]> git.saurik.com Git - apple/libc.git/blob - include/c.h
Libc-339.tar.gz
[apple/libc.git] / include / c.h
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25 /*
26 * Standard C macros
27 *
28 **********************************************************************
29 * HISTORY
30 * 02-Feb-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
31 * Added check to allow multiple or recursive inclusion of this
32 * file. Added bool enum from machine/types.h for regular users
33 * that want a real boolean type.
34 *
35 * 29-Dec-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
36 * Also change spacing of MAX and MIN to coincide with that of
37 * sys/param.h.
38 *
39 * 19-Nov-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
40 * Changed the number of tabs between TRUE, FALSE and their
41 * respective values to match those in sys/types.h.
42 *
43 * 17-Dec-84 Glenn Marcy (gm0w) at Carnegie-Mellon University
44 * Only define TRUE and FALSE if not defined. Added caseE macro
45 * for using enumerated types in switch statements.
46 *
47 * 23-Apr-81 Mike Accetta (mja) at Carnegie-Mellon University
48 * Added "sizeofS" and "sizeofA" macros which expand to the size
49 * of a string constant and array respectively.
50 *
51 **********************************************************************
52 */
53
54 #ifndef _C_INCLUDE_
55 #define _C_INCLUDE_
56
57 #ifndef ABS
58 #define ABS(x) ((x)>=0?(x):-(x))
59 #endif /* ABS */
60 #ifndef MIN
61 #define MIN(a,b) (((a)<(b))?(a):(b))
62 #endif /* MIN */
63 #ifndef MAX
64 #define MAX(a,b) (((a)>(b))?(a):(b))
65 #endif /* MAX */
66
67 #ifndef FALSE
68 #define FALSE 0
69 #endif /* FALSE */
70 #ifndef TRUE
71 #define TRUE 1
72 #endif /* TRUE */
73
74 #define CERROR (-1)
75
76 #ifndef bool
77 typedef enum { false = 0, true = 1 } bool;
78 #endif /* bool */
79
80 #define sizeofS(string) (sizeof(string) - 1)
81 #define sizeofA(array) (sizeof(array)/sizeof(array[0]))
82
83 #define caseE(enum_type) case (int)(enum_type)
84
85 #endif /* _C_INCLUDE_ */