The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/sys/cdefs.h

Version: -  FREEBSD  -  FREEBSD11  -  FREEBSD10  -  FREEBSD9  -  FREEBSD92  -  FREEBSD91  -  FREEBSD90  -  FREEBSD8  -  FREEBSD82  -  FREEBSD81  -  FREEBSD80  -  FREEBSD7  -  FREEBSD74  -  FREEBSD73  -  FREEBSD72  -  FREEBSD71  -  FREEBSD70  -  FREEBSD6  -  FREEBSD64  -  FREEBSD63  -  FREEBSD62  -  FREEBSD61  -  FREEBSD60  -  FREEBSD5  -  FREEBSD55  -  FREEBSD54  -  FREEBSD53  -  FREEBSD52  -  FREEBSD51  -  FREEBSD50  -  FREEBSD4  -  FREEBSD3  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    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  * Redistribution and use in source and binary forms, with or without
    9  * modification, are permitted provided that the following conditions
   10  * are met:
   11  * 1. Redistributions of source code must retain the above copyright
   12  *    notice, this list of conditions and the following disclaimer.
   13  * 2. Redistributions in binary form must reproduce the above copyright
   14  *    notice, this list of conditions and the following disclaimer in the
   15  *    documentation and/or other materials provided with the distribution.
   16  * 3. All advertising materials mentioning features or use of this software
   17  *    must display the following acknowledgement:
   18  *      This product includes software developed by the University of
   19  *      California, Berkeley and its contributors.
   20  * 4. Neither the name of the University nor the names of its contributors
   21  *    may be used to endorse or promote products derived from this software
   22  *    without specific prior written permission.
   23  *
   24  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   27  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   28  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   30  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   33  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   34  * SUCH DAMAGE.
   35  *
   36  *      @(#)cdefs.h     8.8 (Berkeley) 1/9/95
   37  * $FreeBSD: src/sys/sys/cdefs.h,v 1.79 2003/10/31 05:42:53 peter Exp $
   38  */
   39 
   40 #ifndef _SYS_CDEFS_H_
   41 #define _SYS_CDEFS_H_
   42 
   43 #if defined(__cplusplus)
   44 #define __BEGIN_DECLS   extern "C" {
   45 #define __END_DECLS     }
   46 #else
   47 #define __BEGIN_DECLS
   48 #define __END_DECLS
   49 #endif
   50 
   51 /*
   52  * Macro to test if we're using a specific version of gcc or later.
   53  */
   54 #ifdef __GNUC__
   55 #define __GNUC_PREREQ__(ma, mi) \
   56         (__GNUC__ > (ma) || __GNUC__ == (ma) && __GNUC_MINOR__ >= (mi))
   57 #else
   58 #define __GNUC_PREREQ__(ma, mi) 0
   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 to use if it must work in non-ANSI
   65  * mode -- there must be no spaces between its arguments, and for nested
   66  * __CONCAT's, all the __CONCAT's must be at the left.  __CONCAT can also
   67  * concatenate double-quoted strings produced by the __STRING macro, but
   68  * this only works with ANSI C.
   69  *
   70  * __XSTRING is like __STRING, but it expands any macros in its argument
   71  * first.  It is only available with ANSI C.
   72  */
   73 #if defined(__STDC__) || defined(__cplusplus)
   74 #define __P(protos)     protos          /* full-blown ANSI C */
   75 #define __CONCAT1(x,y)  x ## y
   76 #define __CONCAT(x,y)   __CONCAT1(x,y)
   77 #define __STRING(x)     #x              /* stringify without expanding x */
   78 #define __XSTRING(x)    __STRING(x)     /* expand x, then stringify */
   79 
   80 #define __const         const           /* define reserved names to standard */
   81 #define __signed        signed
   82 #define __volatile      volatile
   83 #if defined(__cplusplus)
   84 #define __inline        inline          /* convert to C++ keyword */
   85 #else
   86 #ifndef __GNUC__
   87 #define __inline                        /* delete GCC keyword */
   88 #endif /* !__GNUC__ */
   89 #endif /* !__cplusplus */
   90 
   91 #else   /* !(__STDC__ || __cplusplus) */
   92 #define __P(protos)     ()              /* traditional C preprocessor */
   93 #define __CONCAT(x,y)   x/**/y
   94 #define __STRING(x)     "x"
   95 
   96 #ifndef __GNUC__
   97 #define __const                         /* delete pseudo-ANSI C keywords */
   98 #define __inline
   99 #define __signed
  100 #define __volatile
  101 /*
  102  * In non-ANSI C environments, new programs will want ANSI-only C keywords
  103  * deleted from the program and old programs will want them left alone.
  104  * When using a compiler other than gcc, programs using the ANSI C keywords
  105  * const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS.
  106  * When using "gcc -traditional", we assume that this is the intent; if
  107  * __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone.
  108  */
  109 #ifndef NO_ANSI_KEYWORDS
  110 #define const                           /* delete ANSI C keywords */
  111 #define inline
  112 #define signed
  113 #define volatile
  114 #endif  /* !NO_ANSI_KEYWORDS */
  115 #endif  /* !__GNUC__ */
  116 #endif  /* !(__STDC__ || __cplusplus) */
  117 
  118 /*
  119  * Compiler-dependent macros to help declare dead (non-returning) and
  120  * pure (no side effects) functions, and unused variables.  They are
  121  * null except for versions of gcc that are known to support the features
  122  * properly (old versions of gcc-2 supported the dead and pure features
  123  * in a different (wrong) way).  If we do not provide an implementation
  124  * for a given compiler, let the compile fail if it is told to use
  125  * a feature that we cannot live without.
  126  */
  127 #ifdef lint
  128 #define __dead2
  129 #define __pure2
  130 #define __unused
  131 #define __packed
  132 #define __aligned(x)
  133 #define __section(x)
  134 #else
  135 #if !__GNUC_PREREQ__(2, 5)
  136 #define __dead2
  137 #define __pure2
  138 #define __unused
  139 #endif
  140 #if __GNUC__ == 2 && __GNUC_MINOR__ >= 5 && __GNUC_MINOR__ < 7
  141 #define __dead2         __attribute__((__noreturn__))
  142 #define __pure2         __attribute__((__const__))
  143 #define __unused
  144 /* XXX Find out what to do for __packed, __aligned and __section */
  145 #endif
  146 #if __GNUC_PREREQ__(2, 7)
  147 #define __dead2         __attribute__((__noreturn__))
  148 #define __pure2         __attribute__((__const__))
  149 #define __unused        __attribute__((__unused__))
  150 #define __packed        __attribute__((__packed__))
  151 #define __aligned(x)    __attribute__((__aligned__(x)))
  152 #define __section(x)    __attribute__((__section__(x)))
  153 #endif
  154 #endif
  155 
  156 #if __GNUC_PREREQ__(3, 1)
  157 #define __always_inline __attribute__((__always_inline__))
  158 #else
  159 #define __always_inline
  160 #endif
  161 
  162 #if __GNUC_PREREQ__(3, 3)
  163 #define __nonnull(x)    __attribute__((__nonnull__(x)))
  164 #else
  165 #define __nonnull(x)
  166 #endif
  167 
  168 /* XXX: should use `#if __STDC_VERSION__ < 199901'. */
  169 #if !__GNUC_PREREQ__(2, 7)
  170 #define __func__        NULL
  171 #endif
  172 
  173 #if __GNUC__ >= 2 && !defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901
  174 #define __LONG_LONG_SUPPORTED
  175 #endif
  176 
  177 /*
  178  * GCC 2.95 provides `__restrict' as an extension to C90 to support the
  179  * C99-specific `restrict' type qualifier.  We happen to use `__restrict' as
  180  * a way to define the `restrict' type qualifier without disturbing older
  181  * software that is unaware of C99 keywords.
  182  */
  183 #if !(__GNUC__ == 2 && __GNUC_MINOR__ == 95)
  184 #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901
  185 #define __restrict
  186 #else
  187 #define __restrict      restrict
  188 #endif
  189 #endif
  190 
  191 /*
  192  * GNU C version 2.96 adds explicit branch prediction so that
  193  * the CPU back-end can hint the processor and also so that
  194  * code blocks can be reordered such that the predicted path
  195  * sees a more linear flow, thus improving cache behavior, etc.
  196  *
  197  * The following two macros provide us with a way to utilize this
  198  * compiler feature.  Use __predict_true() if you expect the expression
  199  * to evaluate to true, and __predict_false() if you expect the
  200  * expression to evaluate to false.
  201  *
  202  * A few notes about usage:
  203  *
  204  *      * Generally, __predict_false() error condition checks (unless
  205  *        you have some _strong_ reason to do otherwise, in which case
  206  *        document it), and/or __predict_true() `no-error' condition
  207  *        checks, assuming you want to optimize for the no-error case.
  208  *
  209  *      * Other than that, if you don't know the likelihood of a test
  210  *        succeeding from empirical or other `hard' evidence, don't
  211  *        make predictions.
  212  *
  213  *      * These are meant to be used in places that are run `a lot'.
  214  *        It is wasteful to make predictions in code that is run
  215  *        seldomly (e.g. at subsystem initialization time) as the
  216  *        basic block reordering that this affects can often generate
  217  *        larger code.
  218  */
  219 #if __GNUC_PREREQ__(2, 96)
  220 #define __predict_true(exp)     __builtin_expect((exp), 1)
  221 #define __predict_false(exp)    __builtin_expect((exp), 0)
  222 #else
  223 #define __predict_true(exp)     (exp)
  224 #define __predict_false(exp)    (exp)
  225 #endif
  226 
  227 /*
  228  * We define this here since <stddef.h>, <sys/queue.h>, and <sys/types.h>
  229  * require it.
  230  */
  231 #define __offsetof(type, field) ((size_t)(&((type *)0)->field))
  232 
  233 /*
  234  * Compiler-dependent macros to declare that functions take printf-like
  235  * or scanf-like arguments.  They are null except for versions of gcc
  236  * that are known to support the features properly (old versions of gcc-2
  237  * didn't permit keeping the keywords out of the application namespace).
  238  */
  239 #if !__GNUC_PREREQ__(2, 7)
  240 #define __printflike(fmtarg, firstvararg)
  241 #define __scanflike(fmtarg, firstvararg)
  242 #else
  243 #define __printflike(fmtarg, firstvararg) \
  244             __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
  245 #define __scanflike(fmtarg, firstvararg) \
  246             __attribute__((__format__ (__scanf__, fmtarg, firstvararg)))
  247 #endif
  248 
  249 /* Compiler-dependent macros that rely on FreeBSD-specific extensions. */
  250 #if __FreeBSD_cc_version >= 300001
  251 #define __printf0like(fmtarg, firstvararg) \
  252             __attribute__((__format__ (__printf0__, fmtarg, firstvararg)))
  253 #else
  254 #define __printf0like(fmtarg, firstvararg)
  255 #endif
  256 
  257 #ifdef __GNUC__
  258 #define __strong_reference(sym,aliassym)        \
  259         extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym)));
  260 #ifdef __STDC__
  261 #define __weak_reference(sym,alias)     \
  262         __asm__(".weak " #alias);       \
  263         __asm__(".equ "  #alias ", " #sym)
  264 #define __warn_references(sym,msg)      \
  265         __asm__(".section .gnu.warning." #sym); \
  266         __asm__(".asciz \"" msg "\"");  \
  267         __asm__(".previous")
  268 #else
  269 #define __weak_reference(sym,alias)     \
  270         __asm__(".weak alias");         \
  271         __asm__(".equ alias, sym")
  272 #define __warn_references(sym,msg)      \
  273         __asm__(".section .gnu.warning.sym"); \
  274         __asm__(".asciz \"msg\"");      \
  275         __asm__(".previous")
  276 #endif  /* __STDC__ */
  277 #endif  /* __GNUC__ */
  278 
  279 #ifdef __GNUC__
  280 #define __IDSTRING(name,string) __asm__(".ident\t\"" string "\"")
  281 #else
  282 /*
  283  * The following definition might not work well if used in header files,
  284  * but it should be better than nothing.  If you want a "do nothing"
  285  * version, then it should generate some harmless declaration, such as:
  286  *    #define __IDSTRING(name,string)   struct __hack
  287  */
  288 #define __IDSTRING(name,string) static const char name[] __unused = string
  289 #endif
  290 
  291 /*
  292  * Embed the rcs id of a source file in the resulting library.  Note that in
  293  * more recent ELF binutils, we use .ident allowing the ID to be stripped.
  294  * Usage:
  295  *      __FBSDID("$FreeBSD: src/sys/sys/cdefs.h,v 1.79 2003/10/31 05:42:53 peter Exp $");
  296  */
  297 #ifndef __FBSDID
  298 #if !defined(lint) && !defined(STRIP_FBSDID)
  299 #define __FBSDID(s)     __IDSTRING(__CONCAT(__rcsid_,__LINE__),s)
  300 #else
  301 #define __FBSDID(s)     struct __hack
  302 #endif
  303 #endif
  304 
  305 #ifndef __RCSID
  306 #ifndef NO__RCSID
  307 #define __RCSID(s)      __IDSTRING(__CONCAT(__rcsid_,__LINE__),s)
  308 #else
  309 #define __RCSID(s)      struct __hack
  310 #endif
  311 #endif
  312 
  313 #ifndef __RCSID_SOURCE
  314 #ifndef NO__RCSID_SOURCE
  315 #define __RCSID_SOURCE(s)       __IDSTRING(__CONCAT(__rcsid_source_,__LINE__),s)
  316 #else
  317 #define __RCSID_SOURCE(s)       struct __hack
  318 #endif
  319 #endif
  320 
  321 #ifndef __SCCSID
  322 #ifndef NO__SCCSID
  323 #define __SCCSID(s)     __IDSTRING(__CONCAT(__sccsid_,__LINE__),s)
  324 #else
  325 #define __SCCSID(s)     struct __hack
  326 #endif
  327 #endif
  328 
  329 #ifndef __COPYRIGHT
  330 #ifndef NO__COPYRIGHT
  331 #define __COPYRIGHT(s)  __IDSTRING(__CONCAT(__copyright_,__LINE__),s)
  332 #else
  333 #define __COPYRIGHT(s)  struct __hack
  334 #endif
  335 #endif
  336 
  337 #ifndef __DECONST
  338 #define __DECONST(type, var)    ((type)(uintptr_t)(const void *)(var))
  339 #endif
  340 
  341 #ifndef __DEVOLATILE
  342 #define __DEVOLATILE(type, var) ((type)(uintptr_t)(volatile void *)(var))
  343 #endif
  344 
  345 #ifndef __DEQUALIFY
  346 #define __DEQUALIFY(type, var)  ((type)(uintptr_t)(const volatile void *)(var))
  347 #endif
  348 
  349 /*-
  350  * The following definitions are an extension of the behavior originally
  351  * implemented in <sys/_posix.h>, but with a different level of granularity.
  352  * POSIX.1 requires that the macros we test be defined before any standard
  353  * header file is included.
  354  *
  355  * Here's a quick run-down of the versions:
  356  *  defined(_POSIX_SOURCE)              1003.1-1988
  357  *  _POSIX_C_SOURCE == 1                1003.1-1990
  358  *  _POSIX_C_SOURCE == 2                1003.2-1992 C Language Binding Option
  359  *  _POSIX_C_SOURCE == 199309           1003.1b-1993
  360  *  _POSIX_C_SOURCE == 199506           1003.1c-1995, 1003.1i-1995,
  361  *                                      and the omnibus ISO/IEC 9945-1: 1996
  362  *  _POSIX_C_SOURCE == 200112           1003.1-2001
  363  *
  364  * In addition, the X/Open Portability Guide, which is now the Single UNIX
  365  * Specification, defines a feature-test macro which indicates the version of
  366  * that specification, and which subsumes _POSIX_C_SOURCE.
  367  *
  368  * Our macros begin with two underscores to avoid namespace screwage.
  369  */
  370 
  371 /* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1. */
  372 #if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 1
  373 #undef _POSIX_C_SOURCE          /* Probably illegal, but beyond caring now. */
  374 #define _POSIX_C_SOURCE         199009
  375 #endif
  376 
  377 /* Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2. */
  378 #if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 2
  379 #undef _POSIX_C_SOURCE
  380 #define _POSIX_C_SOURCE         199209
  381 #endif
  382 
  383 /* Deal with various X/Open Portability Guides and Single UNIX Spec. */
  384 #ifdef _XOPEN_SOURCE
  385 #if _XOPEN_SOURCE - 0 >= 600
  386 #define __XSI_VISIBLE           600
  387 #undef _POSIX_C_SOURCE
  388 #define _POSIX_C_SOURCE         200112
  389 #elif _XOPEN_SOURCE - 0 >= 500
  390 #define __XSI_VISIBLE           500
  391 #undef _POSIX_C_SOURCE
  392 #define _POSIX_C_SOURCE         199506
  393 #endif
  394 #endif
  395 
  396 /*
  397  * Deal with all versions of POSIX.  The ordering relative to the tests above is
  398  * important.
  399  */
  400 #if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE)
  401 #define _POSIX_C_SOURCE         198808
  402 #endif
  403 #ifdef _POSIX_C_SOURCE
  404 #if _POSIX_C_SOURCE >= 200112
  405 #define __POSIX_VISIBLE         200112
  406 #define __ISO_C_VISIBLE         1999
  407 #elif _POSIX_C_SOURCE >= 199506
  408 #define __POSIX_VISIBLE         199506
  409 #define __ISO_C_VISIBLE         1990
  410 #elif _POSIX_C_SOURCE >= 199309
  411 #define __POSIX_VISIBLE         199309
  412 #define __ISO_C_VISIBLE         1990
  413 #elif _POSIX_C_SOURCE >= 199209
  414 #define __POSIX_VISIBLE         199209
  415 #define __ISO_C_VISIBLE         1990
  416 #elif _POSIX_C_SOURCE >= 199009
  417 #define __POSIX_VISIBLE         199009
  418 #define __ISO_C_VISIBLE         1990
  419 #else
  420 #define __POSIX_VISIBLE         198808
  421 #define __ISO_C_VISIBLE         0
  422 #endif /* _POSIX_C_SOURCE */
  423 #else
  424 /*-
  425  * Deal with _ANSI_SOURCE:
  426  * If it is defined, and no other compilation environment is explicitly
  427  * requested, then define our internal feature-test macros to zero.  This
  428  * makes no difference to the preprocessor (undefined symbols in preprocessing
  429  * expressions are defined to have value zero), but makes it more convenient for
  430  * a test program to print out the values.
  431  *
  432  * If a program mistakenly defines _ANSI_SOURCE and some other macro such as
  433  * _POSIX_C_SOURCE, we will assume that it wants the broader compilation
  434  * environment (and in fact we will never get here).
  435  */
  436 #if defined(_ANSI_SOURCE)       /* Hide almost everything. */
  437 #define __POSIX_VISIBLE         0
  438 #define __XSI_VISIBLE           0
  439 #define __BSD_VISIBLE           0
  440 #define __ISO_C_VISIBLE         1990
  441 #elif defined(_C99_SOURCE)      /* Localism to specify strict C99 env. */
  442 #define __POSIX_VISIBLE         0
  443 #define __XSI_VISIBLE           0
  444 #define __BSD_VISIBLE           0
  445 #define __ISO_C_VISIBLE         1999
  446 #else                           /* Default environment: show everything. */
  447 #define __POSIX_VISIBLE         200112
  448 #define __XSI_VISIBLE           600
  449 #define __BSD_VISIBLE           1
  450 #define __ISO_C_VISIBLE         1999
  451 #endif
  452 #endif
  453 
  454 #endif /* !_SYS_CDEFS_H_ */

Cache object: b8d03547b416a3637293ee5d2553c9db


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.