1 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ 2 /* A substitute for ISO C99 <ctype.h>, for platforms on which it is incomplete. 3 4 Copyright (C) 2009-2020 Free Software Foundation, Inc. 5 6 This program is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 3, or (at your option) 9 any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program; if not, see <https://www.gnu.org/licenses/>. */ 18 19 /* Written by Bruno Haible. */ 20 21 /* 22 * ISO C 99 <ctype.h> for platforms on which it is incomplete. 23 * <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/ctype.h.html> 24 */ 25 26 #ifndef _GL_CTYPE_H 27 28 #if __GNUC__ >= 3 29 #pragma GCC system_header 30 #endif 31 32 33 /* Include the original <ctype.h>. */ 34 /* The include_next requires a split double-inclusion guard. */ 35 #include_next <ctype.h> 36 37 #ifndef _GL_CTYPE_H 38 #define _GL_CTYPE_H 39 40 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 41 /* C++ compatible function declaration macros. 42 Copyright (C) 2010-2020 Free Software Foundation, Inc. 43 44 This program is free software: you can redistribute it and/or modify it 45 under the terms of the GNU General Public License as published 46 by the Free Software Foundation; either version 3 of the License, or 47 (at your option) any later version. 48 49 This program is distributed in the hope that it will be useful, 50 but WITHOUT ANY WARRANTY; without even the implied warranty of 51 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 52 General Public License for more details. 53 54 You should have received a copy of the GNU General Public License 55 along with this program. If not, see <https://www.gnu.org/licenses/>. */ 56 57 #ifndef _GL_CXXDEFS_H 58 #define _GL_CXXDEFS_H 59 60 /* Begin/end the GNULIB_NAMESPACE namespace. */ 61 #if defined __cplusplus && defined GNULIB_NAMESPACE 62 # define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE { 63 # define _GL_END_NAMESPACE } 64 #else 65 # define _GL_BEGIN_NAMESPACE 66 # define _GL_END_NAMESPACE 67 #endif 68 69 /* The three most frequent use cases of these macros are: 70 71 * For providing a substitute for a function that is missing on some 72 platforms, but is declared and works fine on the platforms on which 73 it exists: 74 75 #if @GNULIB_FOO@ 76 # if !@HAVE_FOO@ 77 _GL_FUNCDECL_SYS (foo, ...); 78 # endif 79 _GL_CXXALIAS_SYS (foo, ...); 80 _GL_CXXALIASWARN (foo); 81 #elif defined GNULIB_POSIXCHECK 82 ... 83 #endif 84 85 * For providing a replacement for a function that exists on all platforms, 86 but is broken/insufficient and needs to be replaced on some platforms: 87 88 #if @GNULIB_FOO@ 89 # if @REPLACE_FOO@ 90 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 91 # undef foo 92 # define foo rpl_foo 93 # endif 94 _GL_FUNCDECL_RPL (foo, ...); 95 _GL_CXXALIAS_RPL (foo, ...); 96 # else 97 _GL_CXXALIAS_SYS (foo, ...); 98 # endif 99 _GL_CXXALIASWARN (foo); 100 #elif defined GNULIB_POSIXCHECK 101 ... 102 #endif 103 104 * For providing a replacement for a function that exists on some platforms 105 but is broken/insufficient and needs to be replaced on some of them and 106 is additionally either missing or undeclared on some other platforms: 107 108 #if @GNULIB_FOO@ 109 # if @REPLACE_FOO@ 110 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 111 # undef foo 112 # define foo rpl_foo 113 # endif 114 _GL_FUNCDECL_RPL (foo, ...); 115 _GL_CXXALIAS_RPL (foo, ...); 116 # else 117 # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@ 118 _GL_FUNCDECL_SYS (foo, ...); 119 # endif 120 _GL_CXXALIAS_SYS (foo, ...); 121 # endif 122 _GL_CXXALIASWARN (foo); 123 #elif defined GNULIB_POSIXCHECK 124 ... 125 #endif 126 */ 127 128 /* _GL_EXTERN_C declaration; 129 performs the declaration with C linkage. */ 130 #if defined __cplusplus 131 # define _GL_EXTERN_C extern "C" 132 #else 133 # define _GL_EXTERN_C extern 134 #endif 135 136 /* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes); 137 declares a replacement function, named rpl_func, with the given prototype, 138 consisting of return type, parameters, and attributes. 139 Example: 140 _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) 141 _GL_ARG_NONNULL ((1))); 142 */ 143 #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \ 144 _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes) 145 #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \ 146 _GL_EXTERN_C rettype rpl_func parameters_and_attributes 147 148 /* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes); 149 declares the system function, named func, with the given prototype, 150 consisting of return type, parameters, and attributes. 151 Example: 152 _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...) 153 _GL_ARG_NONNULL ((1))); 154 */ 155 #define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \ 156 _GL_EXTERN_C rettype func parameters_and_attributes 157 158 /* _GL_CXXALIAS_RPL (func, rettype, parameters); 159 declares a C++ alias called GNULIB_NAMESPACE::func 160 that redirects to rpl_func, if GNULIB_NAMESPACE is defined. 161 Example: 162 _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); 163 164 Wrapping rpl_func in an object with an inline conversion operator 165 avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is 166 actually used in the program. */ 167 #define _GL_CXXALIAS_RPL(func,rettype,parameters) \ 168 _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters) 169 #if defined __cplusplus && defined GNULIB_NAMESPACE 170 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ 171 namespace GNULIB_NAMESPACE \ 172 { \ 173 static const struct _gl_ ## func ## _wrapper \ 174 { \ 175 typedef rettype (*type) parameters; \ 176 \ 177 inline operator type () const \ 178 { \ 179 return ::rpl_func; \ 180 } \ 181 } func = {}; \ 182 } \ 183 _GL_EXTERN_C int _gl_cxxalias_dummy 184 #else 185 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ 186 _GL_EXTERN_C int _gl_cxxalias_dummy 187 #endif 188 189 /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters); 190 is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters); 191 except that the C function rpl_func may have a slightly different 192 declaration. A cast is used to silence the "invalid conversion" error 193 that would otherwise occur. */ 194 #if defined __cplusplus && defined GNULIB_NAMESPACE 195 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ 196 namespace GNULIB_NAMESPACE \ 197 { \ 198 static const struct _gl_ ## func ## _wrapper \ 199 { \ 200 typedef rettype (*type) parameters; \ 201 \ 202 inline operator type () const \ 203 { \ 204 return reinterpret_cast<type>(::rpl_func); \ 205 } \ 206 } func = {}; \ 207 } \ 208 _GL_EXTERN_C int _gl_cxxalias_dummy 209 #else 210 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ 211 _GL_EXTERN_C int _gl_cxxalias_dummy 212 #endif 213 214 /* _GL_CXXALIAS_SYS (func, rettype, parameters); 215 declares a C++ alias called GNULIB_NAMESPACE::func 216 that redirects to the system provided function func, if GNULIB_NAMESPACE 217 is defined. 218 Example: 219 _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); 220 221 Wrapping func in an object with an inline conversion operator 222 avoids a reference to func unless GNULIB_NAMESPACE::func is 223 actually used in the program. */ 224 #if defined __cplusplus && defined GNULIB_NAMESPACE 225 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \ 226 namespace GNULIB_NAMESPACE \ 227 { \ 228 static const struct _gl_ ## func ## _wrapper \ 229 { \ 230 typedef rettype (*type) parameters; \ 231 \ 232 inline operator type () const \ 233 { \ 234 return ::func; \ 235 } \ 236 } func = {}; \ 237 } \ 238 _GL_EXTERN_C int _gl_cxxalias_dummy 239 #else 240 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \ 241 _GL_EXTERN_C int _gl_cxxalias_dummy 242 #endif 243 244 /* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters); 245 is like _GL_CXXALIAS_SYS (func, rettype, parameters); 246 except that the C function func may have a slightly different declaration. 247 A cast is used to silence the "invalid conversion" error that would 248 otherwise occur. */ 249 #if defined __cplusplus && defined GNULIB_NAMESPACE 250 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ 251 namespace GNULIB_NAMESPACE \ 252 { \ 253 static const struct _gl_ ## func ## _wrapper \ 254 { \ 255 typedef rettype (*type) parameters; \ 256 \ 257 inline operator type () const \ 258 { \ 259 return reinterpret_cast<type>(::func); \ 260 } \ 261 } func = {}; \ 262 } \ 263 _GL_EXTERN_C int _gl_cxxalias_dummy 264 #else 265 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ 266 _GL_EXTERN_C int _gl_cxxalias_dummy 267 #endif 268 269 /* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2); 270 is like _GL_CXXALIAS_SYS (func, rettype, parameters); 271 except that the C function is picked among a set of overloaded functions, 272 namely the one with rettype2 and parameters2. Two consecutive casts 273 are used to silence the "cannot find a match" and "invalid conversion" 274 errors that would otherwise occur. */ 275 #if defined __cplusplus && defined GNULIB_NAMESPACE 276 /* The outer cast must be a reinterpret_cast. 277 The inner cast: When the function is defined as a set of overloaded 278 functions, it works as a static_cast<>, choosing the designated variant. 279 When the function is defined as a single variant, it works as a 280 reinterpret_cast<>. The parenthesized cast syntax works both ways. */ 281 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ 282 namespace GNULIB_NAMESPACE \ 283 { \ 284 static const struct _gl_ ## func ## _wrapper \ 285 { \ 286 typedef rettype (*type) parameters; \ 287 \ 288 inline operator type () const \ 289 { \ 290 return reinterpret_cast<type>((rettype2 (*) parameters2)(::func)); \ 291 } \ 292 } func = {}; \ 293 } \ 294 _GL_EXTERN_C int _gl_cxxalias_dummy 295 #else 296 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ 297 _GL_EXTERN_C int _gl_cxxalias_dummy 298 #endif 299 300 /* _GL_CXXALIASWARN (func); 301 causes a warning to be emitted when ::func is used but not when 302 GNULIB_NAMESPACE::func is used. func must be defined without overloaded 303 variants. */ 304 #if defined __cplusplus && defined GNULIB_NAMESPACE 305 # define _GL_CXXALIASWARN(func) \ 306 _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE) 307 # define _GL_CXXALIASWARN_1(func,namespace) \ 308 _GL_CXXALIASWARN_2 (func, namespace) 309 /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, 310 we enable the warning only when not optimizing. */ 311 # if !__OPTIMIZE__ 312 # define _GL_CXXALIASWARN_2(func,namespace) \ 313 _GL_WARN_ON_USE (func, \ 314 "The symbol ::" #func " refers to the system function. " \ 315 "Use " #namespace "::" #func " instead.") 316 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 317 # define _GL_CXXALIASWARN_2(func,namespace) \ 318 extern __typeof__ (func) func 319 # else 320 # define _GL_CXXALIASWARN_2(func,namespace) \ 321 _GL_EXTERN_C int _gl_cxxalias_dummy 322 # endif 323 #else 324 # define _GL_CXXALIASWARN(func) \ 325 _GL_EXTERN_C int _gl_cxxalias_dummy 326 #endif 327 328 /* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes); 329 causes a warning to be emitted when the given overloaded variant of ::func 330 is used but not when GNULIB_NAMESPACE::func is used. */ 331 #if defined __cplusplus && defined GNULIB_NAMESPACE 332 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ 333 _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \ 334 GNULIB_NAMESPACE) 335 # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \ 336 _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace) 337 /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, 338 we enable the warning only when not optimizing. */ 339 # if !__OPTIMIZE__ 340 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ 341 _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \ 342 "The symbol ::" #func " refers to the system function. " \ 343 "Use " #namespace "::" #func " instead.") 344 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 345 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ 346 extern __typeof__ (func) func 347 # else 348 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ 349 _GL_EXTERN_C int _gl_cxxalias_dummy 350 # endif 351 #else 352 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ 353 _GL_EXTERN_C int _gl_cxxalias_dummy 354 #endif 355 356 #endif /* _GL_CXXDEFS_H */ 357 358 /* The definition of _GL_WARN_ON_USE is copied here. */ 359 /* A C macro for emitting warnings if a function is used. 360 Copyright (C) 2010-2020 Free Software Foundation, Inc. 361 362 This program is free software: you can redistribute it and/or modify it 363 under the terms of the GNU General Public License as published 364 by the Free Software Foundation; either version 3 of the License, or 365 (at your option) any later version. 366 367 This program is distributed in the hope that it will be useful, 368 but WITHOUT ANY WARRANTY; without even the implied warranty of 369 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 370 General Public License for more details. 371 372 You should have received a copy of the GNU General Public License 373 along with this program. If not, see <https://www.gnu.org/licenses/>. */ 374 375 /* _GL_WARN_ON_USE (function, "literal string") issues a declaration 376 for FUNCTION which will then trigger a compiler warning containing 377 the text of "literal string" anywhere that function is called, if 378 supported by the compiler. If the compiler does not support this 379 feature, the macro expands to an unused extern declaration. 380 381 _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the 382 attribute used in _GL_WARN_ON_USE. If the compiler does not support 383 this feature, it expands to empty. 384 385 These macros are useful for marking a function as a potential 386 portability trap, with the intent that "literal string" include 387 instructions on the replacement function that should be used 388 instead. 389 _GL_WARN_ON_USE is for functions with 'extern' linkage. 390 _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline' 391 linkage. 392 393 However, one of the reasons that a function is a portability trap is 394 if it has the wrong signature. Declaring FUNCTION with a different 395 signature in C is a compilation error, so this macro must use the 396 same type as any existing declaration so that programs that avoid 397 the problematic FUNCTION do not fail to compile merely because they 398 included a header that poisoned the function. But this implies that 399 _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already 400 have a declaration. Use of this macro implies that there must not 401 be any other macro hiding the declaration of FUNCTION; but 402 undefining FUNCTION first is part of the poisoning process anyway 403 (although for symbols that are provided only via a macro, the result 404 is a compilation error rather than a warning containing 405 "literal string"). Also note that in C++, it is only safe to use if 406 FUNCTION has no overloads. 407 408 For an example, it is possible to poison 'getline' by: 409 - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]], 410 [getline]) in configure.ac, which potentially defines 411 HAVE_RAW_DECL_GETLINE 412 - adding this code to a header that wraps the system <stdio.h>: 413 #undef getline 414 #if HAVE_RAW_DECL_GETLINE 415 _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but" 416 "not universally present; use the gnulib module getline"); 417 #endif 418 419 It is not possible to directly poison global variables. But it is 420 possible to write a wrapper accessor function, and poison that 421 (less common usage, like &environ, will cause a compilation error 422 rather than issue the nice warning, but the end result of informing 423 the developer about their portability problem is still achieved): 424 #if HAVE_RAW_DECL_ENVIRON 425 static char *** 426 rpl_environ (void) { return &environ; } 427 _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared"); 428 # undef environ 429 # define environ (*rpl_environ ()) 430 #endif 431 or better (avoiding contradictory use of 'static' and 'extern'): 432 #if HAVE_RAW_DECL_ENVIRON 433 static char *** 434 _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared") 435 rpl_environ (void) { return &environ; } 436 # undef environ 437 # define environ (*rpl_environ ()) 438 #endif 439 */ 440 #ifndef _GL_WARN_ON_USE 441 442 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) 443 /* A compiler attribute is available in gcc versions 4.3.0 and later. */ 444 # define _GL_WARN_ON_USE(function, message) \ 445 extern __typeof__ (function) function __attribute__ ((__warning__ (message))) 446 # define _GL_WARN_ON_USE_ATTRIBUTE(message) \ 447 __attribute__ ((__warning__ (message))) 448 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 449 /* Verify the existence of the function. */ 450 # define _GL_WARN_ON_USE(function, message) \ 451 extern __typeof__ (function) function 452 # define _GL_WARN_ON_USE_ATTRIBUTE(message) 453 # else /* Unsupported. */ 454 # define _GL_WARN_ON_USE(function, message) \ 455 _GL_WARN_EXTERN_C int _gl_warn_on_use 456 # define _GL_WARN_ON_USE_ATTRIBUTE(message) 457 # endif 458 #endif 459 460 /* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string") 461 is like _GL_WARN_ON_USE (function, "string"), except that the function is 462 declared with the given prototype, consisting of return type, parameters, 463 and attributes. 464 This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does 465 not work in this case. */ 466 #ifndef _GL_WARN_ON_USE_CXX 467 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) 468 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ 469 extern rettype function parameters_and_attributes \ 470 __attribute__ ((__warning__ (msg))) 471 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 472 /* Verify the existence of the function. */ 473 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ 474 extern rettype function parameters_and_attributes 475 # else /* Unsupported. */ 476 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ 477 _GL_WARN_EXTERN_C int _gl_warn_on_use 478 # endif 479 #endif 480 481 /* _GL_WARN_EXTERN_C declaration; 482 performs the declaration with C linkage. */ 483 #ifndef _GL_WARN_EXTERN_C 484 # if defined __cplusplus 485 # define _GL_WARN_EXTERN_C extern "C" 486 # else 487 # define _GL_WARN_EXTERN_C extern 488 # endif 489 #endif 490 491 /* Return non-zero if c is a blank, i.e. a space or tab character. */ 492 #if 1 493 # if !1 494 _GL_EXTERN_C int isblank (int c); 495 # endif 496 #elif defined GNULIB_POSIXCHECK 497 # undef isblank 498 # if HAVE_RAW_DECL_ISBLANK 499 _GL_WARN_ON_USE (isblank, "isblank is unportable - " 500 "use gnulib module isblank for portability"); 501 # endif 502 #endif 503 504 #endif /* _GL_CTYPE_H */ 505 #endif /* _GL_CTYPE_H */ 506