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-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  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 /*      $NetBSD: cdefs.h,v 1.69 2008/08/17 00:23:02 gmcgarry 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. Neither the name of the University nor the names of its contributors
   19  *    may be used to endorse or promote products derived from this software
   20  *    without specific prior written permission.
   21  *
   22  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   25  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   28  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   32  * SUCH DAMAGE.
   33  *
   34  *      @(#)cdefs.h     8.8 (Berkeley) 1/9/95
   35  */
   36 
   37 #ifndef _SYS_CDEFS_H_
   38 #define _SYS_CDEFS_H_
   39 
   40 /*
   41  * Macro to test if we're using a GNU C compiler of a specific vintage
   42  * or later, for e.g. features that appeared in a particular version
   43  * of GNU C.  Usage:
   44  *
   45  *      #if __GNUC_PREREQ__(major, minor)
   46  *      ...cool feature...
   47  *      #else
   48  *      ...delete feature...
   49  *      #endif
   50  */
   51 #ifdef __GNUC__
   52 #define __GNUC_PREREQ__(x, y)                                           \
   53         ((__GNUC__ == (x) && __GNUC_MINOR__ >= (y)) ||                  \
   54          (__GNUC__ > (x)))
   55 #else
   56 #define __GNUC_PREREQ__(x, y)   0
   57 #endif
   58 
   59 #include <machine/cdefs.h>
   60 #ifdef __ELF__
   61 #include <sys/cdefs_elf.h>
   62 #else
   63 #include <sys/cdefs_aout.h>
   64 #endif
   65 
   66 #if defined(__cplusplus)
   67 #define __BEGIN_DECLS           extern "C" {
   68 #define __END_DECLS             }
   69 #define __static_cast(x,y)      static_cast<x>(y)
   70 #else
   71 #define __BEGIN_DECLS
   72 #define __END_DECLS
   73 #define __static_cast(x,y)      (x)y
   74 #endif
   75 
   76 /*
   77  * The __CONCAT macro is used to concatenate parts of symbol names, e.g.
   78  * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo.
   79  * The __CONCAT macro is a bit tricky -- make sure you don't put spaces
   80  * in between its arguments.  __CONCAT can also concatenate double-quoted
   81  * strings produced by the __STRING macro, but this only works with ANSI C.
   82  */
   83 
   84 #define ___STRING(x)    __STRING(x)
   85 #define ___CONCAT(x,y)  __CONCAT(x,y)
   86 
   87 #if __STDC__ || defined(__cplusplus)
   88 #define __P(protos)     protos          /* full-blown ANSI C */
   89 #define __CONCAT(x,y)   x ## y
   90 #define __STRING(x)     #x
   91 
   92 #define __const         const           /* define reserved names to standard */
   93 #define __signed        signed
   94 #define __volatile      volatile
   95 #if defined(__cplusplus) || defined(__PCC__)
   96 #define __inline        inline          /* convert to C++/C99 keyword */
   97 #else
   98 #if !defined(__GNUC__) && !defined(__lint__)
   99 #define __inline                        /* delete GCC keyword */
  100 #endif /* !__GNUC__  && !__lint__ */
  101 #endif /* !__cplusplus */
  102 
  103 #else   /* !(__STDC__ || __cplusplus) */
  104 #define __P(protos)     ()              /* traditional C preprocessor */
  105 #define __CONCAT(x,y)   x/**/y
  106 #define __STRING(x)     "x"
  107 
  108 #ifndef __GNUC__
  109 #define __const                         /* delete pseudo-ANSI C keywords */
  110 #define __inline
  111 #define __signed
  112 #define __volatile
  113 #endif  /* !__GNUC__ */
  114 
  115 /*
  116  * In non-ANSI C environments, new programs will want ANSI-only C keywords
  117  * deleted from the program and old programs will want them left alone.
  118  * Programs using the ANSI C keywords const, inline etc. as normal
  119  * identifiers should define -DNO_ANSI_KEYWORDS.
  120  */
  121 #ifndef NO_ANSI_KEYWORDS
  122 #define const           __const         /* convert ANSI C keywords */
  123 #define inline          __inline
  124 #define signed          __signed
  125 #define volatile        __volatile
  126 #endif /* !NO_ANSI_KEYWORDS */
  127 #endif  /* !(__STDC__ || __cplusplus) */
  128 
  129 /*
  130  * Used for internal auditing of the NetBSD source tree.
  131  */
  132 #ifdef __AUDIT__
  133 #define __aconst        __const
  134 #else
  135 #define __aconst
  136 #endif
  137 
  138 /*
  139  * The following macro is used to remove const cast-away warnings
  140  * from gcc -Wcast-qual; it should be used with caution because it
  141  * can hide valid errors; in particular most valid uses are in
  142  * situations where the API requires it, not to cast away string
  143  * constants. We don't use *intptr_t on purpose here and we are
  144  * explicit about unsigned long so that we don't have additional
  145  * dependencies.
  146  */
  147 #define __UNCONST(a)    ((void *)(unsigned long)(const void *)(a))
  148 
  149 /*
  150  * The following macro is used to remove the volatile cast-away warnings
  151  * from gcc -Wcast-qual; as above it should be used with caution
  152  * because it can hide valid errors or warnings.  Valid uses include
  153  * making it possible to pass a volatile pointer to memset().
  154  * For the same reasons as above, we use unsigned long and not intptr_t.
  155  */
  156 #define __UNVOLATILE(a) ((void *)(unsigned long)(volatile void *)(a))
  157 
  158 /*
  159  * GCC2 provides __extension__ to suppress warnings for various GNU C
  160  * language extensions under "-ansi -pedantic".
  161  */
  162 #if !__GNUC_PREREQ__(2, 0)
  163 #define __extension__           /* delete __extension__ if non-gcc or gcc1 */
  164 #endif
  165 
  166 /*
  167  * GCC1 and some versions of GCC2 declare dead (non-returning) and
  168  * pure (no side effects) functions using "volatile" and "const";
  169  * unfortunately, these then cause warnings under "-ansi -pedantic".
  170  * GCC2 uses a new, peculiar __attribute__((attrs)) style.  All of
  171  * these work for GNU C++ (modulo a slight glitch in the C++ grammar
  172  * in the distribution version of 2.5.5).
  173  */
  174 #if !__GNUC_PREREQ__(2, 0)
  175 #define __attribute__(x)
  176 #endif
  177 
  178 #if __GNUC_PREREQ__(2, 5)
  179 #define __dead          __attribute__((__noreturn__))
  180 #elif defined(__GNUC__)
  181 #define __dead          __volatile
  182 #else
  183 #define __dead
  184 #endif
  185 
  186 #if __GNUC_PREREQ__(2, 96)
  187 #define __pure          __attribute__((__pure__))
  188 #elif defined(__GNUC__)
  189 #define __pure          __const
  190 #else
  191 #define __pure
  192 #endif
  193 
  194 #if __GNUC_PREREQ__(3, 0)
  195 #define __noinline      __attribute__((__noinline__))
  196 #else
  197 #define __noinline      /* nothing */
  198 #endif
  199 
  200 #if __GNUC_PREREQ__(2, 7)
  201 #define __unused        __attribute__((__unused__))
  202 #else
  203 #define __unused        /* delete */
  204 #endif
  205 
  206 #if __GNUC_PREREQ__(3, 1)
  207 #define __used          __attribute__((__used__))
  208 #else
  209 #define __used          __unused
  210 #endif
  211 
  212 #if __GNUC_PREREQ__(2, 7)
  213 #define __packed        __attribute__((__packed__))
  214 #define __aligned(x)    __attribute__((__aligned__(x)))
  215 #define __section(x)    __attribute__((__section__(x)))
  216 #elif defined(__PCC__)
  217 #define __packed        _Pragma("packed")
  218 #define __aligned(x)    _Pragma("aligned " #x)
  219 #define __section(x)    _Pragma("section " ## x)
  220 #elif defined(__lint__)
  221 #define __packed        /* delete */
  222 #define __aligned(x)    /* delete */
  223 #define __section(x)    /* delete */
  224 #else
  225 #define __packed        error: no __packed for this compiler
  226 #define __aligned(x)    error: no __aligned for this compiler
  227 #define __section(x)    error: no __section for this compiler
  228 #endif
  229 
  230 /*
  231  * C99 defines the restrict type qualifier keyword, which was made available
  232  * in GCC 2.92.
  233  */
  234 #if defined(__lint__)
  235 #define __restrict      /* delete __restrict when not supported */
  236 #elif __STDC_VERSION__ >= 199901L
  237 #define __restrict      restrict
  238 #elif !__GNUC_PREREQ__(2, 92)
  239 #define __restrict      /* delete __restrict when not supported */
  240 #endif
  241 
  242 /*
  243  * C99 defines __func__ predefined identifier, which was made available
  244  * in GCC 2.95.
  245  */
  246 #if !(__STDC_VERSION__ >= 199901L)
  247 #if __GNUC_PREREQ__(2, 6)
  248 #define __func__        __PRETTY_FUNCTION__
  249 #elif __GNUC_PREREQ__(2, 4)
  250 #define __func__        __FUNCTION__
  251 #else
  252 #define __func__        ""
  253 #endif
  254 #endif /* !(__STDC_VERSION__ >= 199901L) */
  255 
  256 #if defined(_KERNEL)
  257 #if defined(NO_KERNEL_RCSIDS)
  258 #undef __KERNEL_RCSID
  259 #define __KERNEL_RCSID(_n, _s)          /* nothing */
  260 #endif /* NO_KERNEL_RCSIDS */
  261 #endif /* _KERNEL */
  262 
  263 #if !defined(_STANDALONE) && !defined(_KERNEL)
  264 #if defined(__GNUC__) || defined(__PCC__)
  265 #define __RENAME(x)     ___RENAME(x)
  266 #else
  267 #ifdef __lint__
  268 #define __RENAME(x)     __symbolrename(x)
  269 #else
  270 #error "No function renaming possible"
  271 #endif /* __lint__ */
  272 #endif /* __GNUC__ */
  273 #else /* _STANDALONE || _KERNEL */
  274 #define __RENAME(x)     no renaming in kernel or standalone environment
  275 #endif
  276 
  277 /*
  278  * A barrier to stop the optimizer from moving code or assume live
  279  * register values. This is gcc specific, the version is more or less
  280  * arbitrary, might work with older compilers.
  281  */
  282 #if __GNUC_PREREQ__(2, 95)
  283 #define __insn_barrier()        __asm __volatile("":::"memory")
  284 #else
  285 #define __insn_barrier()        /* */
  286 #endif
  287 
  288 /*
  289  * GNU C version 2.96 adds explicit branch prediction so that
  290  * the CPU back-end can hint the processor and also so that
  291  * code blocks can be reordered such that the predicted path
  292  * sees a more linear flow, thus improving cache behavior, etc.
  293  *
  294  * The following two macros provide us with a way to use this
  295  * compiler feature.  Use __predict_true() if you expect the expression
  296  * to evaluate to true, and __predict_false() if you expect the
  297  * expression to evaluate to false.
  298  *
  299  * A few notes about usage:
  300  *
  301  *      * Generally, __predict_false() error condition checks (unless
  302  *        you have some _strong_ reason to do otherwise, in which case
  303  *        document it), and/or __predict_true() `no-error' condition
  304  *        checks, assuming you want to optimize for the no-error case.
  305  *
  306  *      * Other than that, if you don't know the likelihood of a test
  307  *        succeeding from empirical or other `hard' evidence, don't
  308  *        make predictions.
  309  *
  310  *      * These are meant to be used in places that are run `a lot'.
  311  *        It is wasteful to make predictions in code that is run
  312  *        seldomly (e.g. at subsystem initialization time) as the
  313  *        basic block reordering that this affects can often generate
  314  *        larger code.
  315  */
  316 #if __GNUC_PREREQ__(2, 96)
  317 #define __predict_true(exp)     __builtin_expect((exp) != 0, 1)
  318 #define __predict_false(exp)    __builtin_expect((exp) != 0, 0)
  319 #else
  320 #define __predict_true(exp)     (exp)
  321 #define __predict_false(exp)    (exp)
  322 #endif
  323 
  324 /*
  325  * Macros for manipulating "link sets".  Link sets are arrays of pointers
  326  * to objects, which are gathered up by the linker.
  327  *
  328  * Object format-specific code has provided us with the following macros:
  329  *
  330  *      __link_set_add_text(set, sym)
  331  *              Add a reference to the .text symbol `sym' to `set'.
  332  *
  333  *      __link_set_add_rodata(set, sym)
  334  *              Add a reference to the .rodata symbol `sym' to `set'.
  335  *
  336  *      __link_set_add_data(set, sym)
  337  *              Add a reference to the .data symbol `sym' to `set'.
  338  *
  339  *      __link_set_add_bss(set, sym)
  340  *              Add a reference to the .bss symbol `sym' to `set'.
  341  *
  342  *      __link_set_decl(set, ptype)
  343  *              Provide an extern declaration of the set `set', which
  344  *              contains an array of the pointer type `ptype'.  This
  345  *              macro must be used by any code which wishes to reference
  346  *              the elements of a link set.
  347  *
  348  *      __link_set_start(set)
  349  *              This points to the first slot in the link set.
  350  *
  351  *      __link_set_end(set)
  352  *              This points to the (non-existent) slot after the last
  353  *              entry in the link set.
  354  *
  355  *      __link_set_count(set)
  356  *              Count the number of entries in link set `set'.
  357  *
  358  * In addition, we provide the following macros for accessing link sets:
  359  *
  360  *      __link_set_foreach(pvar, set)
  361  *              Iterate over the link set `set'.  Because a link set is
  362  *              an array of pointers, pvar must be declared as "type **pvar",
  363  *              and the actual entry accessed as "*pvar".
  364  *
  365  *      __link_set_entry(set, idx)
  366  *              Access the link set entry at index `idx' from set `set'.
  367  */
  368 #define __link_set_foreach(pvar, set)                                   \
  369         for (pvar = __link_set_start(set); pvar < __link_set_end(set); pvar++)
  370 
  371 #define __link_set_entry(set, idx)      (__link_set_begin(set)[idx])
  372 
  373 /*
  374  * Return the number of elements in a statically-allocated array,
  375  * __x.
  376  */
  377 #define __arraycount(__x)       (sizeof(__x) / sizeof(__x[0]))
  378 
  379 /* __BIT(n): nth bit, where __BIT(0) == 0x1. */
  380 #define __BIT(__n)      \
  381         (((__n) >= NBBY * sizeof(uintmax_t)) ? 0 : ((uintmax_t)1 << (__n)))
  382 
  383 /* __BITS(m, n): bits m through n, m < n. */
  384 #define __BITS(__m, __n)        \
  385         ((__BIT(MAX((__m), (__n)) + 1) - 1) ^ (__BIT(MIN((__m), (__n))) - 1))
  386 
  387 /* find least significant bit that is set */
  388 #define __LOWEST_SET_BIT(__mask) ((((__mask) - 1) & (__mask)) ^ (__mask))
  389 
  390 #define __PRIuBIT       PRIuMAX
  391 #define __PRIuBITS      __PRIuBIT
  392 
  393 #define __PRIxBIT       PRIxMAX
  394 #define __PRIxBITS      __PRIxBIT
  395 
  396 #define __SHIFTOUT(__x, __mask) (((__x) & (__mask)) / __LOWEST_SET_BIT(__mask))
  397 #define __SHIFTIN(__x, __mask) ((__x) * __LOWEST_SET_BIT(__mask))
  398 #define __SHIFTOUT_MASK(__mask) __SHIFTOUT((__mask), (__mask))
  399 
  400 #endif /* !_SYS_CDEFS_H_ */

Cache object: af9fbcadfdf8ec5028675b5a6207650d


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