* Introduced new header directory "config", which ATM contains HaikuConfig.h

and types.h. The idea is to provide a basic architecture/compiler
  abstraction by defining types and macros that allow the posix/ and os/
  headers to be mostly architecture/compiler agnostic. 
* Adjusted the posix/ and os/ headers accordingly.
* <SupportDefs.h>: Introduced B_PRI* and B_SCN* macros similar to the PRI*
  and SCN* macros defined in <inttypes.h>, just for the BeOS/Haiku [u]int*
  types and some POSIX types (e.g. off_t, dev_t, ino_t) that don't have POSIX
  macros. Also the B_PRI* and B_SCN* macros are available unconditionally,
  unlike the <inttypes.h> macros, which require __STDC_FORMAT_MACROS to be
  defined in C++ mode.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34214 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2009-11-24 19:44:07 +00:00
parent b5504a512c
commit 2222d0559d
27 changed files with 674 additions and 269 deletions
+70
View File
@@ -0,0 +1,70 @@
/*
* Copyright 2009, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _CONFIG_HAIKU_CONFIG_H
#define _CONFIG_HAIKU_CONFIG_H
/* Determine the architecture and define macros for some fundamental
properties:
__HAIKU_ARCH - short name of the architecture (used in paths)
__HAIKU_ARCH_<arch> - defined to 1 for the respective architecture
__HAIKU_ARCH_64_BIT - defined to 1 on 64 bit architectures
__HAIKU_BIG_ENDIAN - defined to 1 on big endian architectures
*/
#ifdef __INTEL__
# ifdef __x86_64__
# define __HAIKU_ARCH x86_64
# define __HAIKU_ARCH_X86_64 1
# define __HAIKU_ARCH_64_BIT 1
# else
# define __HAIKU_ARCH x86
# define __HAIKU_ARCH_X86 1
# endif
#elif __POWERPC__
# define __HAIKU_ARCH ppc
# define __HAIKU_ARCH_PPC 1
# define __HAIKU_BIG_ENDIAN 1
#elif __M68K__
# define __HAIKU_ARCH m68k 1
# define __HAIKU_ARCH_M68K 1
# define __HAIKU_BIG_ENDIAN 1
#elif __MIPSEL__
# define __HAIKU_ARCH mipsel
# define __HAIKU_ARCH_MIPSEL 1
#elif __ARM__
# define __HAIKU_ARCH arm
# define __HAIKU_ARCH_ARM 1
#else
# error Unsupported architecture!
#endif
/* implied properties */
#ifndef __HAIKU_ARCH_64_BIT
# define __HAIKU_ARCH_32_BIT 1
#endif
#ifndef __HAIKU_BIG_ENDIAN
# define __HAIKU_LITTLE_ENDIAN 1
#endif
/* architecture specific include macros */
#define __HAIKU_ARCH_HEADER(header) <arch/__HAIKU_ARCH/header>
#define __HAIKU_SUBDIR_ARCH_HEADER(subdir, header) \
<subdir/arch/__HAIKU_ARCH/header>
/* BeOS R5 binary compatibility (gcc 2 on x86) */
#if defined(__HAIKU_ARCH_X86) && __GNUC__ == 2
# define __HAIKU_BEOS_COMPATIBLE 1
#endif
/* BeOS R5 compatible types */
#ifdef __HAIKU_ARCH_X86
/* TODO: This should be "#ifdef __HAIKU_BEOS_COMPATIBLE", but this will
break all gcc 4 C++ optional packages. I.e. switch that at a suitable
time.
*/
# define __HAIKU_BEOS_COMPATIBLE_TYPES 1
#endif
#endif /* _CONFIG_HAIKU_CONFIG_H */
+78
View File
@@ -0,0 +1,78 @@
/*
* Copyright 2009, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _CONFIG_TYPES_H
#define _CONFIG_TYPES_H
#include <config/HaikuConfig.h>
/* fixed-width types -- the __haiku_std_[u]int* types correspond to the POSIX
[u]int*_t types, the _haiku_[u]int* types to the BeOS [u]int* types. If
__HAIKU_BEOS_COMPATIBLE_TYPES is not defined both sets are identical. Once
we drop compatibility for good, we can consolidate the types.
*/
typedef signed char __haiku_std_int8;
typedef unsigned char __haiku_std_uint8;
typedef signed short __haiku_std_int16;
typedef unsigned short __haiku_std_uint16;
typedef signed int __haiku_std_int32;
typedef unsigned int __haiku_std_uint32;
typedef signed long long __haiku_std_int64;
typedef unsigned long long __haiku_std_uint64;
typedef __haiku_std_int8 __haiku_int8;
typedef __haiku_std_uint8 __haiku_uint8;
typedef __haiku_std_int16 __haiku_int16;
typedef __haiku_std_uint16 __haiku_uint16;
#ifdef __HAIKU_BEOS_COMPATIBLE_TYPES
typedef signed long int __haiku_int32;
typedef unsigned long int __haiku_uint32;
#else
typedef __haiku_std_int32 __haiku_int32;
typedef __haiku_std_uint32 __haiku_uint32;
#endif
typedef __haiku_std_int64 __haiku_int64;
typedef __haiku_std_uint64 __haiku_uint64;
/* address types */
#ifdef __HAIKU_ARCH_64_BIT
typedef __haiku_int64 __haiku_saddr_t;
typedef __haiku_uint64 __haiku_addr_t;
#else
typedef __haiku_int32 __haiku_saddr_t;
typedef __haiku_uint32 __haiku_addr_t;
#endif
/* address type limits */
#ifdef __HAIKU_ARCH_64_BIT
# define __HAIKU_SADDR_MAX (9223372036854775807LL)
# define __HAIKU_ADDR_MAX (18446744073709551615ULL)
#else
# define __HAIKU_SADDR_MAX (2147483647)
# define __HAIKU_ADDR_MAX (4294967295U)
#endif
#define __HAIKU_SADDR_MIN (-__HAIKU_SADDR_MIN-1)
/* printf()/scanf() format prefixes */
#define __HAIKU_STD_PRI_PREFIX_32 ""
#define __HAIKU_STD_PRI_PREFIX_64 "ll"
#ifdef __HAIKU_BEOS_COMPATIBLE_TYPES
# define __HAIKU_PRI_PREFIX_32 "l"
#else
# define __HAIKU_PRI_PREFIX_32 __HAIKU_STD_PRI_PREFIX_32
#endif
#define __HAIKU_PRI_PREFIX_64 __HAIKU_STD_PRI_PREFIX_64
#ifdef __HAIKU_ARCH_64_BIT
# define __HAIKU_PRI_PREFIX_ADDR __HAIKU_STD_PRI_PREFIX_64
#else
# define __HAIKU_PRI_PREFIX_ADDR __HAIKU_STD_PRI_PREFIX_32
#endif
#endif /* _CONFIG_TYPES_H */