1 /* $NetBSD: cdefs.h,v 1.1.1.1 2009/04/12 15:33:55 christos Exp $ */ 2 3 /* 4 * Copyright (c) 1991, 1993 5 * The Regents of the University of California. All rights reserved. 6 * 7 * This code is derived from software contributed to Berkeley by 8 * Berkeley Software Design, Inc. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. All advertising materials mentioning features or use of this software 19 * must display the following acknowledgement: 20 * This product includes software developed by the University of 21 * California, Berkeley and its contributors. 22 * 4. Neither the name of the University nor the names of its contributors 23 * may be used to endorse or promote products derived from this software 24 * without specific prior written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)cdefs.h 8.7 (Berkeley) 1/21/94 39 */ 40 41 #ifndef _CDEFS_H_ 42 #define _CDEFS_H_ 43 44 /* POSIX.2 feature test macro: enable POSIX.1 and/or more */ 45 #if _POSIX_C_SOURCE == 1 || _POSIX_C_SOURCE == 2 46 #define _POSIX_SOURCE 47 #endif 48 49 #if defined(_POSIX_SOURCE) || defined(__STRICT_ANSI__) 50 #define _ANSI_SOURCE 51 #endif 52 53 #if defined(__cplusplus) 54 #define __BEGIN_DECLS extern "C" { 55 #define __END_DECLS }; 56 #else 57 #define __BEGIN_DECLS 58 #define __END_DECLS 59 #endif 60 61 /* 62 * The __CONCAT macro is used to concatenate parts of symbol names, e.g. 63 * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo. 64 * The __CONCAT macro is a bit tricky -- make sure you don't put spaces 65 * in between its arguments. __CONCAT can also concatenate double-quoted 66 * strings produced by the __STRING macro, but this only works with ANSI C. 67 */ 68 #if defined(__STDC__) || defined(__cplusplus) 69 #define __P(protos) protos /* full-blown ANSI C */ 70 #define __CONCAT(x,y) x ## y 71 #define __STRING(x) #x 72 73 #define __const const /* define reserved names to standard */ 74 #define __signed signed 75 #define __volatile volatile 76 #if defined(__cplusplus) 77 #define __inline inline /* convert to C++ keyword */ 78 #else 79 #ifndef __GNUC__ 80 #define __inline /* delete GCC keyword */ 81 #endif /* !__GNUC__ */ 82 #endif /* !__cplusplus */ 83 84 #else /* !(__STDC__ || __cplusplus) */ 85 #define __P(protos) () /* traditional C preprocessor */ 86 #define __CONCAT(x,y) x/**/y 87 #define __STRING(x) "x" 88 89 #ifndef __GNUC__ 90 #define __const /* delete pseudo-ANSI C keywords */ 91 #define __inline 92 #define __signed 93 #define __volatile 94 /* 95 * In non-ANSI C environments, new programs will want ANSI-only C keywords 96 * deleted from the program and old programs will want them left alone. 97 * When using a compiler other than gcc, programs using the ANSI C keywords 98 * const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS. 99 * When using "gcc -traditional", we assume that this is the intent; if 100 * __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone. 101 */ 102 #ifndef NO_ANSI_KEYWORDS 103 #define const /* delete ANSI C keywords */ 104 #define inline 105 #define signed 106 #define volatile 107 #endif 108 #endif /* !__GNUC__ */ 109 #endif /* !(__STDC__ || __cplusplus) */ 110 111 /* 112 * GCC1 and some versions of GCC2 declare dead (non-returning) and 113 * pure (no side effects) functions using "volatile" and "const"; 114 * unfortunately, these then cause warnings under "-ansi -pedantic". 115 * GCC2 uses a new, peculiar __attribute__((attrs)) style. All of 116 * these work for GNU C++ (modulo a slight glitch in the C++ grammar 117 * in the distribution version of 2.5.5). 118 */ 119 #if !defined(__GNUC__) || __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) 120 #define __attribute__(x) /* delete __attribute__ if non-gcc or gcc1 */ 121 #if defined(__GNUC__) && !defined(__STRICT_ANSI__) 122 #define __dead __volatile 123 #define __pure __const 124 #endif 125 #endif 126 /* The following lines were added for newer versions of GNU C 127 * Ed Lewis - Sept 1996 lewis@tis.com 128 */ 129 #if __GNUC__ == 2 && __GNUC_MINOR__ >= 5 || __GNUC__ >= 3 130 #define __dead 131 #define __dead2 __attribute__((noreturn)) 132 #define __pure 133 #define __pure2 __attribute__((const)) 134 #endif 135 136 137 /* Delete pseudo-keywords wherever they are not available or needed. */ 138 #ifndef __dead 139 #define __dead 140 #define __pure 141 #endif 142 143 #endif /* !_CDEFS_H_ */ 144