diff options
Diffstat (limited to 'config.h.in')
-rw-r--r-- | config.h.in | 613 |
1 files changed, 580 insertions, 33 deletions
diff --git a/config.h.in b/config.h.in index 61d44652..43513c8d 100644 --- a/config.h.in +++ b/config.h.in @@ -48,9 +48,22 @@ /* Define as the word index where to find the sign of 'double'. */ #undef DBL_SIGNBIT_WORD +/* the name of the file descriptor member of DIR */ +#undef DIR_FD_MEMBER_NAME + +#ifdef DIR_FD_MEMBER_NAME +# define DIR_TO_FD(Dir_p) ((Dir_p)->DIR_FD_MEMBER_NAME) +#else +# define DIR_TO_FD(Dir_p) -1 +#endif + + /* Define to 1 if // is a file system root distinct from /. */ #undef DOUBLE_SLASH_IS_DISTINCT_ROOT +/* Define if struct dirent has a member d_ino that actually works. */ +#undef D_INO_IN_DIRENT + /* Define to 1 if the package shall run at any location in the file system. */ #undef ENABLE_RELOCATABLE @@ -82,21 +95,73 @@ #undef GETTIMEOFDAY_TIMEZONE /* Define to a C preprocessor expression that evaluates to 1 or 0, depending + whether the gnulib module accept shall be considered present. */ +#undef GNULIB_ACCEPT + +/* Define to a C preprocessor expression that evaluates to 1 or 0, depending + whether the gnulib module bind shall be considered present. */ +#undef GNULIB_BIND + +/* Define to a C preprocessor expression that evaluates to 1 or 0, depending + whether the gnulib module close shall be considered present. */ +#undef GNULIB_CLOSE + +/* Define to a C preprocessor expression that evaluates to 1 or 0, depending + whether the gnulib module connect shall be considered present. */ +#undef GNULIB_CONNECT + +/* Define to a C preprocessor expression that evaluates to 1 or 0, depending + whether the gnulib module fdopendir shall be considered present. */ +#undef GNULIB_FDOPENDIR + +/* Define to a C preprocessor expression that evaluates to 1 or 0, depending + whether the gnulib module fd-safer-flag shall be considered present. */ +#undef GNULIB_FD_SAFER_FLAG + +/* Define to a C preprocessor expression that evaluates to 1 or 0, depending whether the gnulib module fscanf shall be considered present. */ #undef GNULIB_FSCANF /* Define to a C preprocessor expression that evaluates to 1 or 0, depending + whether the gnulib module fstat shall be considered present. */ +#undef GNULIB_FSTAT + +/* Define to a C preprocessor expression that evaluates to 1 or 0, depending + whether the gnulib module fstatat shall be considered present. */ +#undef GNULIB_FSTATAT + +/* Define to a C preprocessor expression that evaluates to 1 or 0, depending + whether the gnulib module getcwd shall be considered present. */ +#undef GNULIB_GETCWD + +/* Define to a C preprocessor expression that evaluates to 1 or 0, depending + whether the gnulib module ioctl shall be considered present. */ +#undef GNULIB_IOCTL + +/* Define to a C preprocessor expression that evaluates to 1 or 0, depending whether the gnulib module isblank shall be considered present. */ #undef GNULIB_ISBLANK /* Define to a C preprocessor expression that evaluates to 1 or 0, depending + whether the gnulib module listen shall be considered present. */ +#undef GNULIB_LISTEN + +/* Define to a C preprocessor expression that evaluates to 1 or 0, depending whether the gnulib module lock shall be considered present. */ #undef GNULIB_LOCK /* Define to a C preprocessor expression that evaluates to 1 or 0, depending + whether the gnulib module lstat shall be considered present. */ +#undef GNULIB_LSTAT + +/* Define to a C preprocessor expression that evaluates to 1 or 0, depending whether the gnulib module msvc-nothrow shall be considered present. */ #undef GNULIB_MSVC_NOTHROW +/* Define to a C preprocessor expression that evaluates to 1 or 0, depending + whether the gnulib module openat shall be considered present. */ +#undef GNULIB_OPENAT + /* Define to 1 if printf and friends should be labeled with attribute "__gnu_printf__" instead of "__printf__" */ #undef GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU @@ -110,6 +175,22 @@ #undef GNULIB_SCANF /* Define to a C preprocessor expression that evaluates to 1 or 0, depending + whether the gnulib module select shall be considered present. */ +#undef GNULIB_SELECT + +/* Define to a C preprocessor expression that evaluates to 1 or 0, depending + whether the gnulib module setsockopt shall be considered present. */ +#undef GNULIB_SETSOCKOPT + +/* Define to a C preprocessor expression that evaluates to 1 or 0, depending + whether the gnulib module socket shall be considered present. */ +#undef GNULIB_SOCKET + +/* Define to a C preprocessor expression that evaluates to 1 or 0, depending + whether the gnulib module stat shall be considered present. */ +#undef GNULIB_STAT + +/* Define to a C preprocessor expression that evaluates to 1 or 0, depending whether the gnulib module strerror shall be considered present. */ #undef GNULIB_STRERROR @@ -183,27 +264,45 @@ /* Define to 1 when the gnulib module calloc-posix should be tested. */ #undef GNULIB_TEST_CALLOC_POSIX +/* Define to 1 when the gnulib module chdir should be tested. */ +#undef GNULIB_TEST_CHDIR + /* Define to 1 when the gnulib module cloexec should be tested. */ #undef GNULIB_TEST_CLOEXEC /* Define to 1 when the gnulib module close should be tested. */ #undef GNULIB_TEST_CLOSE +/* Define to 1 when the gnulib module closedir should be tested. */ +#undef GNULIB_TEST_CLOSEDIR + /* Define to 1 when the gnulib module connect should be tested. */ #undef GNULIB_TEST_CONNECT +/* Define to 1 when the gnulib module dirfd should be tested. */ +#undef GNULIB_TEST_DIRFD + +/* Define to 1 when the gnulib module dup should be tested. */ +#undef GNULIB_TEST_DUP + /* Define to 1 when the gnulib module dup2 should be tested. */ #undef GNULIB_TEST_DUP2 /* Define to 1 when the gnulib module environ should be tested. */ #undef GNULIB_TEST_ENVIRON +/* Define to 1 when the gnulib module fchdir should be tested. */ +#undef GNULIB_TEST_FCHDIR + /* Define to 1 when the gnulib module fcntl should be tested. */ #undef GNULIB_TEST_FCNTL /* Define to 1 when the gnulib module fdopen should be tested. */ #undef GNULIB_TEST_FDOPEN +/* Define to 1 when the gnulib module fdopendir should be tested. */ +#undef GNULIB_TEST_FDOPENDIR + /* Define to 1 when the gnulib module fgetc should be tested. */ #undef GNULIB_TEST_FGETC @@ -237,6 +336,9 @@ /* Define to 1 when the gnulib module fstat should be tested. */ #undef GNULIB_TEST_FSTAT +/* Define to 1 when the gnulib module fstatat should be tested. */ +#undef GNULIB_TEST_FSTATAT + /* Define to 1 when the gnulib module ftruncate should be tested. */ #undef GNULIB_TEST_FTRUNCATE @@ -255,9 +357,6 @@ /* Define to 1 when the gnulib module getdtablesize should be tested. */ #undef GNULIB_TEST_GETDTABLESIZE -/* Define to 1 when the gnulib module getpagesize should be tested. */ -#undef GNULIB_TEST_GETPAGESIZE - /* Define to 1 when the gnulib module getprogname should be tested. */ #undef GNULIB_TEST_GETPROGNAME @@ -315,12 +414,24 @@ /* Define to 1 when the gnulib module memchr should be tested. */ #undef GNULIB_TEST_MEMCHR +/* Define to 1 when the gnulib module mempcpy should be tested. */ +#undef GNULIB_TEST_MEMPCPY + +/* Define to 1 when the gnulib module memrchr should be tested. */ +#undef GNULIB_TEST_MEMRCHR + /* Define to 1 when the gnulib module nanosleep should be tested. */ #undef GNULIB_TEST_NANOSLEEP /* Define to 1 when the gnulib module open should be tested. */ #undef GNULIB_TEST_OPEN +/* Define to 1 when the gnulib module openat should be tested. */ +#undef GNULIB_TEST_OPENAT + +/* Define to 1 when the gnulib module opendir should be tested. */ +#undef GNULIB_TEST_OPENDIR + /* Define to 1 when the gnulib module perror should be tested. */ #undef GNULIB_TEST_PERROR @@ -333,6 +444,22 @@ /* Define to 1 when the gnulib module pselect should be tested. */ #undef GNULIB_TEST_PSELECT +/* Define to 1 when the gnulib module pthread-cond should be tested. */ +#undef GNULIB_TEST_PTHREAD_COND + +/* Define to 1 when the gnulib module pthread-mutex should be tested. */ +#undef GNULIB_TEST_PTHREAD_MUTEX + +/* Define to 1 when the gnulib module pthread_mutex_timedlock should be + tested. */ +#undef GNULIB_TEST_PTHREAD_MUTEX_TIMEDLOCK + +/* Define to 1 when the gnulib module pthread-once should be tested. */ +#undef GNULIB_TEST_PTHREAD_ONCE + +/* Define to 1 when the gnulib module pthread-rwlock should be tested. */ +#undef GNULIB_TEST_PTHREAD_RWLOCK + /* Define to 1 when the gnulib module pthread_sigmask should be tested. */ #undef GNULIB_TEST_PTHREAD_SIGMASK @@ -360,6 +487,9 @@ /* Define to 1 when the gnulib module random_r should be tested. */ #undef GNULIB_TEST_RANDOM_R +/* Define to 1 when the gnulib module readdir should be tested. */ +#undef GNULIB_TEST_READDIR + /* Define to 1 when the gnulib module reallocarray should be tested. */ #undef GNULIB_TEST_REALLOCARRAY @@ -369,6 +499,9 @@ /* Define to 1 when the gnulib module realloc-posix should be tested. */ #undef GNULIB_TEST_REALLOC_POSIX +/* Define to 1 when the gnulib module rewinddir should be tested. */ +#undef GNULIB_TEST_REWINDDIR + /* Define to 1 when the gnulib module scanf should be tested. */ #undef GNULIB_TEST_SCANF @@ -405,6 +538,12 @@ /* Define to 1 when the gnulib module stat should be tested. */ #undef GNULIB_TEST_STAT +/* Define to 1 when the gnulib module stpcpy should be tested. */ +#undef GNULIB_TEST_STPCPY + +/* Define to 1 when the gnulib module strdup should be tested. */ +#undef GNULIB_TEST_STRDUP + /* Define to 1 when the gnulib module strerror should be tested. */ #undef GNULIB_TEST_STRERROR @@ -575,6 +714,9 @@ whether the gnulib module xalloc-die shall be considered present. */ #undef GNULIB_XALLOC_DIE +/* Define to 1 if you have the <afunix.h> header file. */ +#undef HAVE_AFUNIX_H + /* Define if the __locale_t type contains the name of the LC_MESSAGES category. */ #undef HAVE_AIX72_LOCALES @@ -609,6 +751,9 @@ the CoreFoundation framework. */ #undef HAVE_CFPREFERENCESCOPYAPPVALUE +/* Define to 1 if you have the 'closedir' function. */ +#undef HAVE_CLOSEDIR + /* Define if the copysignf function is declared in <math.h> and available in libc. */ #undef HAVE_COPYSIGNF_IN_LIBC @@ -652,6 +797,10 @@ don't. */ #undef HAVE_DECL_COPYSIGNL +/* Define to 1 if you have the declaration of 'dirfd', and to 0 if you don't. + */ +#undef HAVE_DECL_DIRFD + /* Define to 1 if you have the declaration of 'ecvt', and to 0 if you don't. */ #undef HAVE_DECL_ECVT @@ -660,6 +809,10 @@ don't. */ #undef HAVE_DECL_EXECVPE +/* Define to 1 if you have the declaration of 'fchdir', and to 0 if you don't. + */ +#undef HAVE_DECL_FCHDIR + /* Define to 1 if you have the declaration of 'fcloseall', and to 0 if you don't. */ #undef HAVE_DECL_FCLOSEALL @@ -668,10 +821,18 @@ */ #undef HAVE_DECL_FCVT +/* Define to 1 if you have the declaration of 'fdopendir', and to 0 if you + don't. */ +#undef HAVE_DECL_FDOPENDIR + /* Define to 1 if you have the declaration of 'gcvt', and to 0 if you don't. */ #undef HAVE_DECL_GCVT +/* Define to 1 if you have the declaration of 'getcwd', and to 0 if you don't. + */ +#undef HAVE_DECL_GETCWD + /* Define to 1 if you have the declaration of 'getdtablesize', and to 0 if you don't. */ #undef HAVE_DECL_GETDTABLESIZE @@ -700,6 +861,10 @@ don't. */ #undef HAVE_DECL_MBSINIT +/* Define to 1 if you have the declaration of 'memrchr', and to 0 if you + don't. */ +#undef HAVE_DECL_MEMRCHR + /* Define to 1 if you have the declaration of 'program_invocation_name', and to 0 if you don't. */ #undef HAVE_DECL_PROGRAM_INVOCATION_NAME @@ -724,6 +889,10 @@ */ #undef HAVE_DECL_SLEEP +/* Define to 1 if you have the declaration of 'strdup', and to 0 if you don't. + */ +#undef HAVE_DECL_STRDUP + /* Define to 1 if you have the declaration of 'strerror_r', and to 0 if you don't. */ #undef HAVE_DECL_STRERROR_R @@ -764,6 +933,12 @@ */ #undef HAVE_DECL___ARGV +/* Define to 1 if you have the <dirent.h> header file. */ +#undef HAVE_DIRENT_H + +/* Define to 1 if you have the 'dirfd' function. */ +#undef HAVE_DIRFD + /* Define to 1 if you have the <dlfcn.h> header file. */ #undef HAVE_DLFCN_H @@ -783,9 +958,15 @@ OpenBSD. */ #undef HAVE_FAKE_LOCALES +/* Define to 1 if you have the 'fchdir' function. */ +#undef HAVE_FCHDIR + /* Define to 1 if you have the 'fcntl' function. */ #undef HAVE_FCNTL +/* Define to 1 if you have the 'fdopendir' function. */ +#undef HAVE_FDOPENDIR + /* Define to 1 if you have the <features.h> header file. */ #undef HAVE_FEATURES_H @@ -801,9 +982,16 @@ /* Define if the frexp function is available in libc. */ #undef HAVE_FREXP_IN_LIBC +/* Define to 1 if you have the 'fstatat' function. */ +#undef HAVE_FSTATAT + /* Define to 1 if you have the `ftruncate' function. */ #undef HAVE_FTRUNCATE +/* Define to 1 if getcwd works, but with shorter paths than is generally + tested with the replacement. */ +#undef HAVE_GETCWD_SHORTER + /* Define to 1 if you have the 'getdtablesize' function. */ #undef HAVE_GETDTABLESIZE @@ -923,6 +1111,16 @@ /* Define to 1 if you have the `mbtowc' function. */ #undef HAVE_MBTOWC +/* Define to 1 if you have the `mempcpy' function. */ +#undef HAVE_MEMPCPY + +/* Define to 1 if you have the 'memrchr' function. */ +#undef HAVE_MEMRCHR + +/* Define to 1 if getcwd minimally works, that is, its result can be trusted + when it succeeds. */ +#undef HAVE_MINIMALLY_WORKING_GETCWD + /* Define to 1 if you have the <minix/config.h> header file. */ #undef HAVE_MINIX_CONFIG_H @@ -955,8 +1153,15 @@ /* Define to 1 if you have the `nl_langinfo' function. */ #undef HAVE_NL_LANGINFO -/* Define to 1 if you have the <OS.h> header file. */ -#undef HAVE_OS_H +/* Define to 1 if you have the 'openat' function. */ +#undef HAVE_OPENAT + +/* Define to 1 if you have the 'opendir' function. */ +#undef HAVE_OPENDIR + +/* Define to 1 if getcwd works, except it sometimes fails when it shouldn't, + setting errno to ERANGE, ENAMETOOLONG, or ENOENT. */ +#undef HAVE_PARTLY_WORKING_GETCWD /* Define to 1 if you have the 'pipe' function. */ #undef HAVE_PIPE @@ -1001,9 +1206,15 @@ /* Define to 1 if you have the 'random_r' function. */ #undef HAVE_RANDOM_R +/* Define to 1 if you have the 'readdir' function. */ +#undef HAVE_READDIR + /* Define to 1 if you have the `reallocarray' function. */ #undef HAVE_REALLOCARRAY +/* Define to 1 if you have the 'rewinddir' function. */ +#undef HAVE_REWINDDIR + /* Define to 1 if 'long double' and 'double' have the same representation. */ #undef HAVE_SAME_LONG_DOUBLE_AS_DOUBLE @@ -1137,9 +1348,6 @@ /* Define to 1 if you have the <sys/bitypes.h> header file. */ #undef HAVE_SYS_BITYPES_H -/* Define to 1 if you have the <sys/cdefs.h> header file. */ -#undef HAVE_SYS_CDEFS_H - /* Define to 1 if you have the <sys/inttypes.h> header file. */ #undef HAVE_SYS_INTTYPES_H @@ -1173,6 +1381,9 @@ /* Define to 1 if you have the <sys/uio.h> header file. */ #undef HAVE_SYS_UIO_H +/* Define to 1 if you have the <sys/un.h> header file. */ +#undef HAVE_SYS_UN_H + /* Define to 1 if you have the <sys/wait.h> header file. */ #undef HAVE_SYS_WAIT_H @@ -1194,6 +1405,9 @@ /* Define to 1 if you have the <unistd.h> header file. */ #undef HAVE_UNISTD_H +/* Define to 1 if <sys/socket.h> defines AF_UNIX. */ +#undef HAVE_UNIXSOCKET + /* Define to 1 if you have the 'unsetenv' function. */ #undef HAVE_UNSETENV @@ -1216,9 +1430,6 @@ /* Define to 1 if you have the <wchar.h> header file. */ #undef HAVE_WCHAR_H -/* Define if you have the 'wchar_t' type. */ -#undef HAVE_WCHAR_T - /* Define to 1 if you have the 'wcrtomb' function. */ #undef HAVE_WCRTOMB @@ -1244,6 +1455,13 @@ /* Define if you have the 'wint_t' type. */ #undef HAVE_WINT_T +/* Define if the c32rtomb function basically works. */ +#undef HAVE_WORKING_C32RTOMB + +/* Define to 1 if fstatat (..., 0) works. For example, it does not work in AIX + 7.1. */ +#undef HAVE_WORKING_FSTATAT_ZERO_FLAG + /* Define if the mbrtoc32 function basically works. */ #undef HAVE_WORKING_MBRTOC32 @@ -1445,6 +1663,10 @@ */ #undef MBRTOC32_IN_C_LOCALE_MAYBE_EILSEQ +/* Define if the mbrtoc32 function does not accept the input bytes one-by-one. + */ +#undef MBRTOC32_MULTIBYTE_LOCALE_BUG + /* Define if the mbrtowc function does not return (size_t) -2 for empty input. */ #undef MBRTOWC_EMPTY_INPUT_BUG @@ -1590,6 +1812,19 @@ /* Define if the pthread_in_use() detection is hard. */ #undef PTHREAD_IN_USE_DETECTION_HARD +/* Define if the 'robust' attribute of pthread_mutex* doesn't exist. */ +#undef PTHREAD_MUTEXATTR_ROBUST_UNIMPLEMENTED + +/* Define if the pthread_rwlock wait queue handling is not reasonable. */ +#undef PTHREAD_RWLOCK_BAD_WAITQUEUE + +/* Define if the functions pthread_rwlock_timedrdlock and + pthread_rwlock_timedwrlock don't exist. */ +#undef PTHREAD_RWLOCK_LACKS_TIMEOUT + +/* Define if all pthread_rwlock* functions don't exist. */ +#undef PTHREAD_RWLOCK_UNIMPLEMENTED + /* Define to 1 if pthread_sigmask(), when it fails, returns -1 and sets errno. */ #undef PTHREAD_SIGMASK_FAILS_WITH_ERRNO @@ -1604,10 +1839,17 @@ 'ptrdiff_t'. */ #undef PTRDIFF_T_SUFFIX +/* Define to 1 if gnulib's fchdir() replacement is used. */ +#undef REPLACE_FCHDIR + /* Define to 1 if stat needs help when passed a file name with a trailing slash */ #undef REPLACE_FUNC_STAT_FILE +/* Define to 1 if open() should work around the inability to open a directory. + */ +#undef REPLACE_OPEN_DIRECTORY + /* Define to 1 if strerror(0) does not return a message implying success. */ #undef REPLACE_STRERROR_0 @@ -1661,6 +1903,13 @@ /* Define if the ISO C multithreading library can be used. */ #undef USE_ISOC_THREADS +/* Define to enable the declarations of ISO C 23 Annex K types and functions. */ +#if !(defined __STDC_WANT_LIB_EXT1__ && __STDC_WANT_LIB_EXT1__) +#undef/**/__STDC_WANT_LIB_EXT1__ +#define __STDC_WANT_LIB_EXT1__ 1 +#endif + + /* Define if the POSIX multithreading library can be used. */ #undef USE_POSIX_THREADS @@ -1808,10 +2057,22 @@ /* Number of bits in a file offset, on hosts where this is settable. */ #undef _FILE_OFFSET_BITS -/* True if the compiler says it groks GNU C version MAJOR.MINOR. */ -#if defined __GNUC__ && defined __GNUC_MINOR__ +/* True if the compiler says it groks GNU C version MAJOR.MINOR. + Except that + - clang groks GNU C 4.2, even on Windows, where it does not define + __GNUC__. + - The OpenMandriva-modified clang compiler pretends that it groks + GNU C version 13.1, but it doesn't: It does not support + __attribute__ ((__malloc__ (f, i))), nor does it support + __attribute__ ((__warning__ (message))) on a function redeclaration. + - Users can make clang lie as well, through the -fgnuc-version option. */ +#if defined __GNUC__ && defined __GNUC_MINOR__ && !defined __clang__ # define _GL_GNUC_PREREQ(major, minor) \ ((major) < __GNUC__ + ((minor) <= __GNUC_MINOR__)) +#elif defined __clang__ + /* clang really only groks GNU C 4.2. */ +# define _GL_GNUC_PREREQ(major, minor) \ + ((major) < 4 + ((minor) <= 2)) #else # define _GL_GNUC_PREREQ(major, minor) 0 #endif @@ -1826,6 +2087,9 @@ /* Define to 1 on Solaris. */ #undef _LCONV_C99 +/* Define so that AIX headers are more compatible with GNU/Linux. */ +#undef _LINUX_SOURCE_COMPAT + /* The _Noreturn keyword of C11. */ #ifndef _Noreturn # if (defined __cplusplus \ @@ -1950,8 +2214,10 @@ # define _GL_ATTR_nothrow _GL_GNUC_PREREQ (3, 3) # define _GL_ATTR_packed _GL_GNUC_PREREQ (2, 7) # define _GL_ATTR_pure _GL_GNUC_PREREQ (2, 96) +# define _GL_ATTR_reproducible 0 /* not yet supported, as of GCC 14 */ # define _GL_ATTR_returns_nonnull _GL_GNUC_PREREQ (4, 9) # define _GL_ATTR_sentinel _GL_GNUC_PREREQ (4, 0) +# define _GL_ATTR_unsequenced 0 /* not yet supported, as of GCC 14 */ # define _GL_ATTR_unused _GL_GNUC_PREREQ (2, 7) # define _GL_ATTR_warn_unused_result _GL_GNUC_PREREQ (3, 4) # endif @@ -1967,6 +2233,23 @@ # define _GL_HAVE___HAS_C_ATTRIBUTE 0 #endif +/* Attributes in bracket syntax [[...]] vs. attributes in __attribute__((...)) + syntax, in function declarations. There are two problems here. + (Last tested with gcc/g++ 14 and clang/clang++ 18.) + + 1) We want that the _GL_ATTRIBUTE_* can be cumulated on the same declaration + in any order. + =========================== foo.c = foo.cc =========================== + __attribute__ ((__deprecated__)) [[__nodiscard__]] int bar1 (int); + [[__nodiscard__]] __attribute__ ((__deprecated__)) int bar2 (int); + ====================================================================== + This gives a syntax error + - in C mode with gcc + <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108796>, and + - in C++ mode with clang++ version < 16, and + - in C++ mode, inside extern "C" {}, still in newer clang++ versions + <https://github.com/llvm/llvm-project/issues/101990>. + */ /* Define if, in a function declaration, the attributes in bracket syntax [[...]] must come before the attributes in __attribute__((...)) syntax. If this is defined, it is best to avoid the bracket syntax, so that the @@ -1981,13 +2264,183 @@ # define _GL_BRACKET_BEFORE_ATTRIBUTE 1 # endif #endif +/* + 2) We want that the _GL_ATTRIBUTE_* can be placed in a declaration + - without 'extern', in C as well as in C++, + - with 'extern', in C, + - with 'extern "C"', in C++ + in the same position. That is, we don't want to be forced to use a + macro which arranges for the attribute to come before 'extern' in + one case and after 'extern' in the other case, because such a macro + would make the source code of .h files pretty ugly. + =========================== foo.c = foo.cc =========================== + #ifdef __cplusplus + # define CC "C" + #else + # define CC + #endif + + #define ND [[__nodiscard__]] + #define WUR __attribute__((__warn_unused_result__)) + + #ifdef __cplusplus + extern "C" { + #endif + // gcc clang g++ clang++ + + ND int foo (int); + int ND foo (int); // warn error warn error + int foo ND (int); + int foo (int) ND; // warn error warn error + + WUR int foo (int); + int WUR foo (int); + int fo1 WUR (int); // error error error error + int foo (int) WUR; + + #ifdef __cplusplus + } + #endif + + // gcc clang g++ clang++ + + ND extern CC int foo (int); // error error + extern CC ND int foo (int); // error error + extern CC int ND foo (int); // warn error warn error + extern CC int foo ND (int); + extern CC int foo (int) ND; // warn error warn error + + WUR extern CC int foo (int); // warn + extern CC WUR int foo (int); + extern CC int WUR foo (int); + extern CC int foo WUR (int); // error error error error + extern CC int foo (int) WUR; + + ND EXTERN_C_FUNC int foo (int); // error error + EXTERN_C_FUNC ND int foo (int); + EXTERN_C_FUNC int ND foo (int); // warn error warn error + EXTERN_C_FUNC int foo ND (int); + EXTERN_C_FUNC int foo (int) ND; // warn error warn error + + WUR EXTERN_C_FUNC int foo (int); // warn + EXTERN_C_FUNC WUR int foo (int); + EXTERN_C_FUNC int WUR foo (int); + EXTERN_C_FUNC int fo2 WUR (int); // error error error error + EXTERN_C_FUNC int foo (int) WUR; + ====================================================================== + So, if we insist on using the 'extern' keyword ('extern CC' idiom): + * If _GL_ATTRIBUTE_* expands to bracket syntax [[...]] + in both C and C++, there is one available position: + - between the function name and the parameter list. + * If _GL_ATTRIBUTE_* expands to __attribute__((...)) syntax + in both C and C++, there are several available positions: + - before the return type, + - between return type and function name, + - at the end of the declaration. + * If _GL_ATTRIBUTE_* expands to bracket syntax [[...]] in C and to + __attribute__((...)) syntax in C++, there is no available position: + it would need to come before 'extern' in C but after 'extern "C"' + in C++. + * If _GL_ATTRIBUTE_* expands to __attribute__((...)) syntax in C and + to bracket syntax [[...]] in C++, there is one available position: + - before the return type. + Whereas, if we use the 'EXTERN_C_FUNC' idiom, which conditionally + omits the 'extern' keyword: + * If _GL_ATTRIBUTE_* expands to bracket syntax [[...]] + in both C and C++, there are two available positions: + - before the return type, + - between the function name and the parameter list. + * If _GL_ATTRIBUTE_* expands to __attribute__((...)) syntax + in both C and C++, there are several available positions: + - before the return type, + - between return type and function name, + - at the end of the declaration. + * If _GL_ATTRIBUTE_* expands to bracket syntax [[...]] in C and to + __attribute__((...)) syntax in C++, there is one available position: + - before the return type. + * If _GL_ATTRIBUTE_* expands to __attribute__((...)) syntax in C and + to bracket syntax [[...]] in C++, there is one available position: + - before the return type. + The best choice is therefore to use the 'EXTERN_C_FUNC' idiom and + put the attributes before the return type. This works regardless + to what the _GL_ATTRIBUTE_* macros expand. + */ + +/* Attributes in bracket syntax [[...]] vs. attributes in __attribute__((...)) + syntax, in static/inline function definitions. + + There are similar constraints as for function declarations. However, here, + we cannot omit the storage-class specifier. Therefore, the following rule + applies: + * The macros + _GL_ATTRIBUTE_CONST + _GL_ATTRIBUTE_DEPRECATED + _GL_ATTRIBUTE_MAYBE_UNUSED + _GL_ATTRIBUTE_NODISCARD + _GL_ATTRIBUTE_PURE + _GL_ATTRIBUTE_REPRODUCIBLE + _GL_ATTRIBUTE_UNSEQUENCED + which may expand to bracket syntax [[...]], must come first, before the + storage-class specifier. + * Other _GL_ATTRIBUTE_* macros, that expand to __attribute__((...)) syntax, + are better placed between the storage-class specifier and the return + type. + */ + +/* Attributes in bracket syntax [[...]] vs. attributes in __attribute__((...)) + syntax, in variable declarations. + + At which position can they be placed? + (Last tested with gcc/g++ 14 and clang/clang++ 18.) + + =========================== foo.c = foo.cc =========================== + #ifdef __cplusplus + # define CC "C" + #else + # define CC + #endif + + #define BD [[__deprecated__]] + #define AD __attribute__ ((__deprecated__)) + + // gcc clang g++ clang++ + + BD extern CC int var; // error error + extern CC BD int var; // error error + extern CC int BD var; // warn error warn error + extern CC int var BD; + + AD extern CC int var; // warn + extern CC AD int var; + extern CC int AD var; + extern CC int var AD; + + BD extern CC int z[]; // error error + extern CC BD int z[]; // error error + extern CC int BD z[]; // warn error warn error + extern CC int z1 BD []; + extern CC int z[] BD; // warn error error + + AD extern CC int z[]; // warn + extern CC AD int z[]; + extern CC int AD z[]; + extern CC int z2 AD []; // error error error error + extern CC int z[] AD; + ====================================================================== + + * For non-array variables, the only good position is after the variable name, + that is, at the end of the declaration. + * For array variables, you will need to distinguish C and C++: + - In C, before the 'extern' keyword. + - In C++, between the 'extern "C"' and the variable's type. + */ /* _GL_ATTRIBUTE_ALLOC_SIZE ((N)) declares that the Nth argument of the function is the size of the returned memory block. _GL_ATTRIBUTE_ALLOC_SIZE ((M, N)) declares that the Mth argument multiplied by the Nth argument of the function is the size of the returned memory block. */ -/* Applies to: function, pointer to function, function types. */ +/* Applies to: functions, pointer to functions, function types. */ #ifndef _GL_ATTRIBUTE_ALLOC_SIZE # if _GL_HAS_ATTRIBUTE (alloc_size) # define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args)) @@ -1998,7 +2451,7 @@ /* _GL_ATTRIBUTE_ALWAYS_INLINE tells that the compiler should always inline the function and report an error if it cannot do so. */ -/* Applies to: function. */ +/* Applies to: functions. */ #ifndef _GL_ATTRIBUTE_ALWAYS_INLINE # if _GL_HAS_ATTRIBUTE (always_inline) # define _GL_ATTRIBUTE_ALWAYS_INLINE __attribute__ ((__always_inline__)) @@ -2010,7 +2463,7 @@ /* _GL_ATTRIBUTE_ARTIFICIAL declares that the function is not important to show in stack traces when debugging. The compiler should omit the function from stack traces. */ -/* Applies to: function. */ +/* Applies to: functions. */ #ifndef _GL_ATTRIBUTE_ARTIFICIAL # if _GL_HAS_ATTRIBUTE (artificial) # define _GL_ATTRIBUTE_ARTIFICIAL __attribute__ ((__artificial__)) @@ -2036,18 +2489,23 @@ # endif #endif -/* _GL_ATTRIBUTE_CONST declares that it is OK for a compiler to omit duplicate - calls to the function with the same arguments. - This attribute is safe for a function that neither depends on nor affects - observable state, and always returns exactly once - e.g., does not loop - forever, and does not call longjmp. - (This attribute is stricter than _GL_ATTRIBUTE_PURE.) */ +/* _GL_ATTRIBUTE_CONST declares: + It is OK for a compiler to move calls to the function and to omit + calls to the function if another call has the same arguments or the + result is not used. + This attribute is safe for a function that neither depends on + nor affects state, and always returns exactly once - + e.g., does not raise an exception, call longjmp, or loop forever. + (This attribute is stricter than _GL_ATTRIBUTE_PURE because the + function cannot observe state. It is stricter than + _GL_ATTRIBUTE_UNSEQUENCED because the function must return exactly + once and cannot depend on state addressed by its arguments.) */ /* Applies to: functions. */ #ifndef _GL_ATTRIBUTE_CONST # if _GL_HAS_ATTRIBUTE (const) # define _GL_ATTRIBUTE_CONST __attribute__ ((__const__)) # else -# define _GL_ATTRIBUTE_CONST +# define _GL_ATTRIBUTE_CONST _GL_ATTRIBUTE_UNSEQUENCED # endif #endif @@ -2316,7 +2774,7 @@ other attributes. */ #ifndef _GL_ATTRIBUTE_NOTHROW # if defined __cplusplus -# if _GL_GNUC_PREREQ (2, 8) || __clang_major >= 4 +# if _GL_GNUC_PREREQ (2, 8) || __clang_major__ >= 4 # if __cplusplus >= 201103L # define _GL_ATTRIBUTE_NOTHROW noexcept (true) # else @@ -2341,25 +2799,58 @@ /* Applies to: struct members, struct, union, in C++ also: class. */ #ifndef _GL_ATTRIBUTE_PACKED -# if _GL_HAS_ATTRIBUTE (packed) +/* Oracle Studio 12.6 miscompiles code with __attribute__ ((__packed__)) despite + __has_attribute OK. */ +# if _GL_HAS_ATTRIBUTE (packed) && !defined __SUNPRO_C # define _GL_ATTRIBUTE_PACKED __attribute__ ((__packed__)) # else # define _GL_ATTRIBUTE_PACKED # endif #endif -/* _GL_ATTRIBUTE_PURE declares that It is OK for a compiler to omit duplicate - calls to the function with the same arguments if observable state is not - changed between calls. - This attribute is safe for a function that does not affect - observable state, and always returns exactly once. - (This attribute is looser than _GL_ATTRIBUTE_CONST.) */ +/* _GL_ATTRIBUTE_PURE declares: + It is OK for a compiler to move calls to the function and to omit + calls to the function if another call has the same arguments or the + result is not used, and if observable state is the same. + This attribute is safe for a function that does not affect observable state + and always returns exactly once. + (This attribute is looser than _GL_ATTRIBUTE_CONST because the function + can depend on observable state. It is stricter than + _GL_ATTRIBUTE_REPRODUCIBLE because the function must return exactly + once and cannot affect state addressed by its arguments.) */ /* Applies to: functions. */ #ifndef _GL_ATTRIBUTE_PURE # if _GL_HAS_ATTRIBUTE (pure) # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) # else -# define _GL_ATTRIBUTE_PURE +# define _GL_ATTRIBUTE_PURE _GL_ATTRIBUTE_REPRODUCIBLE +# endif +#endif + +/* _GL_ATTRIBUTE_REPRODUCIBLE declares: + It is OK for a compiler to move calls to the function and to omit duplicate + calls to the function with the same arguments, so long as the state + addressed by its arguments is the same and is updated in time for + the rest of the program. + This attribute is safe for a function that is effectless and idempotent; see + ISO C 23 § 6.7.12.7 for a definition of these terms. + (This attribute is looser than _GL_ATTRIBUTE_UNSEQUENCED because + the function need not be stateless and idempotent. It is looser + than _GL_ATTRIBUTE_PURE because the function need not return + exactly once and can affect state addressed by its arguments.) + See also <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2956.htm> and + <https://stackoverflow.com/questions/76847905/>. */ +/* Applies to: functions, pointer to functions, function types. */ +#ifndef _GL_ATTRIBUTE_REPRODUCIBLE +/* This may be revisited when gcc and clang support [[reproducible]] or possibly + __attribute__ ((__reproducible__)). */ +# ifndef _GL_BRACKET_BEFORE_ATTRIBUTE +# if _GL_HAS_ATTRIBUTE (reproducible) +# define _GL_ATTRIBUTE_REPRODUCIBLE [[reproducible]] +# endif +# endif +# ifndef _GL_ATTRIBUTE_REPRODUCIBLE +# define _GL_ATTRIBUTE_REPRODUCIBLE # endif #endif @@ -2387,6 +2878,33 @@ # endif #endif +/* _GL_ATTRIBUTE_UNSEQUENCED declares: + It is OK for a compiler to move calls to the function and to omit duplicate + calls to the function with the same arguments, so long as the state + addressed by its arguments is the same. + This attribute is safe for a function that is effectless, idempotent, + stateless, and independent; see ISO C 23 § 6.7.12.7 for a definition of + these terms. + (This attribute is stricter than _GL_ATTRIBUTE_REPRODUCIBLE because + the function must be stateless and independent. It is looser than + _GL_ATTRIBUTE_CONST because the function need not return exactly + once and can depend on state addressed by its arguments.) + See also <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2956.htm> and + <https://stackoverflow.com/questions/76847905/>. */ +/* Applies to: functions, pointer to functions, function types. */ +#ifndef _GL_ATTRIBUTE_UNSEQUENCED +/* This may be revisited when gcc and clang support [[unsequenced]] or possibly + __attribute__ ((__unsequenced__)). */ +# ifndef _GL_BRACKET_BEFORE_ATTRIBUTE +# if _GL_HAS_ATTRIBUTE (unsequenced) +# define _GL_ATTRIBUTE_UNSEQUENCED [[unsequenced]] +# endif +# endif +# ifndef _GL_ATTRIBUTE_UNSEQUENCED +# define _GL_ATTRIBUTE_UNSEQUENCED +# endif +#endif + /* A helper macro. Don't use it directly. */ #ifndef _GL_ATTRIBUTE_UNUSED # if _GL_HAS_ATTRIBUTE (unused) @@ -2411,6 +2929,35 @@ # endif #endif +/* The following attributes enable detection of multithread-safety problems + and resource leaks at compile-time, by clang ≥ 15, when the warning option + -Wthread-safety is enabled. For usage, see + <https://clang.llvm.org/docs/ThreadSafetyAnalysis.html>. */ +#ifndef _GL_ATTRIBUTE_CAPABILITY_TYPE +# if __clang_major__ >= 15 +# define _GL_ATTRIBUTE_CAPABILITY_TYPE(concept) \ + __attribute__ ((__capability__ (concept))) +#else +# define _GL_ATTRIBUTE_CAPABILITY_TYPE(concept) +# endif +#endif +#ifndef _GL_ATTRIBUTE_ACQUIRE_CAPABILITY +# if __clang_major__ >= 15 +# define _GL_ATTRIBUTE_ACQUIRE_CAPABILITY(resource) \ + __attribute__ ((__acquire_capability__ (resource))) +# else +# define _GL_ATTRIBUTE_ACQUIRE_CAPABILITY(resource) +# endif +#endif +#ifndef _GL_ATTRIBUTE_RELEASE_CAPABILITY +# if __clang_major__ >= 15 +# define _GL_ATTRIBUTE_RELEASE_CAPABILITY(resource) \ + __attribute__ ((__release_capability__ (resource))) +# else +# define _GL_ATTRIBUTE_RELEASE_CAPABILITY(resource) +# endif +#endif + /* In C++, there is the concept of "language linkage", that encompasses name mangling and function calling conventions. @@ -2535,7 +3082,7 @@ References: ISO C23 (latest free draft - <http://www.open-std.org/jtc1/sc22/wg14/www/docs/n3047.pdf>) + <http://www.open-std.org/jtc1/sc22/wg14/www/docs/n3096.pdf>) sections 6.5.3.4, 6.7.5, 7.15. C++11 (latest free draft <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf>) |