xref: /xnu-11215/bsd/sys/_types.h (revision 8d741a5d)
1 /*
2  * Copyright (c) 2003-2007 Apple Inc. All rights reserved.
3  *
4  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5  *
6  * This file contains Original Code and/or Modifications of Original Code
7  * as defined in and that are subject to the Apple Public Source License
8  * Version 2.0 (the 'License'). You may not use this file except in
9  * compliance with the License. The rights granted to you under the License
10  * may not be used to create, or enable the creation or redistribution of,
11  * unlawful or unlicensed copies of an Apple operating system, or to
12  * circumvent, violate, or enable the circumvention or violation of, any
13  * terms of an Apple operating system software license agreement.
14  *
15  * Please obtain a copy of the License at
16  * http://www.opensource.apple.com/apsl/ and read it before using this file.
17  *
18  * The Original Code and all software distributed under the License are
19  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23  * Please see the License for the specific language governing rights and
24  * limitations under the License.
25  *
26  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27  */
28 
29 #ifndef _SYS__TYPES_H_
30 #define _SYS__TYPES_H_
31 
32 #include <sys/cdefs.h>
33 #include <machine/_types.h>
34 
35 #if defined(KERNEL)
36 #ifdef XNU_KERNEL_PRIVATE
37 /*
38  * Xcode doesn't currently set up search paths correctly for Kernel extensions,
39  * so the clang headers are not seen in the correct order to use their types.
40  */
41 #endif
42 #define USE_CLANG_TYPES 0
43 #else
44 #if defined(__has_feature) && __has_feature(modules)
45 #define USE_CLANG_TYPES 1
46 #else
47 #define USE_CLANG_TYPES 0
48 #endif
49 #endif
50 
51 #if USE_CLANG_TYPES
52 #include <sys/_types/_null.h>
53 #endif
54 
55 /*
56  * Type definitions; takes common type definitions that must be used
57  * in multiple header files due to [XSI], removes them from the system
58  * space, and puts them in the implementation space.
59  */
60 
61 #if USE_CLANG_TYPES
62 #define __DARWIN_NULL NULL
63 #elif defined(__cplusplus)
64 #ifdef __GNUG__
65 #define __DARWIN_NULL __null
66 #else /* ! __GNUG__ */
67 #ifdef __LP64__
68 #define __DARWIN_NULL (0L)
69 #else /* !__LP64__ */
70 #define __DARWIN_NULL 0
71 #endif /* __LP64__ */
72 #endif /* __GNUG__ */
73 #else /* ! __cplusplus */
74 #define __DARWIN_NULL ((void *)0)
75 #endif
76 
77 #if !defined(DRIVERKIT)
78 typedef __int64_t       __darwin_blkcnt_t;      /* total blocks */
79 typedef __int32_t       __darwin_blksize_t;     /* preferred block size */
80 typedef __int32_t       __darwin_dev_t;         /* dev_t */
81 typedef unsigned int    __darwin_fsblkcnt_t;    /* Used by statvfs and fstatvfs */
82 typedef unsigned int    __darwin_fsfilcnt_t;    /* Used by statvfs and fstatvfs */
83 typedef __uint32_t      __darwin_gid_t;         /* [???] process and group IDs */
84 typedef __uint32_t      __darwin_id_t;          /* [XSI] pid_t, uid_t, or gid_t*/
85 typedef __uint64_t      __darwin_ino64_t;       /* [???] Used for 64 bit inodes */
86 #if __DARWIN_64_BIT_INO_T
87 typedef __darwin_ino64_t __darwin_ino_t;        /* [???] Used for inodes */
88 #else /* !__DARWIN_64_BIT_INO_T */
89 typedef __uint32_t      __darwin_ino_t;         /* [???] Used for inodes */
90 #endif /* __DARWIN_64_BIT_INO_T */
91 typedef __darwin_natural_t __darwin_mach_port_name_t; /* Used by mach */
92 typedef __darwin_mach_port_name_t __darwin_mach_port_t; /* Used by mach */
93 typedef __uint16_t      __darwin_mode_t;        /* [???] Some file attributes */
94 typedef __int64_t       __darwin_off_t;         /* [???] Used for file sizes */
95 typedef __int32_t       __darwin_pid_t;         /* [???] process and group IDs */
96 typedef __uint32_t      __darwin_sigset_t;      /* [???] signal set */
97 typedef __int32_t       __darwin_suseconds_t;   /* [???] microseconds */
98 typedef __uint32_t      __darwin_uid_t;         /* [???] user IDs */
99 typedef __uint32_t      __darwin_useconds_t;    /* [???] microseconds */
100 #endif /* !defined(DRIVERKIT) */
101 typedef unsigned char   __darwin_uuid_t[16];
102 typedef char    __darwin_uuid_string_t[37];
103 
104 #undef USE_CLANG_TYPES
105 
106 #if !defined(KERNEL) && !defined(DRIVERKIT)
107 #include <sys/_pthread/_pthread_types.h>
108 #endif /* !defined(KERNEL) && !defined(DRIVERKIT) */
109 
110 #if defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 5 || __GNUC__ > 3)
111 #define __offsetof(type, field) __builtin_offsetof(type, field)
112 #else /* !(gcc >= 3.5) */
113 #define __offsetof(type, field) ((size_t)(&((type *)0)->field))
114 #endif /* (gcc >= 3.5) */
115 
116 #ifdef KERNEL
117 #include <sys/_types/_offsetof.h>
118 #endif /* KERNEL */
119 
120 #endif  /* _SYS__TYPES_H_ */
121