1 /* 2 * Copyright (c) 2000-2003 Apple Computer, 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 #ifndef _BSD_I386__TYPES_H_ 29 #define _BSD_I386__TYPES_H_ 30 31 #if defined (__i386__) || defined (__x86_64__) 32 33 #if defined(KERNEL) 34 #ifdef XNU_KERNEL_PRIVATE 35 /* 36 * Xcode doesn't currently set up search paths correctly for Kernel extensions, 37 * so the clang headers are not seen in the correct order to use their types. 38 */ 39 #endif 40 #define USE_CLANG_TYPES 0 41 #else 42 #if defined(__has_feature) && __has_feature(modules) 43 #define USE_CLANG_TYPES 1 44 #else 45 #define USE_CLANG_TYPES 0 46 #endif 47 #endif 48 49 #if USE_CLANG_TYPES 50 #include <sys/_types/_ptrdiff_t.h> 51 #include <sys/_types/_size_t.h> 52 #include <sys/_types/_va_list.h> 53 #include <sys/_types/_wchar_t.h> 54 #endif 55 56 /* 57 * This header file contains integer types. It's intended to also contain 58 * flotaing point and other arithmetic types, as needed, later. 59 */ 60 61 #ifdef __GNUC__ 62 typedef __signed char __int8_t; 63 #else /* !__GNUC__ */ 64 typedef char __int8_t; 65 #endif /* !__GNUC__ */ 66 typedef unsigned char __uint8_t; 67 typedef short __int16_t; 68 typedef unsigned short __uint16_t; 69 typedef int __int32_t; 70 typedef unsigned int __uint32_t; 71 typedef long long __int64_t; 72 typedef unsigned long long __uint64_t; 73 74 typedef long __darwin_intptr_t; 75 typedef unsigned int __darwin_natural_t; 76 77 /* 78 * The rune type below is declared to be an ``int'' instead of the more natural 79 * ``unsigned long'' or ``long''. Two things are happening here. It is not 80 * unsigned so that EOF (-1) can be naturally assigned to it and used. Also, 81 * it looks like 10646 will be a 31 bit standard. This means that if your 82 * ints cannot hold 32 bits, you will be in trouble. The reason an int was 83 * chosen over a long is that the is*() and to*() routines take ints (says 84 * ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it 85 * here, you lose a bit of ANSI conformance, but your programs will still 86 * work. 87 * 88 * NOTE: rune_t is not covered by ANSI nor other standards, and should not 89 * be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and 90 * rune_t must be the same type. Also wint_t must be no narrower than 91 * wchar_t, and should also be able to hold all members of the largest 92 * character set plus one extra value (WEOF). wint_t must be at least 16 bits. 93 */ 94 95 typedef int __darwin_ct_rune_t; /* ct_rune_t */ 96 97 /* 98 * mbstate_t is an opaque object to keep conversion state, during multibyte 99 * stream conversions. The content must not be referenced by user programs. 100 */ 101 typedef union { 102 char __mbstate8[128]; 103 long long _mbstateL; /* for alignment */ 104 } __mbstate_t; 105 106 typedef __mbstate_t __darwin_mbstate_t; /* mbstate_t */ 107 108 #if USE_CLANG_TYPES 109 typedef ptrdiff_t __darwin_ptrdiff_t; /* ptr1 - ptr2 */ 110 #elif defined(__PTRDIFF_TYPE__) 111 typedef __PTRDIFF_TYPE__ __darwin_ptrdiff_t; /* ptr1 - ptr2 */ 112 #elif defined(__LP64__) 113 typedef long __darwin_ptrdiff_t; /* ptr1 - ptr2 */ 114 #else 115 typedef int __darwin_ptrdiff_t; /* ptr1 - ptr2 */ 116 #endif /* __GNUC__ */ 117 118 #if USE_CLANG_TYPES 119 typedef size_t __darwin_size_t; /* sizeof() */ 120 #elif defined(__SIZE_TYPE__) 121 typedef __SIZE_TYPE__ __darwin_size_t; /* sizeof() */ 122 #else 123 typedef unsigned long __darwin_size_t; /* sizeof() */ 124 #endif 125 126 #if USE_CLANG_TYPES 127 typedef va_list __darwin_va_list; /* va_list */ 128 #elif (__GNUC__ > 2) 129 typedef __builtin_va_list __darwin_va_list; /* va_list */ 130 #else 131 typedef void * __darwin_va_list; /* va_list */ 132 #endif 133 134 #if USE_CLANG_TYPES 135 typedef wchar_t __darwin_wchar_t; /* wchar_t */ 136 #elif defined(__WCHAR_TYPE__) 137 typedef __WCHAR_TYPE__ __darwin_wchar_t; /* wchar_t */ 138 #else 139 typedef __darwin_ct_rune_t __darwin_wchar_t; /* wchar_t */ 140 #endif 141 142 typedef __darwin_wchar_t __darwin_rune_t; /* rune_t */ 143 144 #if defined(__WINT_TYPE__) 145 typedef __WINT_TYPE__ __darwin_wint_t; /* wint_t */ 146 #else 147 typedef __darwin_ct_rune_t __darwin_wint_t; /* wint_t */ 148 #endif 149 150 typedef unsigned long __darwin_clock_t; /* clock() */ 151 typedef __uint32_t __darwin_socklen_t; /* socklen_t (duh) */ 152 typedef long __darwin_ssize_t; /* byte count or error */ 153 typedef long __darwin_time_t; /* time() */ 154 155 #undef USE_CLANG_TYPES 156 157 #endif /* defined (__i386__) || defined (__x86_64__) */ 158 159 #endif /* _BSD_I386__TYPES_H_ */ 160