1*e2eeea75SSimon J. Gerraty /* $NetBSD: cdefs.h,v 1.18 1997/06/18 19:09:50 christos Exp $ */ 2*e2eeea75SSimon J. Gerraty 3*e2eeea75SSimon J. Gerraty /* 4*e2eeea75SSimon J. Gerraty * Copyright (c) 1991, 1993 5*e2eeea75SSimon J. Gerraty * The Regents of the University of California. All rights reserved. 6*e2eeea75SSimon J. Gerraty * 7*e2eeea75SSimon J. Gerraty * This code is derived from software contributed to Berkeley by 8*e2eeea75SSimon J. Gerraty * Berkeley Software Design, Inc. 9*e2eeea75SSimon J. Gerraty * 10*e2eeea75SSimon J. Gerraty * Redistribution and use in source and binary forms, with or without 11*e2eeea75SSimon J. Gerraty * modification, are permitted provided that the following conditions 12*e2eeea75SSimon J. Gerraty * are met: 13*e2eeea75SSimon J. Gerraty * 1. Redistributions of source code must retain the above copyright 14*e2eeea75SSimon J. Gerraty * notice, this list of conditions and the following disclaimer. 15*e2eeea75SSimon J. Gerraty * 2. Redistributions in binary form must reproduce the above copyright 16*e2eeea75SSimon J. Gerraty * notice, this list of conditions and the following disclaimer in the 17*e2eeea75SSimon J. Gerraty * documentation and/or other materials provided with the distribution. 18*e2eeea75SSimon J. Gerraty * 3. All advertising materials mentioning features or use of this software 19*e2eeea75SSimon J. Gerraty * must display the following acknowledgement: 20*e2eeea75SSimon J. Gerraty * This product includes software developed by the University of 21*e2eeea75SSimon J. Gerraty * California, Berkeley and its contributors. 22*e2eeea75SSimon J. Gerraty * 4. Neither the name of the University nor the names of its contributors 23*e2eeea75SSimon J. Gerraty * may be used to endorse or promote products derived from this software 24*e2eeea75SSimon J. Gerraty * without specific prior written permission. 25*e2eeea75SSimon J. Gerraty * 26*e2eeea75SSimon J. Gerraty * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 27*e2eeea75SSimon J. Gerraty * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28*e2eeea75SSimon J. Gerraty * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 29*e2eeea75SSimon J. Gerraty * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 30*e2eeea75SSimon J. Gerraty * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31*e2eeea75SSimon J. Gerraty * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32*e2eeea75SSimon J. Gerraty * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33*e2eeea75SSimon J. Gerraty * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34*e2eeea75SSimon J. Gerraty * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35*e2eeea75SSimon J. Gerraty * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36*e2eeea75SSimon J. Gerraty * SUCH DAMAGE. 37*e2eeea75SSimon J. Gerraty * 38*e2eeea75SSimon J. Gerraty * @(#)cdefs.h 8.7 (Berkeley) 1/21/94 39*e2eeea75SSimon J. Gerraty */ 40*e2eeea75SSimon J. Gerraty 41*e2eeea75SSimon J. Gerraty #ifndef _SYS_CDEFS_H_ 42*e2eeea75SSimon J. Gerraty 43*e2eeea75SSimon J. Gerraty #if defined(NEED_HOST_CDEFS_H) 44*e2eeea75SSimon J. Gerraty /* 45*e2eeea75SSimon J. Gerraty * make sure we don't come past here again. 46*e2eeea75SSimon J. Gerraty */ 47*e2eeea75SSimon J. Gerraty #undef NEED_HOST_CDEFS_H 48*e2eeea75SSimon J. Gerraty /* 49*e2eeea75SSimon J. Gerraty * Some systems - notably linux, have sys/cdefs.h 50*e2eeea75SSimon J. Gerraty * which is not really compatible with our's. 51*e2eeea75SSimon J. Gerraty */ 52*e2eeea75SSimon J. Gerraty #ifdef __GNUC__ 53*e2eeea75SSimon J. Gerraty # include_next <sys/cdefs.h> 54*e2eeea75SSimon J. Gerraty #else 55*e2eeea75SSimon J. Gerraty /* 56*e2eeea75SSimon J. Gerraty * It sucks that we have to hard code a path like this. 57*e2eeea75SSimon J. Gerraty * But systems that have a sys/cdefs.h that don't use gcc 58*e2eeea75SSimon J. Gerraty * should be few. 59*e2eeea75SSimon J. Gerraty */ 60*e2eeea75SSimon J. Gerraty # include "/usr/include/sys/cdefs.h" 61*e2eeea75SSimon J. Gerraty #endif 62*e2eeea75SSimon J. Gerraty /* 63*e2eeea75SSimon J. Gerraty * We are about to [re]define these 64*e2eeea75SSimon J. Gerraty */ 65*e2eeea75SSimon J. Gerraty #undef __P 66*e2eeea75SSimon J. Gerraty #undef _SYS_CDEFS_H_ 67*e2eeea75SSimon J. Gerraty #endif 68*e2eeea75SSimon J. Gerraty 69*e2eeea75SSimon J. Gerraty #define _SYS_CDEFS_H_ 70*e2eeea75SSimon J. Gerraty 71*e2eeea75SSimon J. Gerraty #ifdef NetBSD 72*e2eeea75SSimon J. Gerraty #include <machine/cdefs.h> 73*e2eeea75SSimon J. Gerraty #endif 74*e2eeea75SSimon J. Gerraty 75*e2eeea75SSimon J. Gerraty #if defined(__cplusplus) 76*e2eeea75SSimon J. Gerraty # ifndef __BEGIN_DECLS 77*e2eeea75SSimon J. Gerraty # define __BEGIN_DECLS extern "C" { 78*e2eeea75SSimon J. Gerraty # endif 79*e2eeea75SSimon J. Gerraty # ifndef __END_DECLS 80*e2eeea75SSimon J. Gerraty # define __END_DECLS }; 81*e2eeea75SSimon J. Gerraty # endif 82*e2eeea75SSimon J. Gerraty #else 83*e2eeea75SSimon J. Gerraty # ifndef __BEGIN_DECLS 84*e2eeea75SSimon J. Gerraty # define __BEGIN_DECLS 85*e2eeea75SSimon J. Gerraty # endif 86*e2eeea75SSimon J. Gerraty # ifndef __END_DECLS 87*e2eeea75SSimon J. Gerraty # define __END_DECLS 88*e2eeea75SSimon J. Gerraty # endif 89*e2eeea75SSimon J. Gerraty #endif 90*e2eeea75SSimon J. Gerraty 91*e2eeea75SSimon J. Gerraty /* 92*e2eeea75SSimon J. Gerraty * The __CONCAT macro is used to concatenate parts of symbol names, e.g. 93*e2eeea75SSimon J. Gerraty * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo. 94*e2eeea75SSimon J. Gerraty * The __CONCAT macro is a bit tricky -- make sure you don't put spaces 95*e2eeea75SSimon J. Gerraty * in between its arguments. __CONCAT can also concatenate double-quoted 96*e2eeea75SSimon J. Gerraty * strings produced by the __STRING macro, but this only works with ANSI C. 97*e2eeea75SSimon J. Gerraty */ 98*e2eeea75SSimon J. Gerraty #if defined(__STDC__) || defined(__cplusplus) 99*e2eeea75SSimon J. Gerraty #define __P(protos) protos /* full-blown ANSI C */ 100*e2eeea75SSimon J. Gerraty #ifndef __CONCAT 101*e2eeea75SSimon J. Gerraty #define __CONCAT(x,y) x ## y 102*e2eeea75SSimon J. Gerraty #endif 103*e2eeea75SSimon J. Gerraty #define __STRING(x) #x 104*e2eeea75SSimon J. Gerraty 105*e2eeea75SSimon J. Gerraty #define __const const /* define reserved names to standard */ 106*e2eeea75SSimon J. Gerraty #define __signed signed 107*e2eeea75SSimon J. Gerraty #define __volatile volatile 108*e2eeea75SSimon J. Gerraty #if defined(__cplusplus) 109*e2eeea75SSimon J. Gerraty #define __inline inline /* convert to C++ keyword */ 110*e2eeea75SSimon J. Gerraty #else 111*e2eeea75SSimon J. Gerraty #ifndef __GNUC__ 112*e2eeea75SSimon J. Gerraty #define __inline /* delete GCC keyword */ 113*e2eeea75SSimon J. Gerraty #endif /* !__GNUC__ */ 114*e2eeea75SSimon J. Gerraty #endif /* !__cplusplus */ 115*e2eeea75SSimon J. Gerraty 116*e2eeea75SSimon J. Gerraty #else /* !(__STDC__ || __cplusplus) */ 117*e2eeea75SSimon J. Gerraty #define __P(protos) () /* traditional C preprocessor */ 118*e2eeea75SSimon J. Gerraty #define __CONCAT(x,y) x/**/y 119*e2eeea75SSimon J. Gerraty #define __STRING(x) "x" 120*e2eeea75SSimon J. Gerraty 121*e2eeea75SSimon J. Gerraty #ifndef __GNUC__ 122*e2eeea75SSimon J. Gerraty #define __const /* delete pseudo-ANSI C keywords */ 123*e2eeea75SSimon J. Gerraty #define __inline 124*e2eeea75SSimon J. Gerraty #define __signed 125*e2eeea75SSimon J. Gerraty #define __volatile 126*e2eeea75SSimon J. Gerraty #endif /* !__GNUC__ */ 127*e2eeea75SSimon J. Gerraty 128*e2eeea75SSimon J. Gerraty /* 129*e2eeea75SSimon J. Gerraty * In non-ANSI C environments, new programs will want ANSI-only C keywords 130*e2eeea75SSimon J. Gerraty * deleted from the program and old programs will want them left alone. 131*e2eeea75SSimon J. Gerraty * Programs using the ANSI C keywords const, inline etc. as normal 132*e2eeea75SSimon J. Gerraty * identifiers should define -DNO_ANSI_KEYWORDS. 133*e2eeea75SSimon J. Gerraty */ 134*e2eeea75SSimon J. Gerraty #ifndef NO_ANSI_KEYWORDS 135*e2eeea75SSimon J. Gerraty #define const __const /* convert ANSI C keywords */ 136*e2eeea75SSimon J. Gerraty #define inline __inline 137*e2eeea75SSimon J. Gerraty #define signed __signed 138*e2eeea75SSimon J. Gerraty #define volatile __volatile 139*e2eeea75SSimon J. Gerraty #endif /* !NO_ANSI_KEYWORDS */ 140*e2eeea75SSimon J. Gerraty #endif /* !(__STDC__ || __cplusplus) */ 141*e2eeea75SSimon J. Gerraty 142*e2eeea75SSimon J. Gerraty /* 143*e2eeea75SSimon J. Gerraty * GCC1 and some versions of GCC2 declare dead (non-returning) and 144*e2eeea75SSimon J. Gerraty * pure (no side effects) functions using "volatile" and "const"; 145*e2eeea75SSimon J. Gerraty * unfortunately, these then cause warnings under "-ansi -pedantic". 146*e2eeea75SSimon J. Gerraty * GCC2 uses a new, peculiar __attribute__((attrs)) style. All of 147*e2eeea75SSimon J. Gerraty * these work for GNU C++ (modulo a slight glitch in the C++ grammar 148*e2eeea75SSimon J. Gerraty * in the distribution version of 2.5.5). 149*e2eeea75SSimon J. Gerraty */ 150*e2eeea75SSimon J. Gerraty #if !defined(__GNUC__) || __GNUC__ < 2 || \ 151*e2eeea75SSimon J. Gerraty (__GNUC__ == 2 && __GNUC_MINOR__ < 5) 152*e2eeea75SSimon J. Gerraty #define __attribute__(x) /* delete __attribute__ if non-gcc or gcc1 */ 153*e2eeea75SSimon J. Gerraty #if defined(__GNUC__) && !defined(__STRICT_ANSI__) 154*e2eeea75SSimon J. Gerraty #define __dead __volatile 155*e2eeea75SSimon J. Gerraty #define __pure __const 156*e2eeea75SSimon J. Gerraty #endif 157*e2eeea75SSimon J. Gerraty #endif 158*e2eeea75SSimon J. Gerraty 159*e2eeea75SSimon J. Gerraty #ifdef sun386 160*e2eeea75SSimon J. Gerraty # define __attribute__(x) 161*e2eeea75SSimon J. Gerraty #endif 162*e2eeea75SSimon J. Gerraty 163*e2eeea75SSimon J. Gerraty #ifdef __KPRINTF_ATTRIBUTE__ 164*e2eeea75SSimon J. Gerraty #define __kprintf_attribute__(a) __attribute__(a) 165*e2eeea75SSimon J. Gerraty #else 166*e2eeea75SSimon J. Gerraty #define __kprintf_attribute__(a) 167*e2eeea75SSimon J. Gerraty #endif 168*e2eeea75SSimon J. Gerraty 169*e2eeea75SSimon J. Gerraty /* Delete pseudo-keywords wherever they are not available or needed. */ 170*e2eeea75SSimon J. Gerraty #ifndef __dead 171*e2eeea75SSimon J. Gerraty #define __dead 172*e2eeea75SSimon J. Gerraty #define __pure 173*e2eeea75SSimon J. Gerraty #endif 174*e2eeea75SSimon J. Gerraty 175*e2eeea75SSimon J. Gerraty #define __IDSTRING(name,string) \ 176*e2eeea75SSimon J. Gerraty static const char name[] __attribute__((__unused__)) = string 177*e2eeea75SSimon J. Gerraty 178*e2eeea75SSimon J. Gerraty #ifndef __RCSID 179*e2eeea75SSimon J. Gerraty #define __RCSID(s) __IDSTRING(rcsid,s) 180*e2eeea75SSimon J. Gerraty #endif 181*e2eeea75SSimon J. Gerraty 182*e2eeea75SSimon J. Gerraty #ifndef __COPYRIGHT 183*e2eeea75SSimon J. Gerraty #define __COPYRIGHT(s) __IDSTRING(copyright,s) 184*e2eeea75SSimon J. Gerraty #endif 185*e2eeea75SSimon J. Gerraty 186*e2eeea75SSimon J. Gerraty #endif /* !_SYS_CDEFS_H_ */ 187