^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /* ANSI and traditional C compatibility macros
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) Copyright 1991, 1992 Free Software Foundation, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) This file is part of the GNU C Library.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) /* ANSI and traditional C compatibility macros
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) ANSI C is assumed if __STDC__ is #defined.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) Macro ANSI C definition Traditional C definition
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) ----- ---- - ---------- ----------- - ----------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) PTR `void *' `char *'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) LONG_DOUBLE `long double' `double'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) VOLATILE `volatile' `'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) SIGNED `signed' `'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) PTRCONST `void *const' `char *'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) ANSI_PROTOTYPES 1 not defined
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) CONST is also defined, but is obsolete. Just use const.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) DEFUN (name, arglist, args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) Defines function NAME.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) ARGLIST lists the arguments, separated by commas and enclosed in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) parentheses. ARGLIST becomes the argument list in traditional C.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) ARGS list the arguments with their types. It becomes a prototype in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) ANSI C, and the type declarations in traditional C. Arguments should
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) be separated with `AND'. For functions with a variable number of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) arguments, the last thing listed should be `DOTS'.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) DEFUN_VOID (name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) Defines a function NAME, which takes no arguments.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) obsolete -- EXFUN (name, (prototype)) -- obsolete.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) Replaced by PARAMS. Do not use; will disappear someday soon.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) Was used in external function declarations.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) In ANSI C it is `NAME PROTOTYPE' (so PROTOTYPE should be enclosed in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) parentheses). In traditional C it is `NAME()'.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) For a function that takes no arguments, PROTOTYPE should be `(void)'.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) PARAMS ((args))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) We could use the EXFUN macro to handle prototype declarations, but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) the name is misleading and the result is ugly. So we just define a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) simple macro to handle the parameter lists, as in:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) static int foo PARAMS ((int, char));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) This produces: `static int foo();' or `static int foo (int, char);'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) EXFUN would have done it like this:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) static int EXFUN (foo, (int, char));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) but the function is not external...and it's hard to visually parse
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) the function name out of the mess. EXFUN should be considered
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) obsolete; new code should be written to use PARAMS.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) For example:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) extern int printf PARAMS ((CONST char *format DOTS));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) int DEFUN(fprintf, (stream, format),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) FILE *stream AND CONST char *format DOTS) { ... }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) void DEFUN_VOID(abort) { ... }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) #ifndef _ANSIDECL_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) #define _ANSIDECL_H 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) /* Every source file includes this file,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) so they will all get the switch for lint. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) /* LINTLIBRARY */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) #if defined (__STDC__) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) || defined(WIN32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) /* All known AIX compilers implement these things (but don't always
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) define __STDC__). The RISC/OS MIPS compiler defines these things
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) in SVR4 mode, but does not define __STDC__. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) #define PTR void *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) #define PTRCONST void *CONST
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) #define LONG_DOUBLE long double
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) #define AND ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) #define NOARGS void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) #define CONST const
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) #define VOLATILE volatile
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) #define SIGNED signed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) #define DOTS , ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) #define EXFUN(name, proto) name proto
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) #define DEFUN(name, arglist, args) name(args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) #define DEFUN_VOID(name) name(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) #define PROTO(type, name, arglist) type name arglist
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) #define PARAMS(paramlist) paramlist
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) #define ANSI_PROTOTYPES 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) #else /* Not ANSI C. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) #define PTR char *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) #define PTRCONST PTR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) #define LONG_DOUBLE double
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) #define AND ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) #define NOARGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) #define CONST
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) #ifndef const /* some systems define it in header files for non-ansi mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) #define const
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) #define VOLATILE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) #define SIGNED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) #define DOTS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) #define EXFUN(name, proto) name()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) #define DEFUN(name, arglist, args) name arglist args;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) #define DEFUN_VOID(name) name()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) #define PROTO(type, name, arglist) type name ()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) #define PARAMS(paramlist) ()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) #endif /* ANSI C. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) #endif /* ansidecl.h */