cdefs.h revision 1.12
1/* $NetBSD: cdefs.h,v 1.12 1994/07/22 01:44:47 cgd 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#if defined(__cplusplus) 45#define __BEGIN_DECLS extern "C" { 46#define __END_DECLS }; 47#else 48#define __BEGIN_DECLS 49#define __END_DECLS 50#endif 51 52/* 53 * The __CONCAT macro is used to concatenate parts of symbol names, e.g. 54 * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo. 55 * The __CONCAT macro is a bit tricky -- make sure you don't put spaces 56 * in between its arguments. __CONCAT can also concatenate double-quoted 57 * strings produced by the __STRING macro, but this only works with ANSI C. 58 */ 59#if defined(__STDC__) || defined(__cplusplus) 60#define __P(protos) protos /* full-blown ANSI C */ 61#define __CONCAT(x,y) x ## y 62#define __STRING(x) #x 63 64#define __const const /* define reserved names to standard */ 65#define __signed signed 66#define __volatile volatile 67#if defined(__cplusplus) 68#define __inline inline /* convert to C++ keyword */ 69#else 70#ifndef __GNUC__ 71#define __inline /* delete GCC keyword */ 72#endif /* !__GNUC__ */ 73#endif /* !__cplusplus */ 74 75#else /* !(__STDC__ || __cplusplus) */ 76#define __P(protos) () /* traditional C preprocessor */ 77#define __CONCAT(x,y) x/**/y 78#define __STRING(x) "x" 79 80#ifndef __GNUC__ 81#define __const /* delete pseudo-ANSI C keywords */ 82#define __inline 83#define __signed 84#define __volatile 85#endif /* !__GNUC__ */ 86 87/* 88 * In non-ANSI C environments, new programs will want ANSI-only C keywords 89 * deleted from the program and old programs will want them left alone. 90 * Programs using the ANSI C keywords const, inline etc. as normal 91 * identifiers should define -DNO_ANSI_KEYWORDS. 92 */ 93#ifndef NO_ANSI_KEYWORDS 94#define const __const /* convert ANSI C keywords */ 95#define inline __inline 96#define signed __signed 97#define volatile __volatile 98#endif /* !NO_ANSI_KEYWORDS */ 99#endif /* !(__STDC__ || __cplusplus) */ 100 101/* 102 * GCC1 and some versions of GCC2 declare dead (non-returning) and 103 * pure (no side effects) functions using "volatile" and "const"; 104 * unfortunately, these then cause warnings under "-ansi -pedantic". 105 * GCC2 uses a new, peculiar __attribute__((attrs)) style. All of 106 * these work for GNU C++ (modulo a slight glitch in the C++ grammar 107 * in the distribution version of 2.5.5). 108 */ 109#if !defined(__GNUC__) || __GNUC__ < 2 || \ 110 (__GNUC__ == 2 && __GNUC_MINOR__ < 5) 111#define __attribute__(x) /* delete __attribute__ if non-gcc or gcc1 */ 112#if defined(__GNUC__) && !defined(__STRICT_ANSI__) 113#define __dead __volatile 114#define __pure __const 115#endif 116#endif 117 118/* Delete pseudo-keywords wherever they are not available or needed. */ 119#ifndef __dead 120#define __dead 121#define __pure 122#endif 123 124 125/* 126 * The __warn_references macro is used to instruct the linker to print 127 * warning message "msg" if symbol "sym" is referenced. 128 */ 129#ifdef __GNUC__ 130#ifdef __STDC__ 131#define __warn_references(sym,msg) \ 132__asm__(".stabs \"" msg "\",30,0,0,0\n.stabs \"_" #sym "\",1,0,0,0") 133#else 134#define __warn_references(sym,msg) \ 135__asm__(".stabs msg,30,0,0,0\n.stabs \"_/**/sym\",1,0,0,0") 136#endif 137#else 138#define __warn_references(sym,msg) 139#endif 140 141#endif /* !_CDEFS_H_ */ 142