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/cpputil.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  * Portions Copyright (c) 2011, Aggelos Economopoulos
    3  *
    4  * Redistribution and use in source and binary forms, with or without
    5  * modification, are permitted provided that the following conditions
    6  * are met:
    7  *
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer.
   10  * 2. Redistributions in binary form must reproduce the above copyright
   11  *    notice, this list of conditions and the following disclaimer in
   12  *    the documentation and/or other materials provided with the
   13  *    distribution.
   14  * 3. Neither the name of The DragonFly Project nor the names of its
   15  *    contributors may be used to endorse or promote products derived
   16  *    from this software without specific, prior written permission.
   17  *
   18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   19  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
   21  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
   22  * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
   23  * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
   24  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   25  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
   26  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   27  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   28  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   29  * SUCH DAMAGE.
   30  */
   31 
   32 #ifndef _SYS_CPPUTIL_H_
   33 #define _SYS_CPPUTIL_H_
   34 
   35 #include <sys/cdefs.h>
   36 /*
   37  * This file includes macros that abuse the preprocessor --
   38  * we don't want to have to parse these except when compiling
   39  * the files that actually use them.
   40  */
   41 
   42 /*
   43  * Returns the number of args in __VA_ARGS__.
   44  * Note: returns 1 if __VA_ARGS__ is empty!
   45  * Taken from the Boost library.
   46  */
   47 
   48 #define VA_NARGS(...) __VA_ARGS_SIZE(__VA_ARGS__, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1,)
   49 
   50 #define __VA_ARGS_SIZE(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63, size, ...) size
   51 
   52 /*
   53  * Generate a struction declaration using the arguments passed in.
   54  * E.g. __GENSTRUCT(mystruct, int a, char *b); expands to
   55  * struct mystruct {
   56  *      int a;
   57  *      char *b;
   58  * };
   59  */
   60 
   61 #define __GENSTRUCT(tag, args...)\
   62         __CONCAT(__GENSTRUCT,VA_NARGS(args))(tag, args)
   63 
   64 
   65 #define __GENSTRUCT1(tag, arg1) struct tag {    \
   66         arg1;   \
   67         }
   68 #define __GENSTRUCT2(tag, arg1, arg2)   struct tag {    \
   69         arg1;   \
   70         arg2;   \
   71         }
   72 #define __GENSTRUCT3(tag, arg1, arg2, arg3)     struct tag {    \
   73         arg1;   \
   74         arg2;   \
   75         arg3;   \
   76         }
   77 #define __GENSTRUCT4(tag, arg1, arg2, arg3, arg4)       struct tag {    \
   78         arg1;   \
   79         arg2;   \
   80         arg3;   \
   81         arg4;   \
   82         }
   83 #define __GENSTRUCT5(tag, arg1, arg2, arg3, arg4, arg5) struct tag {    \
   84         arg1;   \
   85         arg2;   \
   86         arg3;   \
   87         arg4;   \
   88         arg5;   \
   89         }
   90 #define __GENSTRUCT6(tag, arg1, arg2, arg3, arg4, arg5, arg6)   struct tag {    \
   91         arg1;   \
   92         arg2;   \
   93         arg3;   \
   94         arg4;   \
   95         arg5;   \
   96         arg6;   \
   97         }
   98 #define __GENSTRUCT7(tag, arg1, arg2, arg3, arg4, arg5, arg6, arg7)     struct tag {    \
   99         arg1;   \
  100         arg2;   \
  101         arg3;   \
  102         arg4;   \
  103         arg5;   \
  104         arg6;   \
  105         arg7;   \
  106         }
  107 #define __GENSTRUCT8(tag, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)       struct tag {    \
  108         arg1;   \
  109         arg2;   \
  110         arg3;   \
  111         arg4;   \
  112         arg5;   \
  113         arg6;   \
  114         arg7;   \
  115         arg8;   \
  116         }
  117 #define __GENSTRUCT9(tag, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) struct tag {    \
  118         arg1;   \
  119         arg2;   \
  120         arg3;   \
  121         arg4;   \
  122         arg5;   \
  123         arg6;   \
  124         arg7;   \
  125         arg8;   \
  126         arg9;   \
  127         }
  128 #define __GENSTRUCT10(tag, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) struct tag {    \
  129         arg1;   \
  130         arg2;   \
  131         arg3;   \
  132         arg4;   \
  133         arg5;   \
  134         arg6;   \
  135         arg7;   \
  136         arg8;   \
  137         arg9;   \
  138         arg10;  \
  139         }
  140 #define __GENSTRUCT11(tag, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11)  struct tag {    \
  141         arg1;   \
  142         arg2;   \
  143         arg3;   \
  144         arg4;   \
  145         arg5;   \
  146         arg6;   \
  147         arg7;   \
  148         arg8;   \
  149         arg9;   \
  150         arg10;  \
  151         arg11;  \
  152         }
  153 #define __GENSTRUCT12(tag, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12)   struct tag {    \
  154         arg1;   \
  155         arg2;   \
  156         arg3;   \
  157         arg4;   \
  158         arg5;   \
  159         arg6;   \
  160         arg7;   \
  161         arg8;   \
  162         arg9;   \
  163         arg10;  \
  164         arg11;  \
  165         arg12;  \
  166         }
  167 #define __GENSTRUCT13(tag, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13)    struct tag {    \
  168         arg1;   \
  169         arg2;   \
  170         arg3;   \
  171         arg4;   \
  172         arg5;   \
  173         arg6;   \
  174         arg7;   \
  175         arg8;   \
  176         arg9;   \
  177         arg10;  \
  178         arg11;  \
  179         arg12;  \
  180         arg13;  \
  181         }
  182 #define __GENSTRUCT14(tag, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14)     struct tag {    \
  183         arg1;   \
  184         arg2;   \
  185         arg3;   \
  186         arg4;   \
  187         arg5;   \
  188         arg6;   \
  189         arg7;   \
  190         arg8;   \
  191         arg9;   \
  192         arg10;  \
  193         arg11;  \
  194         arg12;  \
  195         arg13;  \
  196         arg14;  \
  197         }
  198 #define __GENSTRUCT15(tag, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15)      struct tag {  \
  199         arg1;   \
  200         arg2;   \
  201         arg3;   \
  202         arg4;   \
  203         arg5;   \
  204         arg6;   \
  205         arg7;   \
  206         arg8;   \
  207         arg9;   \
  208         arg10;  \
  209         arg11;  \
  210         arg12;  \
  211         arg13;  \
  212         arg14;  \
  213         arg15;  \
  214         }
  215 #define __GENSTRUCT16(tag, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16)       struct tag {   \
  216         arg1;   \
  217         arg2;   \
  218         arg3;   \
  219         arg4;   \
  220         arg5;   \
  221         arg6;   \
  222         arg7;   \
  223         arg8;   \
  224         arg9;   \
  225         arg10;  \
  226         arg11;  \
  227         arg12;  \
  228         arg13;  \
  229         arg14;  \
  230         arg15;  \
  231         arg16;  \
  232         }
  233 #define __GENSTRUCT17(tag, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17)      struct tag {     \
  234         arg1;   \
  235         arg2;   \
  236         arg3;   \
  237         arg4;   \
  238         arg5;   \
  239         arg6;   \
  240         arg7;   \
  241         arg8;   \
  242         arg9;   \
  243         arg10;  \
  244         arg11;  \
  245         arg12;  \
  246         arg13;  \
  247         arg14;  \
  248         arg15;  \
  249         arg16;  \
  250         arg17;  \
  251         }
  252 #define __GENSTRUCT18(tag, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18)struct tag {    \
  253         arg1;   \
  254         arg2;   \
  255         arg3;   \
  256         arg4;   \
  257         arg5;   \
  258         arg6;   \
  259         arg7;   \
  260         arg8;   \
  261         arg9;   \
  262         arg10;  \
  263         arg11;  \
  264         arg12;  \
  265         arg13;  \
  266         arg14;  \
  267         arg15;  \
  268         arg16;  \
  269         arg17;  \
  270         arg18;  \
  271         }
  272 #define __GENSTRUCT19(tag, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19) struct tag {    \
  273         arg1;   \
  274         arg2;   \
  275         arg3;   \
  276         arg4;   \
  277         arg5;   \
  278         arg6;   \
  279         arg7;   \
  280         arg8;   \
  281         arg9;   \
  282         arg10;  \
  283         arg11;  \
  284         arg12;  \
  285         arg13;  \
  286         arg14;  \
  287         arg15;  \
  288         arg16;  \
  289         arg17;  \
  290         arg18;  \
  291         arg19;  \
  292         }
  293 #endif  /* _SYS_CPPUTIL_H_ */

Cache object: cd033e5333aac6e2c049dbd575e245e3


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