]> git.saurik.com Git - apple/xnu.git/blob - bsd/hfs/hfs_macos_defs.h
4038cff5f98d26f12fd53f8185002610e28e3773
[apple/xnu.git] / bsd / hfs / hfs_macos_defs.h
1 /*
2 * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved.
3 *
4 * @APPLE_LICENSE_OSREFERENCE_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
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
14 * agreement.
15 *
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
18 * file.
19 *
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
27 *
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
29 */
30
31 #ifndef __HFS_MACOS_TYPES__
32 #define __HFS_MACOS_TYPES__
33
34 #include <sys/appleapiopts.h>
35
36 #ifdef KERNEL
37 #ifdef __APPLE_API_PRIVATE
38
39 #include <sys/param.h>
40 #ifdef KERNEL
41 #include <libkern/libkern.h>
42 #include <sys/systm.h>
43 #endif
44
45 #include <sys/types.h>
46 #include <sys/time.h>
47 #include <sys/proc.h>
48
49
50 #define TARGET_OS_MAC 0
51 #define TARGET_OS_WIN32 0
52 #define TARGET_OS_UNIX 0
53
54 #define PRAGMA_IMPORT 0
55 #define PRAGMA_STRUCT_ALIGN 1
56 #define PRAGMA_ONCE 0
57 #define PRAGMA_STRUCT_PACK 0
58 #define PRAGMA_STRUCT_PACKPUSH 0
59
60 #if __GNUC__ >= 2
61 #define TYPE_LONGLONG 1
62 #else
63 #define TYPE_LONGLONG 0
64 #endif
65 #ifdef __cplusplus
66 #define TYPE_BOOL 1
67 #else
68 #define TYPE_BOOL 0
69 #endif
70
71 #define EXTERN_API(_type) extern _type
72 #define EXTERN_API_C(_type) extern _type
73
74 #define CALLBACK_API_C(_type, _name) _type ( * _name)
75
76 #define TARGET_API_MACOS_X 1
77 #define TARGET_API_MAC_OS8 0
78 #define TARGET_API_MAC_CARBON 0
79
80
81
82 /****** START OF MACOSTYPES *********/
83
84
85 /*
86 4.4BSD's sys/types.h defines size_t without defining __size_t__:
87 Things are a lot clearer from here on if we define __size_t__ now.
88 */
89 #define __size_t__
90
91 /*
92 Convert kernel's diagnostic flag to MacOS's
93 */
94 #if HFS_DIAGNOSTIC
95 #define DEBUG_BUILD 1
96 #else
97 #define DEBUG_BUILD 0
98 #endif /* DIAGNOSTIC */
99
100 /********************************************************************************
101
102 Special values in C
103
104 NULL The C standard for an impossible pointer value
105 nil A carry over from pascal, NULL is prefered for C
106
107 *********************************************************************************/
108 #ifndef NULL
109 #define NULL 0
110 #endif
111
112 #ifndef nil
113 #define nil NULL
114 #endif
115
116
117 typedef u_int8_t UInt8;
118 typedef int8_t SInt8;
119 typedef u_int16_t UInt16;
120 typedef int16_t SInt16;
121 typedef u_int32_t UInt32;
122 typedef int32_t SInt32;
123 typedef u_int64_t UInt64;
124 typedef int64_t SInt64;
125
126 typedef char * Ptr;
127 typedef long Size;
128
129 typedef SInt16 OSErr;
130 typedef SInt32 OSStatus;
131 typedef UInt32 ItemCount;
132 typedef void * LogicalAddress;
133 typedef UInt32 ByteCount;
134 typedef UInt8 * BytePtr;
135 typedef UInt32 ByteOffset;
136 typedef UInt32 OptionBits;
137 typedef unsigned long FourCharCode;
138 typedef FourCharCode OSType;
139
140 typedef UInt16 UniChar;
141 typedef unsigned char Str255[256];
142 typedef unsigned char Str31[32];
143 typedef unsigned char * StringPtr;
144 typedef const unsigned char * ConstStr255Param;
145 typedef const unsigned char * ConstStr31Param;
146 typedef const unsigned char * ConstUTF8Param;
147
148 typedef UInt8 Byte;
149
150 typedef UInt32 TextEncoding;
151 typedef UniChar * UniCharArrayPtr;
152 typedef const UniChar * ConstUniCharArrayPtr;
153
154
155 /********************************************************************************
156
157 Boolean types and values
158
159 Boolean A one byte value, holds "false" (0) or "true" (1)
160 false The Boolean value of zero (0)
161 true The Boolean value of one (1)
162
163 *********************************************************************************/
164 /*
165 The identifiers "true" and "false" are becoming keywords in C++
166 and work with the new built-in type "bool"
167 "Boolean" will remain an unsigned char for compatibility with source
168 code written before "bool" existed.
169 */
170 #if !TYPE_BOOL
171
172 enum {
173 false = 0,
174 true = 1
175 };
176
177 #endif /* !TYPE_BOOL */
178
179 typedef unsigned char Boolean;
180
181
182
183
184 EXTERN_API( void ) DebugStr(ConstStr255Param debuggerMsg);
185
186 /*********************************************************************************
187
188 Added types for HFSPlus MacOS X functionality. Needs to be incorporated to
189 other places
190
191 *********************************************************************************/
192
193 typedef struct vnode* FileReference;
194
195
196 /***** START OF MACOSSTUBS ********/
197
198
199 /*
200 SizeTDef.h -- Common definitions
201
202 size_t - this type is defined by several ANSI headers.
203 */
204 #if ! defined (__size_t__)
205 #define __size_t__
206 #if defined (__xlc) || defined (__xlC) || defined (__xlC__) || defined (__MWERKS__)
207 typedef unsigned long size_t;
208 #else /* __xlC */
209 typedef unsigned int size_t;
210 #endif /* __xlC */
211 #endif /* __size_t__ */
212
213
214 /*
215 File: Errors.h
216
217 */
218 enum {
219 noErr = 0,
220 dskFulErr = -34, /*disk full*/
221 bdNamErr = -37, /*there may be no bad names in the final system!*/
222 paramErr = -50, /*error in user parameter list*/
223 memFullErr = -108, /*Not enough room in heap zone*/
224 fileBoundsErr = -1309, /*file's EOF, offset, mark or size is too big*/
225 kTECUsedFallbacksStatus = -8783,
226
227 };
228
229
230 enum {
231 /* Finder Flags */
232 kHasBeenInited = 0x0100,
233 kHasCustomIcon = 0x0400,
234 kIsStationery = 0x0800,
235 kNameLocked = 0x1000,
236 kHasBundle = 0x2000,
237 kIsInvisible = 0x4000,
238 kIsAlias = 0x8000
239 };
240
241 enum {
242 fsRtParID = 1,
243 fsRtDirID = 2
244 };
245
246
247 enum {
248 /* Mac OS encodings*/
249 kTextEncodingMacRoman = 0L,
250 kTextEncodingMacJapanese = 1,
251 kTextEncodingMacChineseTrad = 2,
252 kTextEncodingMacKorean = 3,
253 kTextEncodingMacArabic = 4,
254 kTextEncodingMacHebrew = 5,
255 kTextEncodingMacGreek = 6,
256 kTextEncodingMacCyrillic = 7,
257 kTextEncodingMacDevanagari = 9,
258 kTextEncodingMacGurmukhi = 10,
259 kTextEncodingMacGujarati = 11,
260 kTextEncodingMacOriya = 12,
261 kTextEncodingMacBengali = 13,
262 kTextEncodingMacTamil = 14,
263 kTextEncodingMacTelugu = 15,
264 kTextEncodingMacKannada = 16,
265 kTextEncodingMacMalayalam = 17,
266 kTextEncodingMacSinhalese = 18,
267 kTextEncodingMacBurmese = 19,
268 kTextEncodingMacKhmer = 20,
269 kTextEncodingMacThai = 21,
270 kTextEncodingMacLaotian = 22,
271 kTextEncodingMacGeorgian = 23,
272 kTextEncodingMacArmenian = 24,
273 kTextEncodingMacChineseSimp = 25,
274 kTextEncodingMacTibetan = 26,
275 kTextEncodingMacMongolian = 27,
276 kTextEncodingMacEthiopic = 28,
277 kTextEncodingMacCentralEurRoman = 29,
278 kTextEncodingMacVietnamese = 30,
279 kTextEncodingMacExtArabic = 31, /* The following use script code 0, smRoman*/
280 kTextEncodingMacSymbol = 33,
281 kTextEncodingMacDingbats = 34,
282 kTextEncodingMacTurkish = 35,
283 kTextEncodingMacCroatian = 36,
284 kTextEncodingMacIcelandic = 37,
285 kTextEncodingMacRomanian = 38,
286 kTextEncodingMacUnicode = 0x7E,
287
288 kTextEncodingMacFarsi = 0x8C, /* Like MacArabic but uses Farsi digits */ /* The following use script code 7, smCyrillic */
289 kTextEncodingMacUkrainian = 0x98, /* The following use script code 32, smUnimplemented */
290 };
291
292
293 /* PROTOTYPES */
294
295 #if HFS_DIAGNOSTIC
296 extern void RequireFileLock(FileReference vp, int shareable);
297 #define REQUIRE_FILE_LOCK(vp,s) RequireFileLock((vp),(s))
298 #else
299 #define REQUIRE_FILE_LOCK(vp,s)
300 #endif
301
302
303 EXTERN_API( void )
304 BlockMoveData(const void * srcPtr, void * destPtr, Size byteCount);
305
306 #define BlockMoveData(src, dest, len) bcopy((src), (dest), (len))
307
308 EXTERN_API_C( void )
309 ClearMemory(void * start, UInt32 length);
310
311 #define ClearMemory(start, length) bzero((start), (size_t)(length));
312
313
314 EXTERN_API( Ptr )
315 NewPtr(Size byteCount);
316
317 EXTERN_API( Ptr )
318 NewPtrSysClear(Size byteCount);
319
320 EXTERN_API( void )
321 DisposePtr(Ptr p);
322
323 #endif /* __APPLE_API_PRIVATE */
324 #endif /* KERNEL */
325 #endif /* __HFS_MACOS_TYPES__ */