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