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