Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /* ANSI and traditional C compatibility macros
0003    Copyright 1991, 1992 Free Software Foundation, Inc.
0004    This file is part of the GNU C Library.
0005 
0006  */
0007 
0008 /* ANSI and traditional C compatibility macros
0009 
0010    ANSI C is assumed if __STDC__ is #defined.
0011 
0012    Macro    ANSI C definition   Traditional C definition
0013    -----    ---- - ----------   ----------- - ----------
0014    PTR      `void *'        `char *'
0015    LONG_DOUBLE  `long double'       `double'
0016    VOLATILE `volatile'      `'
0017    SIGNED   `signed'        `'
0018    PTRCONST `void *const'       `char *'
0019    ANSI_PROTOTYPES  1           not defined
0020 
0021    CONST is also defined, but is obsolete.  Just use const.
0022 
0023    DEFUN (name, arglist, args)
0024 
0025     Defines function NAME.
0026 
0027     ARGLIST lists the arguments, separated by commas and enclosed in
0028     parentheses.  ARGLIST becomes the argument list in traditional C.
0029 
0030     ARGS list the arguments with their types.  It becomes a prototype in
0031     ANSI C, and the type declarations in traditional C.  Arguments should
0032     be separated with `AND'.  For functions with a variable number of
0033     arguments, the last thing listed should be `DOTS'.
0034 
0035    DEFUN_VOID (name)
0036 
0037     Defines a function NAME, which takes no arguments.
0038 
0039    obsolete --     EXFUN (name, (prototype))    -- obsolete.
0040 
0041     Replaced by PARAMS.  Do not use; will disappear someday soon.
0042     Was used in external function declarations.
0043     In ANSI C it is `NAME PROTOTYPE' (so PROTOTYPE should be enclosed in
0044     parentheses).  In traditional C it is `NAME()'.
0045     For a function that takes no arguments, PROTOTYPE should be `(void)'.
0046 
0047     PARAMS ((args))
0048 
0049     We could use the EXFUN macro to handle prototype declarations, but
0050     the name is misleading and the result is ugly.  So we just define a
0051     simple macro to handle the parameter lists, as in:
0052 
0053           static int foo PARAMS ((int, char));
0054 
0055     This produces:  `static int foo();' or `static int foo (int, char);'
0056 
0057     EXFUN would have done it like this:
0058 
0059           static int EXFUN (foo, (int, char));
0060 
0061     but the function is not external...and it's hard to visually parse
0062     the function name out of the mess.   EXFUN should be considered
0063     obsolete; new code should be written to use PARAMS.
0064 
0065     For example:
0066     extern int printf PARAMS ((CONST char *format DOTS));
0067     int DEFUN(fprintf, (stream, format),
0068           FILE *stream AND CONST char *format DOTS) { ... }
0069     void DEFUN_VOID(abort) { ... }
0070 */
0071 
0072 #ifndef _ANSIDECL_H
0073 
0074 #define _ANSIDECL_H 1
0075 
0076 
0077 /* Every source file includes this file,
0078    so they will all get the switch for lint.  */
0079 /* LINTLIBRARY */
0080 
0081 
0082 #if defined (__STDC__) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) || defined(WIN32)
0083 /* All known AIX compilers implement these things (but don't always
0084    define __STDC__).  The RISC/OS MIPS compiler defines these things
0085    in SVR4 mode, but does not define __STDC__.  */
0086 
0087 #define PTR     void *
0088 #define PTRCONST    void *CONST
0089 #define LONG_DOUBLE long double
0090 
0091 #define AND     ,
0092 #define NOARGS      void
0093 #define CONST       const
0094 #define VOLATILE    volatile
0095 #define SIGNED      signed
0096 #define DOTS        , ...
0097 
0098 #define EXFUN(name, proto)      name proto
0099 #define DEFUN(name, arglist, args)  name(args)
0100 #define DEFUN_VOID(name)        name(void)
0101 
0102 #define PROTO(type, name, arglist)  type name arglist
0103 #define PARAMS(paramlist)       paramlist
0104 #define ANSI_PROTOTYPES         1
0105 
0106 #else   /* Not ANSI C.  */
0107 
0108 #define PTR     char *
0109 #define PTRCONST    PTR
0110 #define LONG_DOUBLE double
0111 
0112 #define AND     ;
0113 #define NOARGS
0114 #define CONST
0115 #ifndef const /* some systems define it in header files for non-ansi mode */
0116 #define const
0117 #endif
0118 #define VOLATILE
0119 #define SIGNED
0120 #define DOTS
0121 
0122 #define EXFUN(name, proto)      name()
0123 #define DEFUN(name, arglist, args)  name arglist args;
0124 #define DEFUN_VOID(name)        name()
0125 #define PROTO(type, name, arglist) type name ()
0126 #define PARAMS(paramlist)       ()
0127 
0128 #endif  /* ANSI C.  */
0129 
0130 #endif  /* ansidecl.h   */