1 /* 2 * Copyright (c) 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Berkeley Software Design, Inc. 7 * 8 * %sccs.include.redist.c% 9 * 10 * @(#)cdefs.h 8.8 (Berkeley) 01/09/95 11 */ 12 13 #ifndef _CDEFS_H_ 14 #define _CDEFS_H_ 15 16 #if defined(__cplusplus) 17 #define __BEGIN_DECLS extern "C" { 18 #define __END_DECLS }; 19 #else 20 #define __BEGIN_DECLS 21 #define __END_DECLS 22 #endif 23 24 /* 25 * The __CONCAT macro is used to concatenate parts of symbol names, e.g. 26 * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo. 27 * The __CONCAT macro is a bit tricky -- make sure you don't put spaces 28 * in between its arguments. __CONCAT can also concatenate double-quoted 29 * strings produced by the __STRING macro, but this only works with ANSI C. 30 */ 31 #if defined(__STDC__) || defined(__cplusplus) 32 #define __P(protos) protos /* full-blown ANSI C */ 33 #define __CONCAT(x,y) x ## y 34 #define __STRING(x) #x 35 36 #define __const const /* define reserved names to standard */ 37 #define __signed signed 38 #define __volatile volatile 39 #if defined(__cplusplus) 40 #define __inline inline /* convert to C++ keyword */ 41 #else 42 #ifndef __GNUC__ 43 #define __inline /* delete GCC keyword */ 44 #endif /* !__GNUC__ */ 45 #endif /* !__cplusplus */ 46 47 #else /* !(__STDC__ || __cplusplus) */ 48 #define __P(protos) () /* traditional C preprocessor */ 49 #define __CONCAT(x,y) x/**/y 50 #define __STRING(x) "x" 51 52 #ifndef __GNUC__ 53 #define __const /* delete pseudo-ANSI C keywords */ 54 #define __inline 55 #define __signed 56 #define __volatile 57 /* 58 * In non-ANSI C environments, new programs will want ANSI-only C keywords 59 * deleted from the program and old programs will want them left alone. 60 * When using a compiler other than gcc, programs using the ANSI C keywords 61 * const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS. 62 * When using "gcc -traditional", we assume that this is the intent; if 63 * __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone. 64 */ 65 #ifndef NO_ANSI_KEYWORDS 66 #define const /* delete ANSI C keywords */ 67 #define inline 68 #define signed 69 #define volatile 70 #endif 71 #endif /* !__GNUC__ */ 72 #endif /* !(__STDC__ || __cplusplus) */ 73 74 /* 75 * GCC1 and some versions of GCC2 declare dead (non-returning) and 76 * pure (no side effects) functions using "volatile" and "const"; 77 * unfortunately, these then cause warnings under "-ansi -pedantic". 78 * GCC2 uses a new, peculiar __attribute__((attrs)) style. All of 79 * these work for GNU C++ (modulo a slight glitch in the C++ grammar 80 * in the distribution version of 2.5.5). 81 */ 82 #if !defined(__GNUC__) || __GNUC__ < 2 || \ 83 (__GNUC__ == 2 && __GNUC_MINOR__ < 5) 84 #define __attribute__(x) /* delete __attribute__ if non-gcc or gcc1 */ 85 #if defined(__GNUC__) && !defined(__STRICT_ANSI__) 86 #define __dead __volatile 87 #define __pure __const 88 #endif 89 #endif 90 91 /* Delete pseudo-keywords wherever they are not available or needed. */ 92 #ifndef __dead 93 #define __dead 94 #define __pure 95 #endif 96 97 #endif /* !_CDEFS_H_ */ 98