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 /*      $OpenBSD: cdefs.h,v 1.43 2018/10/29 17:10:40 guenther Exp $     */
    2 /*      $NetBSD: cdefs.h,v 1.16 1996/04/03 20:46:39 christos Exp $      */
    3 
    4 /*
    5  * Copyright (c) 1991, 1993
    6  *      The Regents of the University of California.  All rights reserved.
    7  *
    8  * This code is derived from software contributed to Berkeley by
    9  * Berkeley Software Design, Inc.
   10  *
   11  * Redistribution and use in source and binary forms, with or without
   12  * modification, are permitted provided that the following conditions
   13  * are met:
   14  * 1. Redistributions of source code must retain the above copyright
   15  *    notice, this list of conditions and the following disclaimer.
   16  * 2. Redistributions in binary form must reproduce the above copyright
   17  *    notice, this list of conditions and the following disclaimer in the
   18  *    documentation and/or other materials provided with the distribution.
   19  * 3. Neither the name of the University nor the names of its contributors
   20  *    may be used to endorse or promote products derived from this software
   21  *    without specific prior written permission.
   22  *
   23  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   33  * SUCH DAMAGE.
   34  *
   35  *      @(#)cdefs.h     8.7 (Berkeley) 1/21/94
   36  */
   37 
   38 #ifndef _SYS_CDEFS_H_
   39 #define _SYS_CDEFS_H_
   40 
   41 #include <machine/cdefs.h>
   42 
   43 /*
   44  * Macro to test if we're using a specific version of gcc or later.
   45  */
   46 #ifdef __GNUC__
   47 #define __GNUC_PREREQ__(ma, mi) \
   48         ((__GNUC__ > (ma)) || (__GNUC__ == (ma) && __GNUC_MINOR__ >= (mi)))
   49 #else
   50 #define __GNUC_PREREQ__(ma, mi) 0
   51 #endif
   52 
   53 /*
   54  * The __CONCAT macro is used to concatenate parts of symbol names, e.g.
   55  * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo.
   56  * The __CONCAT macro is a bit tricky -- make sure you don't put spaces
   57  * in between its arguments.  Do not use __CONCAT on double-quoted strings,
   58  * such as those from the __STRING macro: to concatenate strings just put
   59  * them next to each other.
   60  */
   61 #if defined(__STDC__) || defined(__cplusplus)
   62 #define __P(protos)     protos          /* full-blown ANSI C */
   63 #define __CONCAT(x,y)   x ## y
   64 #define __STRING(x)     #x
   65 
   66 #define __const         const           /* define reserved names to standard */
   67 #define __signed        signed
   68 #define __volatile      volatile
   69 #if defined(__cplusplus) || defined(__PCC__)
   70 #define __inline        inline          /* convert to C++ keyword */
   71 #else
   72 #if !defined(__GNUC__)
   73 #define __inline                        /* delete GCC keyword */
   74 #endif /* !__GNUC__ */
   75 #endif /* !__cplusplus */
   76 
   77 #else   /* !(__STDC__ || __cplusplus) */
   78 #define __P(protos)     ()              /* traditional C preprocessor */
   79 #define __CONCAT(x,y)   x/**/y
   80 #define __STRING(x)     "x"
   81 
   82 #if !defined(__GNUC__)
   83 #define __const                         /* delete pseudo-ANSI C keywords */
   84 #define __inline
   85 #define __signed
   86 #define __volatile
   87 #endif  /* !__GNUC__ */
   88 #endif  /* !(__STDC__ || __cplusplus) */
   89 
   90 /*
   91  * GCC1 and some versions of GCC2 declare dead (non-returning) and
   92  * pure (no side effects) functions using "volatile" and "const";
   93  * unfortunately, these then cause warnings under "-ansi -pedantic".
   94  * GCC >= 2.5 uses the __attribute__((attrs)) style.  All of these
   95  * work for GNU C++ (modulo a slight glitch in the C++ grammar in
   96  * the distribution version of 2.5.5).
   97  */
   98 
   99 #if !__GNUC_PREREQ__(2, 5) && !defined(__PCC__)
  100 #define __attribute__(x)        /* delete __attribute__ if non-gcc or gcc1 */
  101 #if defined(__GNUC__) && !defined(__STRICT_ANSI__)
  102 #define __dead          __volatile
  103 #define __pure          __const
  104 #endif
  105 #else
  106 #define __dead          __attribute__((__noreturn__))
  107 #define __pure          __attribute__((__const__))
  108 #endif
  109 
  110 #if __GNUC_PREREQ__(2, 7)
  111 #define __unused        __attribute__((__unused__))
  112 #else
  113 #define __unused        /* delete */
  114 #endif
  115 
  116 #if __GNUC_PREREQ__(3, 1)
  117 #define __used          __attribute__((__used__))
  118 #else
  119 #define __used          __unused        /* suppress -Wunused warnings */
  120 #endif
  121 
  122 #if __GNUC_PREREQ__(3,4)
  123 # define __warn_unused_result   __attribute__((__warn_unused_result__))
  124 #else
  125 # define __warn_unused_result   /* delete */
  126 #endif
  127 
  128 #if __GNUC_PREREQ__(3,3) && !defined(__clang__)
  129 # define __bounded(args)        __attribute__ ((__bounded__ args ))
  130 #else
  131 # define __bounded(args)        /* delete */
  132 #endif
  133 
  134 /*
  135  * __returns_twice makes the compiler not assume the function
  136  * only returns once.  This affects registerisation of variables:
  137  * even local variables need to be in memory across such a call.
  138  * Example: setjmp()
  139  */
  140 #if __GNUC_PREREQ__(4, 1)
  141 #define __returns_twice __attribute__((returns_twice))
  142 #else
  143 #define __returns_twice
  144 #endif
  145 
  146 /*
  147  * __only_inline makes the compiler only use this function definition
  148  * for inlining; references that can't be inlined will be left as
  149  * external references instead of generating a local copy.  The
  150  * matching library should include a simple extern definition for
  151  * the function to handle those references.  c.f. ctype.h
  152  */
  153 #ifdef __GNUC__
  154 #  if __GNUC_PREREQ__(4, 2)
  155 #define __only_inline   extern __inline __attribute__((__gnu_inline__))
  156 #  else
  157 #define __only_inline   extern __inline
  158 #  endif
  159 #else
  160 #define __only_inline   static __inline
  161 #endif
  162 
  163 /*
  164  * GNU C version 2.96 adds explicit branch prediction so that
  165  * the CPU back-end can hint the processor and also so that
  166  * code blocks can be reordered such that the predicted path
  167  * sees a more linear flow, thus improving cache behavior, etc.
  168  *
  169  * The following two macros provide us with a way to utilize this
  170  * compiler feature.  Use __predict_true() if you expect the expression
  171  * to evaluate to true, and __predict_false() if you expect the
  172  * expression to evaluate to false.
  173  *
  174  * A few notes about usage:
  175  *
  176  *      * Generally, __predict_false() error condition checks (unless
  177  *        you have some _strong_ reason to do otherwise, in which case
  178  *        document it), and/or __predict_true() `no-error' condition
  179  *        checks, assuming you want to optimize for the no-error case.
  180  *
  181  *      * Other than that, if you don't know the likelihood of a test
  182  *        succeeding from empirical or other `hard' evidence, don't
  183  *        make predictions.
  184  *
  185  *      * These are meant to be used in places that are run `a lot'.
  186  *        It is wasteful to make predictions in code that is run
  187  *        seldomly (e.g. at subsystem initialization time) as the
  188  *        basic block reordering that this affects can often generate
  189  *        larger code.
  190  */
  191 #if __GNUC_PREREQ__(2, 96)
  192 #define __predict_true(exp)     __builtin_expect(((exp) != 0), 1)
  193 #define __predict_false(exp)    __builtin_expect(((exp) != 0), 0)
  194 #else
  195 #define __predict_true(exp)     ((exp) != 0)
  196 #define __predict_false(exp)    ((exp) != 0)
  197 #endif
  198 
  199 /* Delete pseudo-keywords wherever they are not available or needed. */
  200 #ifndef __dead
  201 #define __dead
  202 #define __pure
  203 #endif
  204 
  205 /*
  206  * The __packed macro indicates that a variable or structure members
  207  * should have the smallest possible alignment, despite any host CPU
  208  * alignment requirements.
  209  *
  210  * The __aligned(x) macro specifies the minimum alignment of a
  211  * variable or structure.
  212  *
  213  * These macros together are useful for describing the layout and
  214  * alignment of messages exchanged with hardware or other systems.
  215  */
  216 
  217 #if __GNUC_PREREQ__(2, 7) || defined(__PCC__)
  218 #define __packed        __attribute__((__packed__))
  219 #define __aligned(x)    __attribute__((__aligned__(x)))
  220 #endif
  221 
  222 #if !__GNUC_PREREQ__(2, 8)
  223 #define __extension__
  224 #endif
  225 
  226 #if __GNUC_PREREQ__(3, 0)
  227 #define __malloc        __attribute__((__malloc__))
  228 #else
  229 #define __malloc
  230 #endif
  231 
  232 #if defined(__cplusplus)
  233 #define __BEGIN_EXTERN_C        extern "C" {
  234 #define __END_EXTERN_C          }
  235 #else
  236 #define __BEGIN_EXTERN_C
  237 #define __END_EXTERN_C
  238 #endif
  239 
  240 #if __GNUC_PREREQ__(4, 0)
  241 #define __dso_public    __attribute__((__visibility__("default")))
  242 #define __dso_hidden    __attribute__((__visibility__("hidden")))
  243 #define __BEGIN_PUBLIC_DECLS \
  244         _Pragma("GCC visibility push(default)") __BEGIN_EXTERN_C
  245 #define __END_PUBLIC_DECLS      __END_EXTERN_C _Pragma("GCC visibility pop")
  246 #define __BEGIN_HIDDEN_DECLS \
  247         _Pragma("GCC visibility push(hidden)") __BEGIN_EXTERN_C
  248 #define __END_HIDDEN_DECLS      __END_EXTERN_C _Pragma("GCC visibility pop")
  249 #else
  250 #define __dso_public
  251 #define __dso_hidden
  252 #define __BEGIN_PUBLIC_DECLS    __BEGIN_EXTERN_C
  253 #define __END_PUBLIC_DECLS      __END_EXTERN_C
  254 #define __BEGIN_HIDDEN_DECLS    __BEGIN_EXTERN_C
  255 #define __END_HIDDEN_DECLS      __END_EXTERN_C
  256 #endif
  257 
  258 #define __BEGIN_DECLS   __BEGIN_EXTERN_C
  259 #define __END_DECLS     __END_EXTERN_C
  260 
  261 /*
  262  * "The nice thing about standards is that there are so many to choose from."
  263  * There are a number of "feature test macros" specified by (different)
  264  * standards that determine which interfaces and types the header files
  265  * should expose.
  266  *
  267  * Because of inconsistencies in these macros, we define our own
  268  * set in the private name space that end in _VISIBLE.  These are
  269  * always defined and so headers can test their values easily.
  270  * Things can get tricky when multiple feature macros are defined.
  271  * We try to take the union of all the features requested.
  272  *
  273  * The following macros are guaranteed to have a value after cdefs.h
  274  * has been included:
  275  *      __POSIX_VISIBLE
  276  *      __XPG_VISIBLE
  277  *      __ISO_C_VISIBLE
  278  *      __BSD_VISIBLE
  279  */
  280 
  281 /*
  282  * X/Open Portability Guides and Single Unix Specifications.
  283  * _XOPEN_SOURCE                                XPG3
  284  * _XOPEN_SOURCE && _XOPEN_VERSION = 4          XPG4
  285  * _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED = 1  XPG4v2
  286  * _XOPEN_SOURCE == 500                         XPG5
  287  * _XOPEN_SOURCE == 520                         XPG5v2
  288  * _XOPEN_SOURCE == 600                         POSIX 1003.1-2001 with XSI
  289  * _XOPEN_SOURCE == 700                         POSIX 1003.1-2008 with XSI
  290  *
  291  * The XPG spec implies a specific value for _POSIX_C_SOURCE.
  292  */
  293 #ifdef _XOPEN_SOURCE
  294 # if (_XOPEN_SOURCE - 0 >= 700)
  295 #  define __XPG_VISIBLE         700
  296 #  undef _POSIX_C_SOURCE
  297 #  define _POSIX_C_SOURCE       200809L
  298 # elif (_XOPEN_SOURCE - 0 >= 600)
  299 #  define __XPG_VISIBLE         600
  300 #  undef _POSIX_C_SOURCE
  301 #  define _POSIX_C_SOURCE       200112L
  302 # elif (_XOPEN_SOURCE - 0 >= 520)
  303 #  define __XPG_VISIBLE         520
  304 #  undef _POSIX_C_SOURCE
  305 #  define _POSIX_C_SOURCE       199506L
  306 # elif (_XOPEN_SOURCE - 0 >= 500)
  307 #  define __XPG_VISIBLE         500
  308 #  undef _POSIX_C_SOURCE
  309 #  define _POSIX_C_SOURCE       199506L
  310 # elif (_XOPEN_SOURCE_EXTENDED - 0 == 1)
  311 #  define __XPG_VISIBLE         420
  312 # elif (_XOPEN_VERSION - 0 >= 4)
  313 #  define __XPG_VISIBLE         400
  314 # else
  315 #  define __XPG_VISIBLE         300
  316 # endif
  317 #endif
  318 
  319 /*
  320  * POSIX macros, these checks must follow the XOPEN ones above.
  321  *
  322  * _POSIX_SOURCE == 1           1003.1-1988 (superseded by _POSIX_C_SOURCE)
  323  * _POSIX_C_SOURCE == 1         1003.1-1990
  324  * _POSIX_C_SOURCE == 2         1003.2-1992
  325  * _POSIX_C_SOURCE == 199309L   1003.1b-1993
  326  * _POSIX_C_SOURCE == 199506L   1003.1c-1995, 1003.1i-1995,
  327  *                              and the omnibus ISO/IEC 9945-1:1996
  328  * _POSIX_C_SOURCE == 200112L   1003.1-2001
  329  * _POSIX_C_SOURCE == 200809L   1003.1-2008
  330  *
  331  * The POSIX spec implies a specific value for __ISO_C_VISIBLE, though
  332  * this may be overridden by the _ISOC99_SOURCE macro later.
  333  */
  334 #ifdef _POSIX_C_SOURCE
  335 # if (_POSIX_C_SOURCE - 0 >= 200809)
  336 #  define __POSIX_VISIBLE       200809
  337 #  define __ISO_C_VISIBLE       1999
  338 # elif (_POSIX_C_SOURCE - 0 >= 200112)
  339 #  define __POSIX_VISIBLE       200112
  340 #  define __ISO_C_VISIBLE       1999
  341 # elif (_POSIX_C_SOURCE - 0 >= 199506)
  342 #  define __POSIX_VISIBLE       199506
  343 #  define __ISO_C_VISIBLE       1990
  344 # elif (_POSIX_C_SOURCE - 0 >= 199309)
  345 #  define __POSIX_VISIBLE       199309
  346 #  define __ISO_C_VISIBLE       1990
  347 # elif (_POSIX_C_SOURCE - 0 >= 2)
  348 #  define __POSIX_VISIBLE       199209
  349 #  define __ISO_C_VISIBLE       1990
  350 # else
  351 #  define __POSIX_VISIBLE       199009
  352 #  define __ISO_C_VISIBLE       1990
  353 # endif
  354 #elif defined(_POSIX_SOURCE)
  355 # define __POSIX_VISIBLE        198808
  356 #  define __ISO_C_VISIBLE       0
  357 #endif
  358 
  359 /*
  360  * _ANSI_SOURCE means to expose ANSI C89 interfaces only.
  361  * If the user defines it in addition to one of the POSIX or XOPEN
  362  * macros, assume the POSIX/XOPEN macro(s) should take precedence.
  363  */
  364 #if defined(_ANSI_SOURCE) && !defined(__POSIX_VISIBLE) && \
  365     !defined(__XPG_VISIBLE)
  366 # define __POSIX_VISIBLE        0
  367 # define __XPG_VISIBLE          0
  368 # define __ISO_C_VISIBLE        1990
  369 #endif
  370 
  371 /*
  372  * _ISOC99_SOURCE, _ISOC11_SOURCE, __STDC_VERSION__, and __cplusplus
  373  * override any of the other macros since they are non-exclusive.
  374  */
  375 #if defined(_ISOC11_SOURCE) || \
  376     (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112) || \
  377     (defined(__cplusplus) && __cplusplus >= 201703)
  378 # undef __ISO_C_VISIBLE
  379 # define __ISO_C_VISIBLE        2011
  380 #elif defined(_ISOC99_SOURCE) || \
  381     (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901) || \
  382     (defined(__cplusplus) && __cplusplus >= 201103)
  383 # undef __ISO_C_VISIBLE
  384 # define __ISO_C_VISIBLE        1999
  385 #endif
  386 
  387 /*
  388  * Finally deal with BSD-specific interfaces that are not covered
  389  * by any standards.  We expose these when none of the POSIX or XPG
  390  * macros is defined or if the user explicitly asks for them.
  391  */
  392 #if !defined(_BSD_SOURCE) && \
  393    (defined(_ANSI_SOURCE) || defined(__XPG_VISIBLE) || defined(__POSIX_VISIBLE))
  394 # define __BSD_VISIBLE          0
  395 #endif
  396 
  397 /*
  398  * Default values.
  399  */
  400 #ifndef __XPG_VISIBLE
  401 # define __XPG_VISIBLE          700
  402 #endif
  403 #ifndef __POSIX_VISIBLE
  404 # define __POSIX_VISIBLE        200809
  405 #endif
  406 #ifndef __ISO_C_VISIBLE
  407 # define __ISO_C_VISIBLE        2011
  408 #endif
  409 #ifndef __BSD_VISIBLE
  410 # define __BSD_VISIBLE          1
  411 #endif
  412 
  413 #endif /* !_SYS_CDEFS_H_ */

Cache object: 9bc0e8419d77d0d26b3ea480ff8083e7


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