Home | History | Annotate | Line # | Download | only in include
ansidecl.h revision 1.1.1.2
      1      1.1  mrg /* ANSI and traditional C compatability macros
      2      1.1  mrg    Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
      3      1.1  mrg    2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010
      4      1.1  mrg    Free Software Foundation, Inc.
      5      1.1  mrg    This file is part of the GNU C Library.
      6      1.1  mrg 
      7      1.1  mrg This program is free software; you can redistribute it and/or modify
      8      1.1  mrg it under the terms of the GNU General Public License as published by
      9      1.1  mrg the Free Software Foundation; either version 2 of the License, or
     10      1.1  mrg (at your option) any later version.
     11      1.1  mrg 
     12      1.1  mrg This program is distributed in the hope that it will be useful,
     13      1.1  mrg but WITHOUT ANY WARRANTY; without even the implied warranty of
     14      1.1  mrg MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15      1.1  mrg GNU General Public License for more details.
     16      1.1  mrg 
     17      1.1  mrg You should have received a copy of the GNU General Public License
     18      1.1  mrg along with this program; if not, write to the Free Software
     19      1.1  mrg Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
     20      1.1  mrg 
     21      1.1  mrg /* ANSI and traditional C compatibility macros
     22      1.1  mrg 
     23      1.1  mrg    ANSI C is assumed if __STDC__ is #defined.
     24      1.1  mrg 
     25      1.1  mrg    Macro		ANSI C definition	Traditional C definition
     26      1.1  mrg    -----		---- - ----------	----------- - ----------
     27      1.1  mrg    ANSI_PROTOTYPES	1			not defined
     28      1.1  mrg    PTR			`void *'		`char *'
     29      1.1  mrg    PTRCONST		`void *const'		`char *'
     30      1.1  mrg    LONG_DOUBLE		`long double'		`double'
     31      1.1  mrg    const		not defined		`'
     32      1.1  mrg    volatile		not defined		`'
     33      1.1  mrg    signed		not defined		`'
     34      1.1  mrg    VA_START(ap, var)	va_start(ap, var)	va_start(ap)
     35      1.1  mrg 
     36      1.1  mrg    Note that it is safe to write "void foo();" indicating a function
     37      1.1  mrg    with no return value, in all K+R compilers we have been able to test.
     38      1.1  mrg 
     39      1.1  mrg    For declaring functions with prototypes, we also provide these:
     40      1.1  mrg 
     41      1.1  mrg    PARAMS ((prototype))
     42      1.1  mrg    -- for functions which take a fixed number of arguments.  Use this
     43      1.1  mrg    when declaring the function.  When defining the function, write a
     44      1.1  mrg    K+R style argument list.  For example:
     45      1.1  mrg 
     46      1.1  mrg 	char *strcpy PARAMS ((char *dest, char *source));
     47      1.1  mrg 	...
     48      1.1  mrg 	char *
     49      1.1  mrg 	strcpy (dest, source)
     50      1.1  mrg 	     char *dest;
     51      1.1  mrg 	     char *source;
     52      1.1  mrg 	{ ... }
     53      1.1  mrg 
     54      1.1  mrg 
     55      1.1  mrg    VPARAMS ((prototype, ...))
     56      1.1  mrg    -- for functions which take a variable number of arguments.  Use
     57      1.1  mrg    PARAMS to declare the function, VPARAMS to define it.  For example:
     58      1.1  mrg 
     59      1.1  mrg 	int printf PARAMS ((const char *format, ...));
     60      1.1  mrg 	...
     61      1.1  mrg 	int
     62      1.1  mrg 	printf VPARAMS ((const char *format, ...))
     63      1.1  mrg 	{
     64      1.1  mrg 	   ...
     65      1.1  mrg 	}
     66      1.1  mrg 
     67      1.1  mrg    For writing functions which take variable numbers of arguments, we
     68      1.1  mrg    also provide the VA_OPEN, VA_CLOSE, and VA_FIXEDARG macros.  These
     69      1.1  mrg    hide the differences between K+R <varargs.h> and C89 <stdarg.h> more
     70      1.1  mrg    thoroughly than the simple VA_START() macro mentioned above.
     71      1.1  mrg 
     72      1.1  mrg    VA_OPEN and VA_CLOSE are used *instead of* va_start and va_end.
     73      1.1  mrg    Immediately after VA_OPEN, put a sequence of VA_FIXEDARG calls
     74      1.1  mrg    corresponding to the list of fixed arguments.  Then use va_arg
     75      1.1  mrg    normally to get the variable arguments, or pass your va_list object
     76      1.1  mrg    around.  You do not declare the va_list yourself; VA_OPEN does it
     77      1.1  mrg    for you.
     78      1.1  mrg 
     79      1.1  mrg    Here is a complete example:
     80      1.1  mrg 
     81      1.1  mrg 	int
     82      1.1  mrg 	printf VPARAMS ((const char *format, ...))
     83      1.1  mrg 	{
     84      1.1  mrg 	   int result;
     85      1.1  mrg 
     86      1.1  mrg 	   VA_OPEN (ap, format);
     87      1.1  mrg 	   VA_FIXEDARG (ap, const char *, format);
     88      1.1  mrg 
     89      1.1  mrg 	   result = vfprintf (stdout, format, ap);
     90      1.1  mrg 	   VA_CLOSE (ap);
     91      1.1  mrg 
     92      1.1  mrg 	   return result;
     93      1.1  mrg 	}
     94      1.1  mrg 
     95      1.1  mrg 
     96      1.1  mrg    You can declare variables either before or after the VA_OPEN,
     97      1.1  mrg    VA_FIXEDARG sequence.  Also, VA_OPEN and VA_CLOSE are the beginning
     98      1.1  mrg    and end of a block.  They must appear at the same nesting level,
     99      1.1  mrg    and any variables declared after VA_OPEN go out of scope at
    100      1.1  mrg    VA_CLOSE.  Unfortunately, with a K+R compiler, that includes the
    101      1.1  mrg    argument list.  You can have multiple instances of VA_OPEN/VA_CLOSE
    102      1.1  mrg    pairs in a single function in case you need to traverse the
    103      1.1  mrg    argument list more than once.
    104      1.1  mrg 
    105      1.1  mrg    For ease of writing code which uses GCC extensions but needs to be
    106      1.1  mrg    portable to other compilers, we provide the GCC_VERSION macro that
    107      1.1  mrg    simplifies testing __GNUC__ and __GNUC_MINOR__ together, and various
    108      1.1  mrg    wrappers around __attribute__.  Also, __extension__ will be #defined
    109      1.1  mrg    to nothing if it doesn't work.  See below.
    110      1.1  mrg 
    111      1.1  mrg    This header also defines a lot of obsolete macros:
    112      1.1  mrg    CONST, VOLATILE, SIGNED, PROTO, EXFUN, DEFUN, DEFUN_VOID,
    113      1.1  mrg    AND, DOTS, NOARGS.  Don't use them.  */
    114      1.1  mrg 
    115      1.1  mrg #ifndef	_ANSIDECL_H
    116      1.1  mrg #define _ANSIDECL_H	1
    117      1.1  mrg 
    118      1.1  mrg #ifdef __cplusplus
    119      1.1  mrg extern "C" {
    120      1.1  mrg #endif
    121      1.1  mrg 
    122      1.1  mrg /* Every source file includes this file,
    123      1.1  mrg    so they will all get the switch for lint.  */
    124      1.1  mrg /* LINTLIBRARY */
    125      1.1  mrg 
    126      1.1  mrg /* Using MACRO(x,y) in cpp #if conditionals does not work with some
    127      1.1  mrg    older preprocessors.  Thus we can't define something like this:
    128      1.1  mrg 
    129      1.1  mrg #define HAVE_GCC_VERSION(MAJOR, MINOR) \
    130      1.1  mrg   (__GNUC__ > (MAJOR) || (__GNUC__ == (MAJOR) && __GNUC_MINOR__ >= (MINOR)))
    131      1.1  mrg 
    132      1.1  mrg and then test "#if HAVE_GCC_VERSION(2,7)".
    133      1.1  mrg 
    134      1.1  mrg So instead we use the macro below and test it against specific values.  */
    135      1.1  mrg 
    136      1.1  mrg /* This macro simplifies testing whether we are using gcc, and if it
    137      1.1  mrg    is of a particular minimum version. (Both major & minor numbers are
    138      1.1  mrg    significant.)  This macro will evaluate to 0 if we are not using
    139      1.1  mrg    gcc at all.  */
    140      1.1  mrg #ifndef GCC_VERSION
    141      1.1  mrg #define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
    142      1.1  mrg #endif /* GCC_VERSION */
    143      1.1  mrg 
    144      1.1  mrg #if defined (__STDC__) || defined(__cplusplus) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) || defined(_WIN32)
    145      1.1  mrg /* All known AIX compilers implement these things (but don't always
    146      1.1  mrg    define __STDC__).  The RISC/OS MIPS compiler defines these things
    147      1.1  mrg    in SVR4 mode, but does not define __STDC__.  */
    148      1.1  mrg /* eraxxon (at) alumni.rice.edu: The Compaq C++ compiler, unlike many other
    149      1.1  mrg    C++ compilers, does not define __STDC__, though it acts as if this
    150      1.1  mrg    was so. (Verified versions: 5.7, 6.2, 6.3, 6.5) */
    151      1.1  mrg 
    152      1.1  mrg #define ANSI_PROTOTYPES	1
    153      1.1  mrg #define PTR		void *
    154      1.1  mrg #define PTRCONST	void *const
    155      1.1  mrg #define LONG_DOUBLE	long double
    156      1.1  mrg 
    157      1.1  mrg /* PARAMS is often defined elsewhere (e.g. by libintl.h), so wrap it in
    158      1.1  mrg    a #ifndef.  */
    159      1.1  mrg #ifndef PARAMS
    160      1.1  mrg #define PARAMS(ARGS)		ARGS
    161      1.1  mrg #endif
    162      1.1  mrg 
    163      1.1  mrg #define VPARAMS(ARGS)		ARGS
    164      1.1  mrg #define VA_START(VA_LIST, VAR)	va_start(VA_LIST, VAR)
    165      1.1  mrg 
    166      1.1  mrg /* variadic function helper macros */
    167      1.1  mrg /* "struct Qdmy" swallows the semicolon after VA_OPEN/VA_FIXEDARG's
    168      1.1  mrg    use without inhibiting further decls and without declaring an
    169      1.1  mrg    actual variable.  */
    170      1.1  mrg #define VA_OPEN(AP, VAR)	{ va_list AP; va_start(AP, VAR); { struct Qdmy
    171      1.1  mrg #define VA_CLOSE(AP)		} va_end(AP); }
    172      1.1  mrg #define VA_FIXEDARG(AP, T, N)	struct Qdmy
    173      1.1  mrg 
    174      1.1  mrg #undef const
    175      1.1  mrg #undef volatile
    176      1.1  mrg #undef signed
    177      1.1  mrg 
    178      1.1  mrg /* inline requires special treatment; it's in C99, and GCC >=2.7 supports
    179      1.1  mrg    it too, but it's not in C89.  */
    180      1.1  mrg #undef inline
    181      1.1  mrg #if __STDC_VERSION__ >= 199901L || defined(__cplusplus) || (defined(__SUNPRO_C) && defined(__C99FEATURES__))
    182      1.1  mrg /* it's a keyword */
    183      1.1  mrg #else
    184      1.1  mrg # if GCC_VERSION >= 2007
    185      1.1  mrg #  define inline __inline__   /* __inline__ prevents -pedantic warnings */
    186      1.1  mrg # else
    187      1.1  mrg #  define inline  /* nothing */
    188      1.1  mrg # endif
    189      1.1  mrg #endif
    190      1.1  mrg 
    191      1.1  mrg /* These are obsolete.  Do not use.  */
    192      1.1  mrg #ifndef IN_GCC
    193      1.1  mrg #define CONST		const
    194      1.1  mrg #define VOLATILE	volatile
    195      1.1  mrg #define SIGNED		signed
    196      1.1  mrg 
    197      1.1  mrg #define PROTO(type, name, arglist)	type name arglist
    198      1.1  mrg #define EXFUN(name, proto)		name proto
    199      1.1  mrg #define DEFUN(name, arglist, args)	name(args)
    200      1.1  mrg #define DEFUN_VOID(name)		name(void)
    201      1.1  mrg #define AND		,
    202      1.1  mrg #define DOTS		, ...
    203      1.1  mrg #define NOARGS		void
    204      1.1  mrg #endif /* ! IN_GCC */
    205      1.1  mrg 
    206      1.1  mrg #else	/* Not ANSI C.  */
    207      1.1  mrg 
    208      1.1  mrg #undef  ANSI_PROTOTYPES
    209      1.1  mrg #define PTR		char *
    210      1.1  mrg #define PTRCONST	PTR
    211      1.1  mrg #define LONG_DOUBLE	double
    212      1.1  mrg 
    213      1.1  mrg #define PARAMS(args)		()
    214      1.1  mrg #define VPARAMS(args)		(va_alist) va_dcl
    215      1.1  mrg #define VA_START(va_list, var)	va_start(va_list)
    216      1.1  mrg 
    217      1.1  mrg #define VA_OPEN(AP, VAR)		{ va_list AP; va_start(AP); { struct Qdmy
    218      1.1  mrg #define VA_CLOSE(AP)			} va_end(AP); }
    219      1.1  mrg #define VA_FIXEDARG(AP, TYPE, NAME)	TYPE NAME = va_arg(AP, TYPE)
    220      1.1  mrg 
    221      1.1  mrg /* some systems define these in header files for non-ansi mode */
    222      1.1  mrg #undef const
    223      1.1  mrg #undef volatile
    224      1.1  mrg #undef signed
    225      1.1  mrg #undef inline
    226      1.1  mrg #define const
    227      1.1  mrg #define volatile
    228      1.1  mrg #define signed
    229      1.1  mrg #define inline
    230      1.1  mrg 
    231      1.1  mrg #ifndef IN_GCC
    232      1.1  mrg #define CONST
    233      1.1  mrg #define VOLATILE
    234      1.1  mrg #define SIGNED
    235      1.1  mrg 
    236      1.1  mrg #define PROTO(type, name, arglist)	type name ()
    237      1.1  mrg #define EXFUN(name, proto)		name()
    238      1.1  mrg #define DEFUN(name, arglist, args)	name arglist args;
    239      1.1  mrg #define DEFUN_VOID(name)		name()
    240      1.1  mrg #define AND		;
    241      1.1  mrg #define DOTS
    242      1.1  mrg #define NOARGS
    243      1.1  mrg #endif /* ! IN_GCC */
    244      1.1  mrg 
    245      1.1  mrg #endif	/* ANSI C.  */
    246      1.1  mrg 
    247      1.1  mrg /* Define macros for some gcc attributes.  This permits us to use the
    248      1.1  mrg    macros freely, and know that they will come into play for the
    249      1.1  mrg    version of gcc in which they are supported.  */
    250      1.1  mrg 
    251      1.1  mrg #if (GCC_VERSION < 2007)
    252      1.1  mrg # define __attribute__(x)
    253      1.1  mrg #endif
    254      1.1  mrg 
    255      1.1  mrg /* Attribute __malloc__ on functions was valid as of gcc 2.96. */
    256      1.1  mrg #ifndef ATTRIBUTE_MALLOC
    257      1.1  mrg # if (GCC_VERSION >= 2096)
    258      1.1  mrg #  define ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
    259      1.1  mrg # else
    260      1.1  mrg #  define ATTRIBUTE_MALLOC
    261      1.1  mrg # endif /* GNUC >= 2.96 */
    262      1.1  mrg #endif /* ATTRIBUTE_MALLOC */
    263      1.1  mrg 
    264      1.1  mrg /* Attributes on labels were valid as of gcc 2.93 and g++ 4.5.  For
    265      1.1  mrg    g++ an attribute on a label must be followed by a semicolon.  */
    266      1.1  mrg #ifndef ATTRIBUTE_UNUSED_LABEL
    267      1.1  mrg # ifndef __cplusplus
    268      1.1  mrg #  if GCC_VERSION >= 2093
    269      1.1  mrg #   define ATTRIBUTE_UNUSED_LABEL ATTRIBUTE_UNUSED
    270      1.1  mrg #  else
    271      1.1  mrg #   define ATTRIBUTE_UNUSED_LABEL
    272      1.1  mrg #  endif
    273      1.1  mrg # else
    274      1.1  mrg #  if GCC_VERSION >= 4005
    275      1.1  mrg #   define ATTRIBUTE_UNUSED_LABEL ATTRIBUTE_UNUSED ;
    276      1.1  mrg #  else
    277      1.1  mrg #   define ATTRIBUTE_UNUSED_LABEL
    278      1.1  mrg #  endif
    279      1.1  mrg # endif
    280      1.1  mrg #endif
    281      1.1  mrg 
    282  1.1.1.2  mrg /* Similarly to ARG_UNUSED below.  Prior to GCC 3.4, the C++ frontend
    283  1.1.1.2  mrg    couldn't parse attributes placed after the identifier name, and now
    284  1.1.1.2  mrg    the entire compiler is built with C++.  */
    285      1.1  mrg #ifndef ATTRIBUTE_UNUSED
    286  1.1.1.2  mrg #if GCC_VERSION >= 3004
    287  1.1.1.2  mrg #  define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
    288  1.1.1.2  mrg #else
    289  1.1.1.2  mrg #define ATTRIBUTE_UNUSED
    290  1.1.1.2  mrg #endif
    291      1.1  mrg #endif /* ATTRIBUTE_UNUSED */
    292      1.1  mrg 
    293      1.1  mrg /* Before GCC 3.4, the C++ frontend couldn't parse attributes placed after the
    294      1.1  mrg    identifier name.  */
    295      1.1  mrg #if ! defined(__cplusplus) || (GCC_VERSION >= 3004)
    296      1.1  mrg # define ARG_UNUSED(NAME) NAME ATTRIBUTE_UNUSED
    297      1.1  mrg #else /* !__cplusplus || GNUC >= 3.4 */
    298      1.1  mrg # define ARG_UNUSED(NAME) NAME
    299      1.1  mrg #endif /* !__cplusplus || GNUC >= 3.4 */
    300      1.1  mrg 
    301      1.1  mrg #ifndef ATTRIBUTE_NORETURN
    302      1.1  mrg #define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
    303      1.1  mrg #endif /* ATTRIBUTE_NORETURN */
    304      1.1  mrg 
    305      1.1  mrg /* Attribute `nonnull' was valid as of gcc 3.3.  */
    306      1.1  mrg #ifndef ATTRIBUTE_NONNULL
    307      1.1  mrg # if (GCC_VERSION >= 3003)
    308      1.1  mrg #  define ATTRIBUTE_NONNULL(m) __attribute__ ((__nonnull__ (m)))
    309      1.1  mrg # else
    310      1.1  mrg #  define ATTRIBUTE_NONNULL(m)
    311      1.1  mrg # endif /* GNUC >= 3.3 */
    312      1.1  mrg #endif /* ATTRIBUTE_NONNULL */
    313      1.1  mrg 
    314      1.1  mrg /* Attribute `pure' was valid as of gcc 3.0.  */
    315      1.1  mrg #ifndef ATTRIBUTE_PURE
    316      1.1  mrg # if (GCC_VERSION >= 3000)
    317      1.1  mrg #  define ATTRIBUTE_PURE __attribute__ ((__pure__))
    318      1.1  mrg # else
    319      1.1  mrg #  define ATTRIBUTE_PURE
    320      1.1  mrg # endif /* GNUC >= 3.0 */
    321      1.1  mrg #endif /* ATTRIBUTE_PURE */
    322      1.1  mrg 
    323      1.1  mrg /* Use ATTRIBUTE_PRINTF when the format specifier must not be NULL.
    324      1.1  mrg    This was the case for the `printf' format attribute by itself
    325      1.1  mrg    before GCC 3.3, but as of 3.3 we need to add the `nonnull'
    326      1.1  mrg    attribute to retain this behavior.  */
    327      1.1  mrg #ifndef ATTRIBUTE_PRINTF
    328      1.1  mrg #define ATTRIBUTE_PRINTF(m, n) __attribute__ ((__format__ (__printf__, m, n))) ATTRIBUTE_NONNULL(m)
    329      1.1  mrg #define ATTRIBUTE_PRINTF_1 ATTRIBUTE_PRINTF(1, 2)
    330      1.1  mrg #define ATTRIBUTE_PRINTF_2 ATTRIBUTE_PRINTF(2, 3)
    331      1.1  mrg #define ATTRIBUTE_PRINTF_3 ATTRIBUTE_PRINTF(3, 4)
    332      1.1  mrg #define ATTRIBUTE_PRINTF_4 ATTRIBUTE_PRINTF(4, 5)
    333      1.1  mrg #define ATTRIBUTE_PRINTF_5 ATTRIBUTE_PRINTF(5, 6)
    334      1.1  mrg #endif /* ATTRIBUTE_PRINTF */
    335      1.1  mrg 
    336      1.1  mrg /* Use ATTRIBUTE_FPTR_PRINTF when the format attribute is to be set on
    337      1.1  mrg    a function pointer.  Format attributes were allowed on function
    338      1.1  mrg    pointers as of gcc 3.1.  */
    339      1.1  mrg #ifndef ATTRIBUTE_FPTR_PRINTF
    340      1.1  mrg # if (GCC_VERSION >= 3001)
    341      1.1  mrg #  define ATTRIBUTE_FPTR_PRINTF(m, n) ATTRIBUTE_PRINTF(m, n)
    342      1.1  mrg # else
    343      1.1  mrg #  define ATTRIBUTE_FPTR_PRINTF(m, n)
    344      1.1  mrg # endif /* GNUC >= 3.1 */
    345      1.1  mrg # define ATTRIBUTE_FPTR_PRINTF_1 ATTRIBUTE_FPTR_PRINTF(1, 2)
    346      1.1  mrg # define ATTRIBUTE_FPTR_PRINTF_2 ATTRIBUTE_FPTR_PRINTF(2, 3)
    347      1.1  mrg # define ATTRIBUTE_FPTR_PRINTF_3 ATTRIBUTE_FPTR_PRINTF(3, 4)
    348      1.1  mrg # define ATTRIBUTE_FPTR_PRINTF_4 ATTRIBUTE_FPTR_PRINTF(4, 5)
    349      1.1  mrg # define ATTRIBUTE_FPTR_PRINTF_5 ATTRIBUTE_FPTR_PRINTF(5, 6)
    350      1.1  mrg #endif /* ATTRIBUTE_FPTR_PRINTF */
    351      1.1  mrg 
    352      1.1  mrg /* Use ATTRIBUTE_NULL_PRINTF when the format specifier may be NULL.  A
    353      1.1  mrg    NULL format specifier was allowed as of gcc 3.3.  */
    354      1.1  mrg #ifndef ATTRIBUTE_NULL_PRINTF
    355      1.1  mrg # if (GCC_VERSION >= 3003)
    356      1.1  mrg #  define ATTRIBUTE_NULL_PRINTF(m, n) __attribute__ ((__format__ (__printf__, m, n)))
    357      1.1  mrg # else
    358      1.1  mrg #  define ATTRIBUTE_NULL_PRINTF(m, n)
    359      1.1  mrg # endif /* GNUC >= 3.3 */
    360      1.1  mrg # define ATTRIBUTE_NULL_PRINTF_1 ATTRIBUTE_NULL_PRINTF(1, 2)
    361      1.1  mrg # define ATTRIBUTE_NULL_PRINTF_2 ATTRIBUTE_NULL_PRINTF(2, 3)
    362      1.1  mrg # define ATTRIBUTE_NULL_PRINTF_3 ATTRIBUTE_NULL_PRINTF(3, 4)
    363      1.1  mrg # define ATTRIBUTE_NULL_PRINTF_4 ATTRIBUTE_NULL_PRINTF(4, 5)
    364      1.1  mrg # define ATTRIBUTE_NULL_PRINTF_5 ATTRIBUTE_NULL_PRINTF(5, 6)
    365      1.1  mrg #endif /* ATTRIBUTE_NULL_PRINTF */
    366      1.1  mrg 
    367      1.1  mrg /* Attribute `sentinel' was valid as of gcc 3.5.  */
    368      1.1  mrg #ifndef ATTRIBUTE_SENTINEL
    369      1.1  mrg # if (GCC_VERSION >= 3005)
    370      1.1  mrg #  define ATTRIBUTE_SENTINEL __attribute__ ((__sentinel__))
    371      1.1  mrg # else
    372      1.1  mrg #  define ATTRIBUTE_SENTINEL
    373      1.1  mrg # endif /* GNUC >= 3.5 */
    374      1.1  mrg #endif /* ATTRIBUTE_SENTINEL */
    375      1.1  mrg 
    376      1.1  mrg 
    377      1.1  mrg #ifndef ATTRIBUTE_ALIGNED_ALIGNOF
    378      1.1  mrg # if (GCC_VERSION >= 3000)
    379      1.1  mrg #  define ATTRIBUTE_ALIGNED_ALIGNOF(m) __attribute__ ((__aligned__ (__alignof__ (m))))
    380      1.1  mrg # else
    381      1.1  mrg #  define ATTRIBUTE_ALIGNED_ALIGNOF(m)
    382      1.1  mrg # endif /* GNUC >= 3.0 */
    383      1.1  mrg #endif /* ATTRIBUTE_ALIGNED_ALIGNOF */
    384      1.1  mrg 
    385      1.1  mrg /* Useful for structures whose layout must much some binary specification
    386      1.1  mrg    regardless of the alignment and padding qualities of the compiler.  */
    387      1.1  mrg #ifndef ATTRIBUTE_PACKED
    388      1.1  mrg # define ATTRIBUTE_PACKED __attribute__ ((packed))
    389      1.1  mrg #endif
    390      1.1  mrg 
    391      1.1  mrg /* Attribute `hot' and `cold' was valid as of gcc 4.3.  */
    392      1.1  mrg #ifndef ATTRIBUTE_COLD
    393      1.1  mrg # if (GCC_VERSION >= 4003)
    394      1.1  mrg #  define ATTRIBUTE_COLD __attribute__ ((__cold__))
    395      1.1  mrg # else
    396      1.1  mrg #  define ATTRIBUTE_COLD
    397      1.1  mrg # endif /* GNUC >= 4.3 */
    398      1.1  mrg #endif /* ATTRIBUTE_COLD */
    399      1.1  mrg #ifndef ATTRIBUTE_HOT
    400      1.1  mrg # if (GCC_VERSION >= 4003)
    401      1.1  mrg #  define ATTRIBUTE_HOT __attribute__ ((__hot__))
    402      1.1  mrg # else
    403      1.1  mrg #  define ATTRIBUTE_HOT
    404      1.1  mrg # endif /* GNUC >= 4.3 */
    405      1.1  mrg #endif /* ATTRIBUTE_HOT */
    406      1.1  mrg 
    407      1.1  mrg /* We use __extension__ in some places to suppress -pedantic warnings
    408      1.1  mrg    about GCC extensions.  This feature didn't work properly before
    409      1.1  mrg    gcc 2.8.  */
    410      1.1  mrg #if GCC_VERSION < 2008
    411      1.1  mrg #define __extension__
    412      1.1  mrg #endif
    413      1.1  mrg 
    414      1.1  mrg /* This is used to declare a const variable which should be visible
    415      1.1  mrg    outside of the current compilation unit.  Use it as
    416      1.1  mrg      EXPORTED_CONST int i = 1;
    417      1.1  mrg    This is because the semantics of const are different in C and C++.
    418      1.1  mrg    "extern const" is permitted in C but it looks strange, and gcc
    419      1.1  mrg    warns about it when -Wc++-compat is not used.  */
    420      1.1  mrg #ifdef __cplusplus
    421      1.1  mrg #define EXPORTED_CONST extern const
    422      1.1  mrg #else
    423      1.1  mrg #define EXPORTED_CONST const
    424      1.1  mrg #endif
    425      1.1  mrg 
    426  1.1.1.2  mrg /* Be conservative and only use enum bitfields with C++ or GCC.
    427  1.1.1.2  mrg    FIXME: provide a complete autoconf test for buggy enum bitfields.  */
    428  1.1.1.2  mrg 
    429  1.1.1.2  mrg #ifdef __cplusplus
    430  1.1.1.2  mrg #define ENUM_BITFIELD(TYPE) enum TYPE
    431  1.1.1.2  mrg #elif (GCC_VERSION > 2000)
    432  1.1.1.2  mrg #define ENUM_BITFIELD(TYPE) __extension__ enum TYPE
    433  1.1.1.2  mrg #else
    434  1.1.1.2  mrg #define ENUM_BITFIELD(TYPE) unsigned int
    435  1.1.1.2  mrg #endif
    436  1.1.1.2  mrg 
    437      1.1  mrg #ifdef __cplusplus
    438      1.1  mrg }
    439      1.1  mrg #endif
    440      1.1  mrg 
    441      1.1  mrg #endif	/* ansidecl.h	*/
    442