xref: /haiku/headers/build/config/types.h (revision e81a954787e50e56a7f06f72705b7859b6ab06d1)
1 /*
2  * Copyright 2009-2011, Haiku, Inc. All Rights Reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifdef HAIKU_HOST_PLATFORM_HAIKU
6 #include_next <config/types.h>
7 #elif !defined(_CONFIG_BUILD_TYPES_H)
8 #define _CONFIG_BUILD_TYPES_H
9 
10 
11 #include <config/HaikuConfig.h>
12 
13 #include <inttypes.h>
14 
15 
16 /* fixed-width types -- the __haiku_std_[u]int* types correspond to the POSIX
17    [u]int*_t types, the _haiku_[u]int* types to the BeOS [u]int* types. If
18    __HAIKU_BEOS_COMPATIBLE_TYPES is not defined both sets are identical. Once
19    we drop compatibility for good, we can consolidate the types.
20 */
21 typedef int8_t				__haiku_std_int8;
22 typedef uint8_t				__haiku_std_uint8;
23 typedef int16_t				__haiku_std_int16;
24 typedef uint16_t			__haiku_std_uint16;
25 typedef int32_t				__haiku_std_int32;
26 typedef uint32_t			__haiku_std_uint32;
27 typedef int64_t				__haiku_std_int64;
28 typedef uint64_t			__haiku_std_uint64;
29 
30 typedef __haiku_std_int8	__haiku_int8;
31 typedef __haiku_std_uint8	__haiku_uint8;
32 typedef __haiku_std_int16	__haiku_int16;
33 typedef __haiku_std_uint16	__haiku_uint16;
34 typedef __haiku_std_int32	__haiku_int32;
35 typedef __haiku_std_uint32	__haiku_uint32;
36 typedef __haiku_std_int64	__haiku_int64;
37 typedef __haiku_std_uint64	__haiku_uint64;
38 
39 /* address types */
40 #ifdef __HAIKU_ARCH_64_BIT
41 	typedef	__haiku_int64	__haiku_saddr_t;
42 	typedef	__haiku_uint64	__haiku_addr_t;
43 #else
44 	typedef	__haiku_int32	__haiku_saddr_t;
45 	typedef	__haiku_uint32	__haiku_addr_t;
46 #endif
47 
48 #ifdef __HAIKU_ARCH_PHYSICAL_64_BIT
49 	typedef	__haiku_int64	__haiku_phys_saddr_t;
50 	typedef	__haiku_uint64	__haiku_phys_addr_t;
51 #else
52 	typedef	__haiku_int32	__haiku_phys_saddr_t;
53 	typedef	__haiku_uint32	__haiku_phys_addr_t;
54 #endif
55 
56 /* address type limits */
57 #ifdef __HAIKU_ARCH_64_BIT
58 #	define __HAIKU_SADDR_MAX		(9223372036854775807LL)
59 #	define __HAIKU_ADDR_MAX			(18446744073709551615ULL)
60 #else
61 #	define __HAIKU_SADDR_MAX		(2147483647)
62 #	define __HAIKU_ADDR_MAX			(4294967295U)
63 #endif
64 #define __HAIKU_SADDR_MIN			(-__HAIKU_SADDR_MAX-1)
65 
66 #ifdef __HAIKU_ARCH_PHYSICAL_64_BIT
67 #	define __HAIKU_PHYS_SADDR_MAX	(9223372036854775807LL)
68 #	define __HAIKU_PHYS_ADDR_MAX	(18446744073709551615ULL)
69 #else
70 #	define __HAIKU_PHYS_SADDR_MAX	(2147483647)
71 #	define __HAIKU_PHYS_ADDR_MAX	(4294967295U)
72 #endif
73 #define __HAIKU_PHYS_SADDR_MIN		(-__HAIKU_SADDR_MAX-1)
74 
75 
76 /* printf()/scanf() format prefixes */
77 /* TODO: The following are only guesses! We should define them in the
78    build/host headers. */
79 #define	__HAIKU_STD_PRI_PREFIX_32	""
80 #ifdef __HAIKU_ARCH_64_BIT
81 #	define __HAIKU_STD_PRI_PREFIX_64	"l"
82 #else
83 #	define __HAIKU_STD_PRI_PREFIX_64	"ll"
84 #endif
85 
86 #define	__HAIKU_PRI_PREFIX_32		__HAIKU_STD_PRI_PREFIX_32
87 #define	__HAIKU_PRI_PREFIX_64		__HAIKU_STD_PRI_PREFIX_64
88 
89 #ifdef __HAIKU_ARCH_64_BIT
90 #	define __HAIKU_PRI_PREFIX_ADDR	__HAIKU_PRI_PREFIX_64
91 #else
92 #	define __HAIKU_PRI_PREFIX_ADDR	__HAIKU_PRI_PREFIX_32
93 #endif
94 
95 #ifdef __HAIKU_ARCH_PHYSICAL_64_BIT
96 #	define __HAIKU_PRI_PREFIX_PHYS_ADDR	__HAIKU_PRI_PREFIX_64
97 #else
98 #	define __HAIKU_PRI_PREFIX_PHYS_ADDR	__HAIKU_PRI_PREFIX_32
99 #endif
100 
101 
102 /* a generic address type wide enough for virtual and physical addresses */
103 #if __HAIKU_ARCH_BITS >= __HAIKU_ARCH_PHYSICAL_BITS
104 	typedef __haiku_addr_t					__haiku_generic_addr_t;
105 #	define __HAIKU_GENERIC_ADDR_MAX			__HAIKU_ADDR_MAX
106 #	define __HAIKU_PRI_PREFIX_GENERIC_ADDR	__HAIKU_PRI_PREFIX_ADDR
107 #else
108 	typedef __haiku_phys_addr_t				__haiku_generic_addr_t;
109 #	define __HAIKU_GENERIC_ADDR_MAX			__HAIKU_PHYS_ADDR_MAX
110 #	define __HAIKU_PRI_PREFIX_GENERIC_ADDR	__HAIKU_PRI_PREFIX_PHYS_ADDR
111 #endif
112 
113 
114 #endif	/* _CONFIG_BUILD_TYPES_H */
115