vfs: check userland buffers before reading them.
[haiku.git] / headers / build / config / types.h
blob260fbbc2890dfe3945ae14cfdae36058c683ef28
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
11 #include <config/HaikuConfig.h>
13 #include <inttypes.h>
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.
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;
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;
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
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
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)
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)
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
86 #define __HAIKU_PRI_PREFIX_32 __HAIKU_STD_PRI_PREFIX_32
87 #define __HAIKU_PRI_PREFIX_64 __HAIKU_STD_PRI_PREFIX_64
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
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
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
114 #endif /* _CONFIG_BUILD_TYPES_H */