18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* ANSI and traditional C compatibility macros 38c2ecf20Sopenharmony_ci Copyright 1991, 1992 Free Software Foundation, Inc. 48c2ecf20Sopenharmony_ci This file is part of the GNU C Library. 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci/* ANSI and traditional C compatibility macros 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci ANSI C is assumed if __STDC__ is #defined. 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci Macro ANSI C definition Traditional C definition 138c2ecf20Sopenharmony_ci ----- ---- - ---------- ----------- - ---------- 148c2ecf20Sopenharmony_ci PTR `void *' `char *' 158c2ecf20Sopenharmony_ci LONG_DOUBLE `long double' `double' 168c2ecf20Sopenharmony_ci VOLATILE `volatile' `' 178c2ecf20Sopenharmony_ci SIGNED `signed' `' 188c2ecf20Sopenharmony_ci PTRCONST `void *const' `char *' 198c2ecf20Sopenharmony_ci ANSI_PROTOTYPES 1 not defined 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci CONST is also defined, but is obsolete. Just use const. 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci DEFUN (name, arglist, args) 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci Defines function NAME. 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci ARGLIST lists the arguments, separated by commas and enclosed in 288c2ecf20Sopenharmony_ci parentheses. ARGLIST becomes the argument list in traditional C. 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci ARGS list the arguments with their types. It becomes a prototype in 318c2ecf20Sopenharmony_ci ANSI C, and the type declarations in traditional C. Arguments should 328c2ecf20Sopenharmony_ci be separated with `AND'. For functions with a variable number of 338c2ecf20Sopenharmony_ci arguments, the last thing listed should be `DOTS'. 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci DEFUN_VOID (name) 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci Defines a function NAME, which takes no arguments. 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci obsolete -- EXFUN (name, (prototype)) -- obsolete. 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci Replaced by PARAMS. Do not use; will disappear someday soon. 428c2ecf20Sopenharmony_ci Was used in external function declarations. 438c2ecf20Sopenharmony_ci In ANSI C it is `NAME PROTOTYPE' (so PROTOTYPE should be enclosed in 448c2ecf20Sopenharmony_ci parentheses). In traditional C it is `NAME()'. 458c2ecf20Sopenharmony_ci For a function that takes no arguments, PROTOTYPE should be `(void)'. 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci PARAMS ((args)) 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ci We could use the EXFUN macro to handle prototype declarations, but 508c2ecf20Sopenharmony_ci the name is misleading and the result is ugly. So we just define a 518c2ecf20Sopenharmony_ci simple macro to handle the parameter lists, as in: 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci static int foo PARAMS ((int, char)); 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci This produces: `static int foo();' or `static int foo (int, char);' 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci EXFUN would have done it like this: 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci static int EXFUN (foo, (int, char)); 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ci but the function is not external...and it's hard to visually parse 628c2ecf20Sopenharmony_ci the function name out of the mess. EXFUN should be considered 638c2ecf20Sopenharmony_ci obsolete; new code should be written to use PARAMS. 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci For example: 668c2ecf20Sopenharmony_ci extern int printf PARAMS ((CONST char *format DOTS)); 678c2ecf20Sopenharmony_ci int DEFUN(fprintf, (stream, format), 688c2ecf20Sopenharmony_ci FILE *stream AND CONST char *format DOTS) { ... } 698c2ecf20Sopenharmony_ci void DEFUN_VOID(abort) { ... } 708c2ecf20Sopenharmony_ci*/ 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci#ifndef _ANSIDECL_H 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci#define _ANSIDECL_H 1 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci/* Every source file includes this file, 788c2ecf20Sopenharmony_ci so they will all get the switch for lint. */ 798c2ecf20Sopenharmony_ci/* LINTLIBRARY */ 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ci#if defined (__STDC__) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) || defined(WIN32) 838c2ecf20Sopenharmony_ci/* All known AIX compilers implement these things (but don't always 848c2ecf20Sopenharmony_ci define __STDC__). The RISC/OS MIPS compiler defines these things 858c2ecf20Sopenharmony_ci in SVR4 mode, but does not define __STDC__. */ 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci#define PTR void * 888c2ecf20Sopenharmony_ci#define PTRCONST void *CONST 898c2ecf20Sopenharmony_ci#define LONG_DOUBLE long double 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci#define AND , 928c2ecf20Sopenharmony_ci#define NOARGS void 938c2ecf20Sopenharmony_ci#define CONST const 948c2ecf20Sopenharmony_ci#define VOLATILE volatile 958c2ecf20Sopenharmony_ci#define SIGNED signed 968c2ecf20Sopenharmony_ci#define DOTS , ... 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ci#define EXFUN(name, proto) name proto 998c2ecf20Sopenharmony_ci#define DEFUN(name, arglist, args) name(args) 1008c2ecf20Sopenharmony_ci#define DEFUN_VOID(name) name(void) 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci#define PROTO(type, name, arglist) type name arglist 1038c2ecf20Sopenharmony_ci#define PARAMS(paramlist) paramlist 1048c2ecf20Sopenharmony_ci#define ANSI_PROTOTYPES 1 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ci#else /* Not ANSI C. */ 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_ci#define PTR char * 1098c2ecf20Sopenharmony_ci#define PTRCONST PTR 1108c2ecf20Sopenharmony_ci#define LONG_DOUBLE double 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_ci#define AND ; 1138c2ecf20Sopenharmony_ci#define NOARGS 1148c2ecf20Sopenharmony_ci#define CONST 1158c2ecf20Sopenharmony_ci#ifndef const /* some systems define it in header files for non-ansi mode */ 1168c2ecf20Sopenharmony_ci#define const 1178c2ecf20Sopenharmony_ci#endif 1188c2ecf20Sopenharmony_ci#define VOLATILE 1198c2ecf20Sopenharmony_ci#define SIGNED 1208c2ecf20Sopenharmony_ci#define DOTS 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_ci#define EXFUN(name, proto) name() 1238c2ecf20Sopenharmony_ci#define DEFUN(name, arglist, args) name arglist args; 1248c2ecf20Sopenharmony_ci#define DEFUN_VOID(name) name() 1258c2ecf20Sopenharmony_ci#define PROTO(type, name, arglist) type name () 1268c2ecf20Sopenharmony_ci#define PARAMS(paramlist) () 1278c2ecf20Sopenharmony_ci 1288c2ecf20Sopenharmony_ci#endif /* ANSI C. */ 1298c2ecf20Sopenharmony_ci 1308c2ecf20Sopenharmony_ci#endif /* ansidecl.h */ 131