162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 262306a36Sopenharmony_ci/* ANSI and traditional C compatibility macros 362306a36Sopenharmony_ci Copyright 1991, 1992 Free Software Foundation, Inc. 462306a36Sopenharmony_ci This file is part of the GNU C Library. 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci */ 762306a36Sopenharmony_ci 862306a36Sopenharmony_ci/* ANSI and traditional C compatibility macros 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci ANSI C is assumed if __STDC__ is #defined. 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci Macro ANSI C definition Traditional C definition 1362306a36Sopenharmony_ci ----- ---- - ---------- ----------- - ---------- 1462306a36Sopenharmony_ci PTR `void *' `char *' 1562306a36Sopenharmony_ci LONG_DOUBLE `long double' `double' 1662306a36Sopenharmony_ci VOLATILE `volatile' `' 1762306a36Sopenharmony_ci SIGNED `signed' `' 1862306a36Sopenharmony_ci PTRCONST `void *const' `char *' 1962306a36Sopenharmony_ci ANSI_PROTOTYPES 1 not defined 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ci CONST is also defined, but is obsolete. Just use const. 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_ci DEFUN (name, arglist, args) 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_ci Defines function NAME. 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ci ARGLIST lists the arguments, separated by commas and enclosed in 2862306a36Sopenharmony_ci parentheses. ARGLIST becomes the argument list in traditional C. 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ci ARGS list the arguments with their types. It becomes a prototype in 3162306a36Sopenharmony_ci ANSI C, and the type declarations in traditional C. Arguments should 3262306a36Sopenharmony_ci be separated with `AND'. For functions with a variable number of 3362306a36Sopenharmony_ci arguments, the last thing listed should be `DOTS'. 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci DEFUN_VOID (name) 3662306a36Sopenharmony_ci 3762306a36Sopenharmony_ci Defines a function NAME, which takes no arguments. 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_ci obsolete -- EXFUN (name, (prototype)) -- obsolete. 4062306a36Sopenharmony_ci 4162306a36Sopenharmony_ci Replaced by PARAMS. Do not use; will disappear someday soon. 4262306a36Sopenharmony_ci Was used in external function declarations. 4362306a36Sopenharmony_ci In ANSI C it is `NAME PROTOTYPE' (so PROTOTYPE should be enclosed in 4462306a36Sopenharmony_ci parentheses). In traditional C it is `NAME()'. 4562306a36Sopenharmony_ci For a function that takes no arguments, PROTOTYPE should be `(void)'. 4662306a36Sopenharmony_ci 4762306a36Sopenharmony_ci PARAMS ((args)) 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_ci We could use the EXFUN macro to handle prototype declarations, but 5062306a36Sopenharmony_ci the name is misleading and the result is ugly. So we just define a 5162306a36Sopenharmony_ci simple macro to handle the parameter lists, as in: 5262306a36Sopenharmony_ci 5362306a36Sopenharmony_ci static int foo PARAMS ((int, char)); 5462306a36Sopenharmony_ci 5562306a36Sopenharmony_ci This produces: `static int foo();' or `static int foo (int, char);' 5662306a36Sopenharmony_ci 5762306a36Sopenharmony_ci EXFUN would have done it like this: 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_ci static int EXFUN (foo, (int, char)); 6062306a36Sopenharmony_ci 6162306a36Sopenharmony_ci but the function is not external...and it's hard to visually parse 6262306a36Sopenharmony_ci the function name out of the mess. EXFUN should be considered 6362306a36Sopenharmony_ci obsolete; new code should be written to use PARAMS. 6462306a36Sopenharmony_ci 6562306a36Sopenharmony_ci For example: 6662306a36Sopenharmony_ci extern int printf PARAMS ((CONST char *format DOTS)); 6762306a36Sopenharmony_ci int DEFUN(fprintf, (stream, format), 6862306a36Sopenharmony_ci FILE *stream AND CONST char *format DOTS) { ... } 6962306a36Sopenharmony_ci void DEFUN_VOID(abort) { ... } 7062306a36Sopenharmony_ci*/ 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ci#ifndef _ANSIDECL_H 7362306a36Sopenharmony_ci 7462306a36Sopenharmony_ci#define _ANSIDECL_H 1 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_ci 7762306a36Sopenharmony_ci/* Every source file includes this file, 7862306a36Sopenharmony_ci so they will all get the switch for lint. */ 7962306a36Sopenharmony_ci/* LINTLIBRARY */ 8062306a36Sopenharmony_ci 8162306a36Sopenharmony_ci 8262306a36Sopenharmony_ci#if defined (__STDC__) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) || defined(WIN32) 8362306a36Sopenharmony_ci/* All known AIX compilers implement these things (but don't always 8462306a36Sopenharmony_ci define __STDC__). The RISC/OS MIPS compiler defines these things 8562306a36Sopenharmony_ci in SVR4 mode, but does not define __STDC__. */ 8662306a36Sopenharmony_ci 8762306a36Sopenharmony_ci#define PTR void * 8862306a36Sopenharmony_ci#define PTRCONST void *CONST 8962306a36Sopenharmony_ci#define LONG_DOUBLE long double 9062306a36Sopenharmony_ci 9162306a36Sopenharmony_ci#define AND , 9262306a36Sopenharmony_ci#define NOARGS void 9362306a36Sopenharmony_ci#define CONST const 9462306a36Sopenharmony_ci#define VOLATILE volatile 9562306a36Sopenharmony_ci#define SIGNED signed 9662306a36Sopenharmony_ci#define DOTS , ... 9762306a36Sopenharmony_ci 9862306a36Sopenharmony_ci#define EXFUN(name, proto) name proto 9962306a36Sopenharmony_ci#define DEFUN(name, arglist, args) name(args) 10062306a36Sopenharmony_ci#define DEFUN_VOID(name) name(void) 10162306a36Sopenharmony_ci 10262306a36Sopenharmony_ci#define PROTO(type, name, arglist) type name arglist 10362306a36Sopenharmony_ci#define PARAMS(paramlist) paramlist 10462306a36Sopenharmony_ci#define ANSI_PROTOTYPES 1 10562306a36Sopenharmony_ci 10662306a36Sopenharmony_ci#else /* Not ANSI C. */ 10762306a36Sopenharmony_ci 10862306a36Sopenharmony_ci#define PTR char * 10962306a36Sopenharmony_ci#define PTRCONST PTR 11062306a36Sopenharmony_ci#define LONG_DOUBLE double 11162306a36Sopenharmony_ci 11262306a36Sopenharmony_ci#define AND ; 11362306a36Sopenharmony_ci#define NOARGS 11462306a36Sopenharmony_ci#define CONST 11562306a36Sopenharmony_ci#ifndef const /* some systems define it in header files for non-ansi mode */ 11662306a36Sopenharmony_ci#define const 11762306a36Sopenharmony_ci#endif 11862306a36Sopenharmony_ci#define VOLATILE 11962306a36Sopenharmony_ci#define SIGNED 12062306a36Sopenharmony_ci#define DOTS 12162306a36Sopenharmony_ci 12262306a36Sopenharmony_ci#define EXFUN(name, proto) name() 12362306a36Sopenharmony_ci#define DEFUN(name, arglist, args) name arglist args; 12462306a36Sopenharmony_ci#define DEFUN_VOID(name) name() 12562306a36Sopenharmony_ci#define PROTO(type, name, arglist) type name () 12662306a36Sopenharmony_ci#define PARAMS(paramlist) () 12762306a36Sopenharmony_ci 12862306a36Sopenharmony_ci#endif /* ANSI C. */ 12962306a36Sopenharmony_ci 13062306a36Sopenharmony_ci#endif /* ansidecl.h */ 131