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

Cache object: ec8a19d2ebd6242392961a525d229ae0


[ 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.