Home | History | Annotate | Line # | Download | only in m4
      1  1.1.1.2  christos # gnulib-common.m4 serial 73
      2  1.1.1.2  christos dnl Copyright (C) 2007-2022 Free Software Foundation, Inc.
      3      1.1  christos dnl This file is free software; the Free Software Foundation
      4      1.1  christos dnl gives unlimited permission to copy and/or distribute it,
      5      1.1  christos dnl with or without modifications, as long as this notice is preserved.
      6      1.1  christos 
      7      1.1  christos AC_PREREQ([2.62])
      8      1.1  christos 
      9      1.1  christos # gl_COMMON
     10      1.1  christos # is expanded unconditionally through gnulib-tool magic.
     11      1.1  christos AC_DEFUN([gl_COMMON], [
     12      1.1  christos   dnl Use AC_REQUIRE here, so that the code is expanded once only.
     13      1.1  christos   AC_REQUIRE([gl_00GNULIB])
     14      1.1  christos   AC_REQUIRE([gl_COMMON_BODY])
     15      1.1  christos   AC_REQUIRE([gl_ZZGNULIB])
     16      1.1  christos ])
     17      1.1  christos AC_DEFUN([gl_COMMON_BODY], [
     18      1.1  christos   AH_VERBATIM([_GL_GNUC_PREREQ],
     19      1.1  christos [/* True if the compiler says it groks GNU C version MAJOR.MINOR.  */
     20      1.1  christos #if defined __GNUC__ && defined __GNUC_MINOR__
     21      1.1  christos # define _GL_GNUC_PREREQ(major, minor) \
     22      1.1  christos     ((major) < __GNUC__ + ((minor) <= __GNUC_MINOR__))
     23      1.1  christos #else
     24      1.1  christos # define _GL_GNUC_PREREQ(major, minor) 0
     25      1.1  christos #endif
     26      1.1  christos ])
     27      1.1  christos   AH_VERBATIM([_Noreturn],
     28      1.1  christos [/* The _Noreturn keyword of C11.  */
     29      1.1  christos #ifndef _Noreturn
     30      1.1  christos # if (defined __cplusplus \
     31      1.1  christos       && ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \
     32      1.1  christos           || (defined _MSC_VER && 1900 <= _MSC_VER)) \
     33      1.1  christos       && 0)
     34      1.1  christos     /* [[noreturn]] is not practically usable, because with it the syntax
     35      1.1  christos          extern _Noreturn void func (...);
     36      1.1  christos        would not be valid; such a declaration would only be valid with 'extern'
     37      1.1  christos        and '_Noreturn' swapped, or without the 'extern' keyword.  However, some
     38      1.1  christos        AIX system header files and several gnulib header files use precisely
     39      1.1  christos        this syntax with 'extern'.  */
     40      1.1  christos #  define _Noreturn [[noreturn]]
     41      1.1  christos # elif ((!defined __cplusplus || defined __clang__) \
     42  1.1.1.2  christos         && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \
     43  1.1.1.2  christos             || (!defined __STRICT_ANSI__ \
     44  1.1.1.2  christos                 && (_GL_GNUC_PREREQ (4, 7) \
     45  1.1.1.2  christos                     || (defined __apple_build_version__ \
     46  1.1.1.2  christos                         ? 6000000 <= __apple_build_version__ \
     47  1.1.1.2  christos                         : 3 < __clang_major__ + (5 <= __clang_minor__))))))
     48      1.1  christos    /* _Noreturn works as-is.  */
     49  1.1.1.2  christos # elif _GL_GNUC_PREREQ (2, 8) || defined __clang__ || 0x5110 <= __SUNPRO_C
     50      1.1  christos #  define _Noreturn __attribute__ ((__noreturn__))
     51      1.1  christos # elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0)
     52      1.1  christos #  define _Noreturn __declspec (noreturn)
     53      1.1  christos # else
     54      1.1  christos #  define _Noreturn
     55      1.1  christos # endif
     56      1.1  christos #endif
     57      1.1  christos ])
     58      1.1  christos   AH_VERBATIM([isoc99_inline],
     59      1.1  christos [/* Work around a bug in Apple GCC 4.0.1 build 5465: In C99 mode, it supports
     60      1.1  christos    the ISO C 99 semantics of 'extern inline' (unlike the GNU C semantics of
     61      1.1  christos    earlier versions), but does not display it by setting __GNUC_STDC_INLINE__.
     62      1.1  christos    __APPLE__ && __MACH__ test for Mac OS X.
     63      1.1  christos    __APPLE_CC__ tests for the Apple compiler and its version.
     64      1.1  christos    __STDC_VERSION__ tests for the C99 mode.  */
     65      1.1  christos #if defined __APPLE__ && defined __MACH__ && __APPLE_CC__ >= 5465 && !defined __cplusplus && __STDC_VERSION__ >= 199901L && !defined __GNUC_STDC_INLINE__
     66      1.1  christos # define __GNUC_STDC_INLINE__ 1
     67      1.1  christos #endif])
     68      1.1  christos   AH_VERBATIM([attribute],
     69      1.1  christos [/* Attributes.  */
     70  1.1.1.2  christos #if (defined __has_attribute \
     71  1.1.1.2  christos      && (!defined __clang_minor__ \
     72  1.1.1.2  christos          || (defined __apple_build_version__ \
     73  1.1.1.2  christos              ? 6000000 <= __apple_build_version__ \
     74  1.1.1.2  christos              : 3 < __clang_major__ + (5 <= __clang_minor__))))
     75      1.1  christos # define _GL_HAS_ATTRIBUTE(attr) __has_attribute (__##attr##__)
     76      1.1  christos #else
     77      1.1  christos # define _GL_HAS_ATTRIBUTE(attr) _GL_ATTR_##attr
     78      1.1  christos # define _GL_ATTR_alloc_size _GL_GNUC_PREREQ (4, 3)
     79      1.1  christos # define _GL_ATTR_always_inline _GL_GNUC_PREREQ (3, 2)
     80      1.1  christos # define _GL_ATTR_artificial _GL_GNUC_PREREQ (4, 3)
     81      1.1  christos # define _GL_ATTR_cold _GL_GNUC_PREREQ (4, 3)
     82      1.1  christos # define _GL_ATTR_const _GL_GNUC_PREREQ (2, 95)
     83      1.1  christos # define _GL_ATTR_deprecated _GL_GNUC_PREREQ (3, 1)
     84  1.1.1.2  christos # define _GL_ATTR_diagnose_if 0
     85      1.1  christos # define _GL_ATTR_error _GL_GNUC_PREREQ (4, 3)
     86      1.1  christos # define _GL_ATTR_externally_visible _GL_GNUC_PREREQ (4, 1)
     87      1.1  christos # define _GL_ATTR_fallthrough _GL_GNUC_PREREQ (7, 0)
     88      1.1  christos # define _GL_ATTR_format _GL_GNUC_PREREQ (2, 7)
     89      1.1  christos # define _GL_ATTR_leaf _GL_GNUC_PREREQ (4, 6)
     90  1.1.1.2  christos # define _GL_ATTR_malloc _GL_GNUC_PREREQ (3, 0)
     91      1.1  christos # ifdef _ICC
     92      1.1  christos #  define _GL_ATTR_may_alias 0
     93      1.1  christos # else
     94      1.1  christos #  define _GL_ATTR_may_alias _GL_GNUC_PREREQ (3, 3)
     95      1.1  christos # endif
     96      1.1  christos # define _GL_ATTR_noinline _GL_GNUC_PREREQ (3, 1)
     97      1.1  christos # define _GL_ATTR_nonnull _GL_GNUC_PREREQ (3, 3)
     98      1.1  christos # define _GL_ATTR_nonstring _GL_GNUC_PREREQ (8, 0)
     99      1.1  christos # define _GL_ATTR_nothrow _GL_GNUC_PREREQ (3, 3)
    100      1.1  christos # define _GL_ATTR_packed _GL_GNUC_PREREQ (2, 7)
    101      1.1  christos # define _GL_ATTR_pure _GL_GNUC_PREREQ (2, 96)
    102      1.1  christos # define _GL_ATTR_returns_nonnull _GL_GNUC_PREREQ (4, 9)
    103      1.1  christos # define _GL_ATTR_sentinel _GL_GNUC_PREREQ (4, 0)
    104      1.1  christos # define _GL_ATTR_unused _GL_GNUC_PREREQ (2, 7)
    105      1.1  christos # define _GL_ATTR_warn_unused_result _GL_GNUC_PREREQ (3, 4)
    106      1.1  christos #endif
    107      1.1  christos 
    108  1.1.1.2  christos #ifdef __has_c_attribute
    109  1.1.1.2  christos # if ((defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) <= 201710 \
    110  1.1.1.2  christos       && _GL_GNUC_PREREQ (4, 6))
    111  1.1.1.2  christos #  pragma GCC diagnostic ignored "-Wpedantic"
    112  1.1.1.2  christos # endif
    113  1.1.1.2  christos # define _GL_HAS_C_ATTRIBUTE(attr) __has_c_attribute (__##attr##__)
    114  1.1.1.2  christos #else
    115  1.1.1.2  christos # define _GL_HAS_C_ATTRIBUTE(attr) 0
    116  1.1.1.2  christos #endif
    117  1.1.1.2  christos 
    118      1.1  christos ]dnl There is no _GL_ATTRIBUTE_ALIGNED; use stdalign's _Alignas instead.
    119      1.1  christos [
    120  1.1.1.2  christos /* _GL_ATTRIBUTE_ALLOC_SIZE ((N)) declares that the Nth argument of the function
    121  1.1.1.2  christos    is the size of the returned memory block.
    122  1.1.1.2  christos    _GL_ATTRIBUTE_ALLOC_SIZE ((M, N)) declares that the Mth argument multiplied
    123  1.1.1.2  christos    by the Nth argument of the function is the size of the returned memory block.
    124  1.1.1.2  christos  */
    125  1.1.1.2  christos /* Applies to: function, pointer to function, function types.  */
    126      1.1  christos #if _GL_HAS_ATTRIBUTE (alloc_size)
    127      1.1  christos # define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args))
    128      1.1  christos #else
    129      1.1  christos # define _GL_ATTRIBUTE_ALLOC_SIZE(args)
    130      1.1  christos #endif
    131      1.1  christos 
    132  1.1.1.2  christos /* _GL_ATTRIBUTE_ALWAYS_INLINE tells that the compiler should always inline the
    133  1.1.1.2  christos    function and report an error if it cannot do so.  */
    134  1.1.1.2  christos /* Applies to: function.  */
    135      1.1  christos #if _GL_HAS_ATTRIBUTE (always_inline)
    136      1.1  christos # define _GL_ATTRIBUTE_ALWAYS_INLINE __attribute__ ((__always_inline__))
    137      1.1  christos #else
    138      1.1  christos # define _GL_ATTRIBUTE_ALWAYS_INLINE
    139      1.1  christos #endif
    140      1.1  christos 
    141  1.1.1.2  christos /* _GL_ATTRIBUTE_ARTIFICIAL declares that the function is not important to show
    142  1.1.1.2  christos     in stack traces when debugging.  The compiler should omit the function from
    143  1.1.1.2  christos     stack traces.  */
    144  1.1.1.2  christos /* Applies to: function.  */
    145      1.1  christos #if _GL_HAS_ATTRIBUTE (artificial)
    146      1.1  christos # define _GL_ATTRIBUTE_ARTIFICIAL __attribute__ ((__artificial__))
    147      1.1  christos #else
    148      1.1  christos # define _GL_ATTRIBUTE_ARTIFICIAL
    149      1.1  christos #endif
    150      1.1  christos 
    151  1.1.1.2  christos /* _GL_ATTRIBUTE_COLD declares that the function is rarely executed.  */
    152  1.1.1.2  christos /* Applies to: functions.  */
    153      1.1  christos /* Avoid __attribute__ ((cold)) on MinGW; see thread starting at
    154  1.1.1.2  christos    <https://lists.gnu.org/r/emacs-devel/2019-04/msg01152.html>.
    155  1.1.1.2  christos    Also, Oracle Studio 12.6 requires 'cold' not '__cold__'.  */
    156      1.1  christos #if _GL_HAS_ATTRIBUTE (cold) && !defined __MINGW32__
    157  1.1.1.2  christos # ifndef __SUNPRO_C
    158  1.1.1.2  christos #  define _GL_ATTRIBUTE_COLD __attribute__ ((__cold__))
    159  1.1.1.2  christos # else
    160  1.1.1.2  christos #  define _GL_ATTRIBUTE_COLD __attribute__ ((cold))
    161  1.1.1.2  christos # endif
    162      1.1  christos #else
    163      1.1  christos # define _GL_ATTRIBUTE_COLD
    164      1.1  christos #endif
    165      1.1  christos 
    166  1.1.1.2  christos /* _GL_ATTRIBUTE_CONST declares that it is OK for a compiler to omit duplicate
    167  1.1.1.2  christos    calls to the function with the same arguments.
    168  1.1.1.2  christos    This attribute is safe for a function that neither depends on nor affects
    169  1.1.1.2  christos    observable state, and always returns exactly once - e.g., does not loop
    170  1.1.1.2  christos    forever, and does not call longjmp.
    171  1.1.1.2  christos    (This attribute is stricter than _GL_ATTRIBUTE_PURE.)  */
    172  1.1.1.2  christos /* Applies to: functions.  */
    173      1.1  christos #if _GL_HAS_ATTRIBUTE (const)
    174      1.1  christos # define _GL_ATTRIBUTE_CONST __attribute__ ((__const__))
    175      1.1  christos #else
    176      1.1  christos # define _GL_ATTRIBUTE_CONST
    177      1.1  christos #endif
    178      1.1  christos 
    179  1.1.1.2  christos /* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
    180  1.1.1.2  christos    that can be freed by passing them as the Ith argument to the
    181  1.1.1.2  christos    function F.
    182  1.1.1.2  christos    _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that
    183  1.1.1.2  christos    can be freed via 'free'; it can be used only after declaring 'free'.  */
    184  1.1.1.2  christos /* Applies to: functions.  Cannot be used on inline functions.  */
    185  1.1.1.2  christos /* Disable on Solaris to avoid GDB PR build/29791.  */
    186  1.1.1.2  christos #if _GL_GNUC_PREREQ (11, 0) && !(defined(__sun__) && defined(__svr4__))
    187  1.1.1.2  christos # define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
    188  1.1.1.2  christos #else
    189  1.1.1.2  christos # define _GL_ATTRIBUTE_DEALLOC(f, i)
    190  1.1.1.2  christos #endif
    191  1.1.1.2  christos /* If gnulib's <string.h> or <wchar.h> has already defined this macro, continue
    192  1.1.1.2  christos    to use this earlier definition, since <stdlib.h> may not have been included
    193  1.1.1.2  christos    yet.  */
    194  1.1.1.2  christos #ifndef _GL_ATTRIBUTE_DEALLOC_FREE
    195  1.1.1.2  christos # define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (free, 1)
    196  1.1.1.2  christos #endif
    197  1.1.1.2  christos 
    198  1.1.1.2  christos /* _GL_ATTRIBUTE_DEPRECATED: Declares that an entity is deprecated.
    199  1.1.1.2  christos    The compiler may warn if the entity is used.  */
    200  1.1.1.2  christos /* Applies to:
    201  1.1.1.2  christos      - function, variable,
    202  1.1.1.2  christos      - struct, union, struct/union member,
    203  1.1.1.2  christos      - enumeration, enumeration item,
    204  1.1.1.2  christos      - typedef,
    205  1.1.1.2  christos    in C++ also: namespace, class, template specialization.  */
    206  1.1.1.2  christos #if _GL_HAS_C_ATTRIBUTE (deprecated)
    207      1.1  christos # define _GL_ATTRIBUTE_DEPRECATED [[__deprecated__]]
    208      1.1  christos #elif _GL_HAS_ATTRIBUTE (deprecated)
    209      1.1  christos # define _GL_ATTRIBUTE_DEPRECATED __attribute__ ((__deprecated__))
    210      1.1  christos #else
    211      1.1  christos # define _GL_ATTRIBUTE_DEPRECATED
    212      1.1  christos #endif
    213      1.1  christos 
    214  1.1.1.2  christos /* _GL_ATTRIBUTE_ERROR(msg) requests an error if a function is called and
    215  1.1.1.2  christos    the function call is not optimized away.
    216  1.1.1.2  christos    _GL_ATTRIBUTE_WARNING(msg) requests a warning if a function is called and
    217  1.1.1.2  christos    the function call is not optimized away.  */
    218  1.1.1.2  christos /* Applies to: functions.  */
    219      1.1  christos #if _GL_HAS_ATTRIBUTE (error)
    220      1.1  christos # define _GL_ATTRIBUTE_ERROR(msg) __attribute__ ((__error__ (msg)))
    221      1.1  christos # define _GL_ATTRIBUTE_WARNING(msg) __attribute__ ((__warning__ (msg)))
    222  1.1.1.2  christos #elif _GL_HAS_ATTRIBUTE (diagnose_if)
    223  1.1.1.2  christos # define _GL_ATTRIBUTE_ERROR(msg) __attribute__ ((__diagnose_if__ (1, msg, "error")))
    224  1.1.1.2  christos # define _GL_ATTRIBUTE_WARNING(msg) __attribute__ ((__diagnose_if__ (1, msg, "warning")))
    225      1.1  christos #else
    226      1.1  christos # define _GL_ATTRIBUTE_ERROR(msg)
    227      1.1  christos # define _GL_ATTRIBUTE_WARNING(msg)
    228      1.1  christos #endif
    229      1.1  christos 
    230  1.1.1.2  christos /* _GL_ATTRIBUTE_EXTERNALLY_VISIBLE declares that the entity should remain
    231  1.1.1.2  christos    visible to debuggers etc., even with '-fwhole-program'.  */
    232  1.1.1.2  christos /* Applies to: functions, variables.  */
    233      1.1  christos #if _GL_HAS_ATTRIBUTE (externally_visible)
    234      1.1  christos # define _GL_ATTRIBUTE_EXTERNALLY_VISIBLE __attribute__ ((externally_visible))
    235      1.1  christos #else
    236      1.1  christos # define _GL_ATTRIBUTE_EXTERNALLY_VISIBLE
    237      1.1  christos #endif
    238      1.1  christos 
    239  1.1.1.2  christos /* _GL_ATTRIBUTE_FALLTHROUGH declares that it is not a programming mistake if
    240  1.1.1.2  christos    the control flow falls through to the immediately following 'case' or
    241  1.1.1.2  christos    'default' label.  The compiler should not warn in this case.  */
    242  1.1.1.2  christos /* Applies to: Empty statement (;), inside a 'switch' statement.  */
    243  1.1.1.2  christos /* Always expands to something.  */
    244  1.1.1.2  christos #if _GL_HAS_C_ATTRIBUTE (fallthrough)
    245      1.1  christos # define _GL_ATTRIBUTE_FALLTHROUGH [[__fallthrough__]]
    246      1.1  christos #elif _GL_HAS_ATTRIBUTE (fallthrough)
    247      1.1  christos # define _GL_ATTRIBUTE_FALLTHROUGH __attribute__ ((__fallthrough__))
    248      1.1  christos #else
    249      1.1  christos # define _GL_ATTRIBUTE_FALLTHROUGH ((void) 0)
    250      1.1  christos #endif
    251      1.1  christos 
    252  1.1.1.2  christos /* _GL_ATTRIBUTE_FORMAT ((ARCHETYPE, STRING-INDEX, FIRST-TO-CHECK))
    253  1.1.1.2  christos    declares that the STRING-INDEXth function argument is a format string of
    254  1.1.1.2  christos    style ARCHETYPE, which is one of:
    255  1.1.1.2  christos      printf, gnu_printf
    256  1.1.1.2  christos      scanf, gnu_scanf,
    257  1.1.1.2  christos      strftime, gnu_strftime,
    258  1.1.1.2  christos      strfmon,
    259  1.1.1.2  christos    or the same thing prefixed and suffixed with '__'.
    260  1.1.1.2  christos    If FIRST-TO-CHECK is not 0, arguments starting at FIRST-TO_CHECK
    261  1.1.1.2  christos    are suitable for the format string.  */
    262  1.1.1.2  christos /* Applies to: functions.  */
    263      1.1  christos #if _GL_HAS_ATTRIBUTE (format)
    264      1.1  christos # define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
    265      1.1  christos #else
    266      1.1  christos # define _GL_ATTRIBUTE_FORMAT(spec)
    267      1.1  christos #endif
    268      1.1  christos 
    269  1.1.1.2  christos /* _GL_ATTRIBUTE_LEAF declares that if the function is called from some other
    270  1.1.1.2  christos    compilation unit, it executes code from that unit only by return or by
    271  1.1.1.2  christos    exception handling.  This declaration lets the compiler optimize that unit
    272  1.1.1.2  christos    more aggressively.  */
    273  1.1.1.2  christos /* Applies to: functions.  */
    274      1.1  christos #if _GL_HAS_ATTRIBUTE (leaf)
    275      1.1  christos # define _GL_ATTRIBUTE_LEAF __attribute__ ((__leaf__))
    276      1.1  christos #else
    277      1.1  christos # define _GL_ATTRIBUTE_LEAF
    278      1.1  christos #endif
    279      1.1  christos 
    280  1.1.1.2  christos /* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
    281  1.1.1.2  christos    allocated memory.  */
    282  1.1.1.2  christos /* Applies to: functions.  */
    283  1.1.1.2  christos #if _GL_HAS_ATTRIBUTE (malloc)
    284  1.1.1.2  christos # define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
    285  1.1.1.2  christos #else
    286  1.1.1.2  christos # define _GL_ATTRIBUTE_MALLOC
    287  1.1.1.2  christos #endif
    288  1.1.1.2  christos 
    289  1.1.1.2  christos /* _GL_ATTRIBUTE_MAY_ALIAS declares that pointers to the type may point to the
    290  1.1.1.2  christos    same storage as pointers to other types.  Thus this declaration disables
    291  1.1.1.2  christos    strict aliasing optimization.  */
    292  1.1.1.2  christos /* Applies to: types.  */
    293  1.1.1.2  christos /* Oracle Studio 12.6 mishandles may_alias despite __has_attribute OK.  */
    294  1.1.1.2  christos #if _GL_HAS_ATTRIBUTE (may_alias) && !defined __SUNPRO_C
    295      1.1  christos # define _GL_ATTRIBUTE_MAY_ALIAS __attribute__ ((__may_alias__))
    296      1.1  christos #else
    297      1.1  christos # define _GL_ATTRIBUTE_MAY_ALIAS
    298      1.1  christos #endif
    299      1.1  christos 
    300  1.1.1.2  christos /* _GL_ATTRIBUTE_MAYBE_UNUSED declares that it is not a programming mistake if
    301  1.1.1.2  christos    the entity is not used.  The compiler should not warn if the entity is not
    302  1.1.1.2  christos    used.  */
    303  1.1.1.2  christos /* Applies to:
    304  1.1.1.2  christos      - function, variable,
    305  1.1.1.2  christos      - struct, union, struct/union member,
    306  1.1.1.2  christos      - enumeration, enumeration item,
    307  1.1.1.2  christos      - typedef,
    308  1.1.1.2  christos    in C++ also: class.  */
    309  1.1.1.2  christos /* In C++ and C2x, this is spelled [[__maybe_unused__]].
    310  1.1.1.2  christos    GCC's syntax is __attribute__ ((__unused__)).
    311  1.1.1.2  christos    clang supports both syntaxes.  */
    312  1.1.1.2  christos #if _GL_HAS_C_ATTRIBUTE (maybe_unused)
    313      1.1  christos # define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]]
    314      1.1  christos #else
    315  1.1.1.2  christos # define _GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_UNUSED
    316      1.1  christos #endif
    317  1.1.1.2  christos /* Alternative spelling of this macro, for convenience.  */
    318      1.1  christos #define _GL_UNUSED _GL_ATTRIBUTE_MAYBE_UNUSED
    319  1.1.1.2  christos /* Earlier spellings of this macro.  */
    320      1.1  christos #define _UNUSED_PARAMETER_ _GL_ATTRIBUTE_MAYBE_UNUSED
    321      1.1  christos 
    322  1.1.1.2  christos /* _GL_ATTRIBUTE_NODISCARD declares that the caller of the function should not
    323  1.1.1.2  christos    discard the return value.  The compiler may warn if the caller does not use
    324  1.1.1.2  christos    the return value, unless the caller uses something like ignore_value.  */
    325  1.1.1.2  christos /* Applies to: function, enumeration, class.  */
    326  1.1.1.2  christos #if _GL_HAS_C_ATTRIBUTE (nodiscard)
    327      1.1  christos # define _GL_ATTRIBUTE_NODISCARD [[__nodiscard__]]
    328      1.1  christos #elif _GL_HAS_ATTRIBUTE (warn_unused_result)
    329      1.1  christos # define _GL_ATTRIBUTE_NODISCARD __attribute__ ((__warn_unused_result__))
    330      1.1  christos #else
    331      1.1  christos # define _GL_ATTRIBUTE_NODISCARD
    332      1.1  christos #endif
    333      1.1  christos 
    334  1.1.1.2  christos /* _GL_ATTRIBUTE_NOINLINE tells that the compiler should not inline the
    335  1.1.1.2  christos    function.  */
    336  1.1.1.2  christos /* Applies to: functions.  */
    337      1.1  christos #if _GL_HAS_ATTRIBUTE (noinline)
    338      1.1  christos # define _GL_ATTRIBUTE_NOINLINE __attribute__ ((__noinline__))
    339      1.1  christos #else
    340      1.1  christos # define _GL_ATTRIBUTE_NOINLINE
    341      1.1  christos #endif
    342      1.1  christos 
    343  1.1.1.2  christos /* _GL_ATTRIBUTE_NONNULL ((N1, N2,...)) declares that the arguments N1, N2,...
    344  1.1.1.2  christos    must not be NULL.
    345  1.1.1.2  christos    _GL_ATTRIBUTE_NONNULL () declares that all pointer arguments must not be
    346  1.1.1.2  christos    null.  */
    347  1.1.1.2  christos /* Applies to: functions.  */
    348      1.1  christos #if _GL_HAS_ATTRIBUTE (nonnull)
    349      1.1  christos # define _GL_ATTRIBUTE_NONNULL(args) __attribute__ ((__nonnull__ args))
    350      1.1  christos #else
    351      1.1  christos # define _GL_ATTRIBUTE_NONNULL(args)
    352      1.1  christos #endif
    353      1.1  christos 
    354  1.1.1.2  christos /* _GL_ATTRIBUTE_NONSTRING declares that the contents of a character array is
    355  1.1.1.2  christos    not meant to be NUL-terminated.  */
    356  1.1.1.2  christos /* Applies to: struct/union members and variables that are arrays of element
    357  1.1.1.2  christos    type '[[un]signed] char'.  */
    358      1.1  christos #if _GL_HAS_ATTRIBUTE (nonstring)
    359      1.1  christos # define _GL_ATTRIBUTE_NONSTRING __attribute__ ((__nonstring__))
    360      1.1  christos #else
    361      1.1  christos # define _GL_ATTRIBUTE_NONSTRING
    362      1.1  christos #endif
    363      1.1  christos 
    364      1.1  christos /* There is no _GL_ATTRIBUTE_NORETURN; use _Noreturn instead.  */
    365      1.1  christos 
    366  1.1.1.2  christos /* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions.
    367  1.1.1.2  christos  */
    368  1.1.1.2  christos /* Applies to: functions.  */
    369      1.1  christos #if _GL_HAS_ATTRIBUTE (nothrow) && !defined __cplusplus
    370      1.1  christos # define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__))
    371      1.1  christos #else
    372      1.1  christos # define _GL_ATTRIBUTE_NOTHROW
    373      1.1  christos #endif
    374      1.1  christos 
    375  1.1.1.2  christos /* _GL_ATTRIBUTE_PACKED declares:
    376  1.1.1.2  christos    For struct members: The member has the smallest possible alignment.
    377  1.1.1.2  christos    For struct, union, class: All members have the smallest possible alignment,
    378  1.1.1.2  christos    minimizing the memory required.  */
    379  1.1.1.2  christos /* Applies to: struct members, struct, union,
    380  1.1.1.2  christos    in C++ also: class.  */
    381      1.1  christos #if _GL_HAS_ATTRIBUTE (packed)
    382      1.1  christos # define _GL_ATTRIBUTE_PACKED __attribute__ ((__packed__))
    383      1.1  christos #else
    384      1.1  christos # define _GL_ATTRIBUTE_PACKED
    385      1.1  christos #endif
    386      1.1  christos 
    387  1.1.1.2  christos /* _GL_ATTRIBUTE_PURE declares that It is OK for a compiler to omit duplicate
    388  1.1.1.2  christos    calls to the function with the same arguments if observable state is not
    389  1.1.1.2  christos    changed between calls.
    390  1.1.1.2  christos    This attribute is safe for a function that does not affect
    391  1.1.1.2  christos    observable state, and always returns exactly once.
    392  1.1.1.2  christos    (This attribute is looser than _GL_ATTRIBUTE_CONST.)  */
    393  1.1.1.2  christos /* Applies to: functions.  */
    394      1.1  christos #if _GL_HAS_ATTRIBUTE (pure)
    395      1.1  christos # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
    396      1.1  christos #else
    397      1.1  christos # define _GL_ATTRIBUTE_PURE
    398      1.1  christos #endif
    399      1.1  christos 
    400  1.1.1.2  christos /* _GL_ATTRIBUTE_RETURNS_NONNULL declares that the function's return value is
    401  1.1.1.2  christos    a non-NULL pointer.  */
    402  1.1.1.2  christos /* Applies to: functions.  */
    403      1.1  christos #if _GL_HAS_ATTRIBUTE (returns_nonnull)
    404      1.1  christos # define _GL_ATTRIBUTE_RETURNS_NONNULL __attribute__ ((__returns_nonnull__))
    405      1.1  christos #else
    406      1.1  christos # define _GL_ATTRIBUTE_RETURNS_NONNULL
    407      1.1  christos #endif
    408      1.1  christos 
    409  1.1.1.2  christos /* _GL_ATTRIBUTE_SENTINEL(pos) declares that the variadic function expects a
    410  1.1.1.2  christos    trailing NULL argument.
    411  1.1.1.2  christos    _GL_ATTRIBUTE_SENTINEL () - The last argument is NULL (requires C99).
    412  1.1.1.2  christos    _GL_ATTRIBUTE_SENTINEL ((N)) - The (N+1)st argument from the end is NULL.  */
    413  1.1.1.2  christos /* Applies to: functions.  */
    414      1.1  christos #if _GL_HAS_ATTRIBUTE (sentinel)
    415      1.1  christos # define _GL_ATTRIBUTE_SENTINEL(pos) __attribute__ ((__sentinel__ pos))
    416      1.1  christos #else
    417      1.1  christos # define _GL_ATTRIBUTE_SENTINEL(pos)
    418      1.1  christos #endif
    419      1.1  christos 
    420  1.1.1.2  christos /* A helper macro.  Don't use it directly.  */
    421  1.1.1.2  christos #if _GL_HAS_ATTRIBUTE (unused)
    422  1.1.1.2  christos # define _GL_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
    423  1.1.1.2  christos #else
    424  1.1.1.2  christos # define _GL_ATTRIBUTE_UNUSED
    425  1.1.1.2  christos #endif
    426  1.1.1.2  christos 
    427      1.1  christos ]dnl There is no _GL_ATTRIBUTE_VISIBILITY; see m4/visibility.m4 instead.
    428      1.1  christos [
    429  1.1.1.2  christos /* _GL_UNUSED_LABEL; declares that it is not a programming mistake if the
    430  1.1.1.2  christos    immediately preceding label is not used.  The compiler should not warn
    431  1.1.1.2  christos    if the label is not used.  */
    432  1.1.1.2  christos /* Applies to: label (both in C and C++).  */
    433  1.1.1.2  christos /* Note that g++ < 4.5 does not support the '__attribute__ ((__unused__)) ;'
    434  1.1.1.2  christos    syntax.  But clang does.  */
    435  1.1.1.2  christos #if !(defined __cplusplus && !_GL_GNUC_PREREQ (4, 5)) || defined __clang__
    436  1.1.1.2  christos # define _GL_UNUSED_LABEL _GL_ATTRIBUTE_UNUSED
    437      1.1  christos #else
    438      1.1  christos # define _GL_UNUSED_LABEL
    439      1.1  christos #endif
    440      1.1  christos ])
    441      1.1  christos   AH_VERBATIM([async_safe],
    442      1.1  christos [/* The _GL_ASYNC_SAFE marker should be attached to functions that are
    443      1.1  christos    signal handlers (for signals other than SIGABRT, SIGPIPE) or can be
    444      1.1  christos    invoked from such signal handlers.  Such functions have some restrictions:
    445      1.1  christos      * All functions that it calls should be marked _GL_ASYNC_SAFE as well,
    446      1.1  christos        or should be listed as async-signal-safe in POSIX
    447      1.1  christos        <https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_04>
    448      1.1  christos        section 2.4.3.  Note that malloc(), sprintf(), and fwrite(), in
    449      1.1  christos        particular, are NOT async-signal-safe.
    450      1.1  christos      * All memory locations (variables and struct fields) that these functions
    451      1.1  christos        access must be marked 'volatile'.  This holds for both read and write
    452      1.1  christos        accesses.  Otherwise the compiler might optimize away stores to and
    453      1.1  christos        reads from such locations that occur in the program, depending on its
    454      1.1  christos        data flow analysis.  For example, when the program contains a loop
    455      1.1  christos        that is intended to inspect a variable set from within a signal handler
    456      1.1  christos            while (!signal_occurred)
    457      1.1  christos              ;
    458      1.1  christos        the compiler is allowed to transform this into an endless loop if the
    459      1.1  christos        variable 'signal_occurred' is not declared 'volatile'.
    460      1.1  christos    Additionally, recall that:
    461      1.1  christos      * A signal handler should not modify errno (except if it is a handler
    462      1.1  christos        for a fatal signal and ends by raising the same signal again, thus
    463      1.1  christos        provoking the termination of the process).  If it invokes a function
    464      1.1  christos        that may clobber errno, it needs to save and restore the value of
    465      1.1  christos        errno.  */
    466      1.1  christos #define _GL_ASYNC_SAFE
    467      1.1  christos ])
    468  1.1.1.2  christos   AH_VERBATIM([micro_optimizations],
    469  1.1.1.2  christos [/* _GL_CMP (n1, n2) performs a three-valued comparison on n1 vs. n2, where
    470  1.1.1.2  christos    n1 and n2 are expressions without side effects, that evaluate to real
    471  1.1.1.2  christos    numbers (excluding NaN).
    472  1.1.1.2  christos    It returns
    473  1.1.1.2  christos      1  if n1 > n2
    474  1.1.1.2  christos      0  if n1 == n2
    475  1.1.1.2  christos      -1 if n1 < n2
    476  1.1.1.2  christos    The nave code   (n1 > n2 ? 1 : n1 < n2 ? -1 : 0)  produces a conditional
    477  1.1.1.2  christos    jump with nearly all GCC versions up to GCC 10.
    478  1.1.1.2  christos    This variant     (n1 < n2 ? -1 : n1 > n2)  produces a conditional with many
    479  1.1.1.2  christos    GCC versions up to GCC 9.
    480  1.1.1.2  christos    The better code  (n1 > n2) - (n1 < n2)  from Hacker's Delight  2-9
    481  1.1.1.2  christos    avoids conditional jumps in all GCC versions >= 3.4.  */
    482  1.1.1.2  christos #define _GL_CMP(n1, n2) (((n1) > (n2)) - ((n1) < (n2)))
    483  1.1.1.2  christos ])
    484      1.1  christos   dnl Hint which direction to take regarding cross-compilation guesses:
    485      1.1  christos   dnl When a user installs a program on a platform they are not intimately
    486      1.1  christos   dnl familiar with, --enable-cross-guesses=conservative is the appropriate
    487      1.1  christos   dnl choice.  It implements the "If we don't know, assume the worst" principle.
    488      1.1  christos   dnl However, when an operating system developer (on a platform which is not
    489      1.1  christos   dnl yet known to gnulib) builds packages for their platform, they want to
    490      1.1  christos   dnl expose, not hide, possible platform bugs; in this case,
    491      1.1  christos   dnl --enable-cross-guesses=risky is the appropriate choice.
    492      1.1  christos   dnl Sets the variables
    493      1.1  christos   dnl gl_cross_guess_normal    (to be used when 'yes' is good and 'no' is bad),
    494      1.1  christos   dnl gl_cross_guess_inverted  (to be used when 'no' is good and 'yes' is bad).
    495      1.1  christos   AC_ARG_ENABLE([cross-guesses],
    496      1.1  christos     [AS_HELP_STRING([--enable-cross-guesses={conservative|risky}],
    497      1.1  christos        [specify policy for cross-compilation guesses])],
    498      1.1  christos     [if test "x$enableval" != xconservative && test "x$enableval" != xrisky; then
    499      1.1  christos        AC_MSG_WARN([invalid argument supplied to --enable-cross-guesses])
    500      1.1  christos        enableval=conservative
    501      1.1  christos      fi
    502      1.1  christos      gl_cross_guesses="$enableval"],
    503      1.1  christos     [gl_cross_guesses=conservative])
    504      1.1  christos   if test $gl_cross_guesses = risky; then
    505      1.1  christos     gl_cross_guess_normal="guessing yes"
    506      1.1  christos     gl_cross_guess_inverted="guessing no"
    507      1.1  christos   else
    508      1.1  christos     gl_cross_guess_normal="guessing no"
    509      1.1  christos     gl_cross_guess_inverted="guessing yes"
    510      1.1  christos   fi
    511      1.1  christos   dnl Preparation for running test programs:
    512      1.1  christos   dnl Tell glibc to write diagnostics from -D_FORTIFY_SOURCE=2 to stderr, not
    513      1.1  christos   dnl to /dev/tty, so they can be redirected to log files.  Such diagnostics
    514      1.1  christos   dnl arise e.g., in the macros gl_PRINTF_DIRECTIVE_N, gl_SNPRINTF_DIRECTIVE_N.
    515      1.1  christos   LIBC_FATAL_STDERR_=1
    516      1.1  christos   export LIBC_FATAL_STDERR_
    517      1.1  christos ])
    518      1.1  christos 
    519  1.1.1.2  christos # gl_MODULE_INDICATOR_INIT_VARIABLE([variablename])
    520  1.1.1.2  christos # gl_MODULE_INDICATOR_INIT_VARIABLE([variablename], [initialvalue])
    521  1.1.1.2  christos # initializes the shell variable that indicates the presence of the given module
    522  1.1.1.2  christos # as a C preprocessor expression.
    523  1.1.1.2  christos AC_DEFUN([gl_MODULE_INDICATOR_INIT_VARIABLE],
    524  1.1.1.2  christos [
    525  1.1.1.2  christos   GL_MODULE_INDICATOR_PREFIX[]_[$1]=m4_if([$2], , [0], [$2])
    526  1.1.1.2  christos   AC_SUBST(GL_MODULE_INDICATOR_PREFIX[]_[$1])
    527  1.1.1.2  christos ])
    528  1.1.1.2  christos 
    529      1.1  christos # gl_MODULE_INDICATOR_CONDITION
    530      1.1  christos # expands to a C preprocessor expression that evaluates to 1 or 0, depending
    531      1.1  christos # whether a gnulib module that has been requested shall be considered present
    532      1.1  christos # or not.
    533      1.1  christos m4_define([gl_MODULE_INDICATOR_CONDITION], [1])
    534      1.1  christos 
    535      1.1  christos # gl_MODULE_INDICATOR_SET_VARIABLE([modulename])
    536      1.1  christos # sets the shell variable that indicates the presence of the given module to
    537      1.1  christos # a C preprocessor expression that will evaluate to 1.
    538      1.1  christos AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE],
    539      1.1  christos [
    540      1.1  christos   gl_MODULE_INDICATOR_SET_VARIABLE_AUX(
    541  1.1.1.2  christos     [GL_MODULE_INDICATOR_PREFIX[]_GNULIB_[]m4_translit([[$1]],
    542  1.1.1.2  christos                                                        [abcdefghijklmnopqrstuvwxyz./-],
    543  1.1.1.2  christos                                                        [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])],
    544      1.1  christos     [gl_MODULE_INDICATOR_CONDITION])
    545      1.1  christos ])
    546      1.1  christos 
    547      1.1  christos # gl_MODULE_INDICATOR_SET_VARIABLE_AUX([variable])
    548      1.1  christos # modifies the shell variable to include the gl_MODULE_INDICATOR_CONDITION.
    549      1.1  christos # The shell variable's value is a C preprocessor expression that evaluates
    550      1.1  christos # to 0 or 1.
    551      1.1  christos AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE_AUX],
    552      1.1  christos [
    553      1.1  christos   m4_if(m4_defn([gl_MODULE_INDICATOR_CONDITION]), [1],
    554      1.1  christos     [
    555      1.1  christos      dnl Simplify the expression VALUE || 1 to 1.
    556      1.1  christos      $1=1
    557      1.1  christos     ],
    558      1.1  christos     [gl_MODULE_INDICATOR_SET_VARIABLE_AUX_OR([$1],
    559      1.1  christos                                              [gl_MODULE_INDICATOR_CONDITION])])
    560      1.1  christos ])
    561      1.1  christos 
    562      1.1  christos # gl_MODULE_INDICATOR_SET_VARIABLE_AUX_OR([variable], [condition])
    563      1.1  christos # modifies the shell variable to include the given condition.  The shell
    564      1.1  christos # variable's value is a C preprocessor expression that evaluates to 0 or 1.
    565      1.1  christos AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE_AUX_OR],
    566      1.1  christos [
    567      1.1  christos   dnl Simplify the expression 1 || CONDITION to 1.
    568      1.1  christos   if test "$[]$1" != 1; then
    569      1.1  christos     dnl Simplify the expression 0 || CONDITION to CONDITION.
    570      1.1  christos     if test "$[]$1" = 0; then
    571      1.1  christos       $1=$2
    572      1.1  christos     else
    573      1.1  christos       $1="($[]$1 || $2)"
    574      1.1  christos     fi
    575      1.1  christos   fi
    576      1.1  christos ])
    577      1.1  christos 
    578      1.1  christos # gl_MODULE_INDICATOR([modulename])
    579      1.1  christos # defines a C macro indicating the presence of the given module
    580      1.1  christos # in a location where it can be used.
    581      1.1  christos #                                             |  Value  |   Value   |
    582      1.1  christos #                                             | in lib/ | in tests/ |
    583      1.1  christos # --------------------------------------------+---------+-----------+
    584      1.1  christos # Module present among main modules:          |    1    |     1     |
    585      1.1  christos # --------------------------------------------+---------+-----------+
    586      1.1  christos # Module present among tests-related modules: |    0    |     1     |
    587      1.1  christos # --------------------------------------------+---------+-----------+
    588      1.1  christos # Module not present at all:                  |    0    |     0     |
    589      1.1  christos # --------------------------------------------+---------+-----------+
    590      1.1  christos AC_DEFUN([gl_MODULE_INDICATOR],
    591      1.1  christos [
    592      1.1  christos   AC_DEFINE_UNQUOTED([GNULIB_]m4_translit([[$1]],
    593      1.1  christos       [abcdefghijklmnopqrstuvwxyz./-],
    594      1.1  christos       [ABCDEFGHIJKLMNOPQRSTUVWXYZ___]),
    595      1.1  christos     [gl_MODULE_INDICATOR_CONDITION],
    596      1.1  christos     [Define to a C preprocessor expression that evaluates to 1 or 0,
    597      1.1  christos      depending whether the gnulib module $1 shall be considered present.])
    598      1.1  christos ])
    599      1.1  christos 
    600      1.1  christos # gl_MODULE_INDICATOR_FOR_TESTS([modulename])
    601      1.1  christos # defines a C macro indicating the presence of the given module
    602      1.1  christos # in lib or tests. This is useful to determine whether the module
    603      1.1  christos # should be tested.
    604      1.1  christos #                                             |  Value  |   Value   |
    605      1.1  christos #                                             | in lib/ | in tests/ |
    606      1.1  christos # --------------------------------------------+---------+-----------+
    607      1.1  christos # Module present among main modules:          |    1    |     1     |
    608      1.1  christos # --------------------------------------------+---------+-----------+
    609      1.1  christos # Module present among tests-related modules: |    1    |     1     |
    610      1.1  christos # --------------------------------------------+---------+-----------+
    611      1.1  christos # Module not present at all:                  |    0    |     0     |
    612      1.1  christos # --------------------------------------------+---------+-----------+
    613      1.1  christos AC_DEFUN([gl_MODULE_INDICATOR_FOR_TESTS],
    614      1.1  christos [
    615      1.1  christos   AC_DEFINE([GNULIB_TEST_]m4_translit([[$1]],
    616      1.1  christos       [abcdefghijklmnopqrstuvwxyz./-],
    617      1.1  christos       [ABCDEFGHIJKLMNOPQRSTUVWXYZ___]), [1],
    618      1.1  christos     [Define to 1 when the gnulib module $1 should be tested.])
    619      1.1  christos ])
    620      1.1  christos 
    621      1.1  christos # gl_ASSERT_NO_GNULIB_POSIXCHECK
    622      1.1  christos # asserts that there will never be a need to #define GNULIB_POSIXCHECK.
    623      1.1  christos # and thereby enables an optimization of configure and config.h.
    624      1.1  christos # Used by Emacs.
    625      1.1  christos AC_DEFUN([gl_ASSERT_NO_GNULIB_POSIXCHECK],
    626      1.1  christos [
    627      1.1  christos   dnl Override gl_WARN_ON_USE_PREPARE.
    628      1.1  christos   dnl But hide this definition from 'aclocal'.
    629      1.1  christos   AC_DEFUN([gl_W][ARN_ON_USE_PREPARE], [])
    630      1.1  christos ])
    631      1.1  christos 
    632      1.1  christos # gl_ASSERT_NO_GNULIB_TESTS
    633      1.1  christos # asserts that there will be no gnulib tests in the scope of the configure.ac
    634      1.1  christos # and thereby enables an optimization of config.h.
    635      1.1  christos # Used by Emacs.
    636      1.1  christos AC_DEFUN([gl_ASSERT_NO_GNULIB_TESTS],
    637      1.1  christos [
    638      1.1  christos   dnl Override gl_MODULE_INDICATOR_FOR_TESTS.
    639      1.1  christos   AC_DEFUN([gl_MODULE_INDICATOR_FOR_TESTS], [])
    640      1.1  christos ])
    641      1.1  christos 
    642      1.1  christos # Test whether <features.h> exists.
    643      1.1  christos # Set HAVE_FEATURES_H.
    644      1.1  christos AC_DEFUN([gl_FEATURES_H],
    645      1.1  christos [
    646      1.1  christos   AC_CHECK_HEADERS_ONCE([features.h])
    647      1.1  christos   if test $ac_cv_header_features_h = yes; then
    648      1.1  christos     HAVE_FEATURES_H=1
    649      1.1  christos   else
    650      1.1  christos     HAVE_FEATURES_H=0
    651      1.1  christos   fi
    652      1.1  christos   AC_SUBST([HAVE_FEATURES_H])
    653      1.1  christos ])
    654      1.1  christos 
    655      1.1  christos # gl_PROG_CC_C99
    656      1.1  christos # Modifies the value of the shell variable CC in an attempt to make $CC
    657      1.1  christos # understand ISO C99 source code.
    658      1.1  christos AC_DEFUN([gl_PROG_CC_C99],
    659      1.1  christos [
    660  1.1.1.2  christos   dnl Just use AC_PROG_CC_C99.
    661  1.1.1.2  christos   dnl When AC_PROG_CC_C99 and AC_PROG_CC_STDC are used together, the substituted
    662  1.1.1.2  christos   dnl value of CC will contain the C99 enabling options twice. But this is only
    663  1.1.1.2  christos   dnl a cosmetic problem.
    664  1.1.1.2  christos   dnl With Autoconf >= 2.70, use AC_PROG_CC since it implies AC_PROG_CC_C99;
    665  1.1.1.2  christos   dnl this avoids a "warning: The macro `AC_PROG_CC_C99' is obsolete."
    666  1.1.1.2  christos   m4_version_prereq([2.70],
    667  1.1.1.2  christos     [AC_REQUIRE([AC_PROG_CC])],
    668  1.1.1.2  christos     [AC_REQUIRE([AC_PROG_CC_C99])])
    669      1.1  christos ])
    670      1.1  christos 
    671      1.1  christos # gl_PROG_AR_RANLIB
    672      1.1  christos # Determines the values for AR, ARFLAGS, RANLIB that fit with the compiler.
    673      1.1  christos # The user can set the variables AR, ARFLAGS, RANLIB if he wants to override
    674      1.1  christos # the values.
    675      1.1  christos AC_DEFUN([gl_PROG_AR_RANLIB],
    676      1.1  christos [
    677      1.1  christos   dnl Minix 3 comes with two toolchains: The Amsterdam Compiler Kit compiler
    678      1.1  christos   dnl as "cc", and GCC as "gcc". They have different object file formats and
    679      1.1  christos   dnl library formats. In particular, the GNU binutils programs ar and ranlib
    680      1.1  christos   dnl produce libraries that work only with gcc, not with cc.
    681      1.1  christos   AC_REQUIRE([AC_PROG_CC])
    682      1.1  christos   dnl The '][' hides this use from 'aclocal'.
    683      1.1  christos   AC_BEFORE([$0], [A][M_PROG_AR])
    684      1.1  christos   AC_CACHE_CHECK([for Minix Amsterdam compiler], [gl_cv_c_amsterdam_compiler],
    685      1.1  christos     [
    686      1.1  christos       AC_EGREP_CPP([Amsterdam],
    687      1.1  christos         [
    688      1.1  christos #ifdef __ACK__
    689      1.1  christos Amsterdam
    690      1.1  christos #endif
    691      1.1  christos         ],
    692      1.1  christos         [gl_cv_c_amsterdam_compiler=yes],
    693      1.1  christos         [gl_cv_c_amsterdam_compiler=no])
    694      1.1  christos     ])
    695      1.1  christos 
    696      1.1  christos   dnl Don't compete with AM_PROG_AR's decision about AR/ARFLAGS if we are not
    697      1.1  christos   dnl building with __ACK__.
    698      1.1  christos   if test $gl_cv_c_amsterdam_compiler = yes; then
    699      1.1  christos     if test -z "$AR"; then
    700      1.1  christos       AR='cc -c.a'
    701      1.1  christos     fi
    702      1.1  christos     if test -z "$ARFLAGS"; then
    703      1.1  christos       ARFLAGS='-o'
    704      1.1  christos     fi
    705      1.1  christos   else
    706      1.1  christos     dnl AM_PROG_AR was added in automake v1.11.2.  AM_PROG_AR does not AC_SUBST
    707      1.1  christos     dnl ARFLAGS variable (it is filed into Makefile.in directly by automake
    708      1.1  christos     dnl script on-demand, if not specified by ./configure of course).
    709      1.1  christos     dnl Don't AC_REQUIRE the AM_PROG_AR otherwise the code for __ACK__ above
    710      1.1  christos     dnl will be ignored.  Also, pay attention to call AM_PROG_AR in else block
    711      1.1  christos     dnl because AM_PROG_AR is written so it could re-set AR variable even for
    712      1.1  christos     dnl __ACK__.  It may seem like its easier to avoid calling the macro here,
    713      1.1  christos     dnl but we need to AC_SUBST both AR/ARFLAGS (thus those must have some good
    714      1.1  christos     dnl default value and automake should usually know them).
    715      1.1  christos     dnl
    716      1.1  christos     dnl The '][' hides this use from 'aclocal'.
    717      1.1  christos     m4_ifdef([A][M_PROG_AR], [A][M_PROG_AR], [:])
    718      1.1  christos   fi
    719      1.1  christos 
    720      1.1  christos   dnl In case the code above has not helped with setting AR/ARFLAGS, use
    721      1.1  christos   dnl Automake-documented default values for AR and ARFLAGS, but prefer
    722      1.1  christos   dnl ${host}-ar over ar (useful for cross-compiling).
    723      1.1  christos   AC_CHECK_TOOL([AR], [ar], [ar])
    724      1.1  christos   if test -z "$ARFLAGS"; then
    725      1.1  christos     ARFLAGS='cr'
    726      1.1  christos   fi
    727      1.1  christos 
    728      1.1  christos   AC_SUBST([AR])
    729      1.1  christos   AC_SUBST([ARFLAGS])
    730      1.1  christos   if test -z "$RANLIB"; then
    731      1.1  christos     if test $gl_cv_c_amsterdam_compiler = yes; then
    732      1.1  christos       RANLIB=':'
    733      1.1  christos     else
    734      1.1  christos       dnl Use the ranlib program if it is available.
    735      1.1  christos       AC_PROG_RANLIB
    736      1.1  christos     fi
    737      1.1  christos   fi
    738      1.1  christos   AC_SUBST([RANLIB])
    739      1.1  christos ])
    740      1.1  christos 
    741      1.1  christos # AC_C_RESTRICT
    742  1.1.1.2  christos # This definition is copied from post-2.70 Autoconf and overrides the
    743  1.1.1.2  christos # AC_C_RESTRICT macro from autoconf 2.60..2.70.
    744  1.1.1.2  christos m4_version_prereq([2.70.1], [], [
    745      1.1  christos AC_DEFUN([AC_C_RESTRICT],
    746      1.1  christos [AC_CACHE_CHECK([for C/C++ restrict keyword], [ac_cv_c_restrict],
    747      1.1  christos   [ac_cv_c_restrict=no
    748  1.1.1.2  christos    # Put '__restrict__' first, to avoid problems with glibc and non-GCC; see:
    749  1.1.1.2  christos    # https://lists.gnu.org/archive/html/bug-autoconf/2016-02/msg00006.html
    750  1.1.1.2  christos    # Put 'restrict' last, because C++ lacks it.
    751  1.1.1.2  christos    for ac_kw in __restrict__ __restrict _Restrict restrict; do
    752      1.1  christos      AC_COMPILE_IFELSE(
    753      1.1  christos       [AC_LANG_PROGRAM(
    754      1.1  christos          [[typedef int *int_ptr;
    755      1.1  christos            int foo (int_ptr $ac_kw ip) { return ip[0]; }
    756      1.1  christos            int bar (int [$ac_kw]); /* Catch GCC bug 14050.  */
    757      1.1  christos            int bar (int ip[$ac_kw]) { return ip[0]; }
    758      1.1  christos          ]],
    759      1.1  christos          [[int s[1];
    760      1.1  christos            int *$ac_kw t = s;
    761      1.1  christos            t[0] = 0;
    762      1.1  christos            return foo (t) + bar (t);
    763      1.1  christos          ]])],
    764      1.1  christos       [ac_cv_c_restrict=$ac_kw])
    765      1.1  christos      test "$ac_cv_c_restrict" != no && break
    766      1.1  christos    done
    767      1.1  christos   ])
    768      1.1  christos  AH_VERBATIM([restrict],
    769      1.1  christos [/* Define to the equivalent of the C99 'restrict' keyword, or to
    770      1.1  christos    nothing if this is not supported.  Do not define if restrict is
    771  1.1.1.2  christos    supported only directly.  */
    772      1.1  christos #undef restrict
    773      1.1  christos /* Work around a bug in older versions of Sun C++, which did not
    774      1.1  christos    #define __restrict__ or support _Restrict or __restrict__
    775      1.1  christos    even though the corresponding Sun C compiler ended up with
    776      1.1  christos    "#define restrict _Restrict" or "#define restrict __restrict__"
    777      1.1  christos    in the previous line.  This workaround can be removed once
    778      1.1  christos    we assume Oracle Developer Studio 12.5 (2016) or later.  */
    779      1.1  christos #if defined __SUNPRO_CC && !defined __RESTRICT && !defined __restrict__
    780      1.1  christos # define _Restrict
    781      1.1  christos # define __restrict__
    782      1.1  christos #endif])
    783      1.1  christos  case $ac_cv_c_restrict in
    784      1.1  christos    restrict) ;;
    785      1.1  christos    no) AC_DEFINE([restrict], []) ;;
    786      1.1  christos    *)  AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;;
    787      1.1  christos  esac
    788      1.1  christos ])# AC_C_RESTRICT
    789  1.1.1.2  christos ])
    790      1.1  christos 
    791      1.1  christos # gl_BIGENDIAN
    792      1.1  christos # is like AC_C_BIGENDIAN, except that it can be AC_REQUIREd.
    793      1.1  christos # Note that AC_REQUIRE([AC_C_BIGENDIAN]) does not work reliably because some
    794      1.1  christos # macros invoke AC_C_BIGENDIAN with arguments.
    795      1.1  christos AC_DEFUN([gl_BIGENDIAN],
    796      1.1  christos [
    797      1.1  christos   AC_C_BIGENDIAN
    798      1.1  christos ])
    799      1.1  christos 
    800  1.1.1.2  christos # A temporary file descriptor.
    801  1.1.1.2  christos # Must be less than 10, because dash 0.5.8 does not support redirections
    802  1.1.1.2  christos # with multi-digit file descriptors.
    803  1.1.1.2  christos m4_define([GL_TMP_FD], 9)
    804  1.1.1.2  christos 
    805  1.1.1.2  christos # gl_SILENT(command)
    806  1.1.1.2  christos # executes command, but without the normal configure output.
    807  1.1.1.2  christos # This is useful when you want to invoke AC_CACHE_CHECK (or AC_CHECK_FUNC etc.)
    808  1.1.1.2  christos # inside another AC_CACHE_CHECK.
    809  1.1.1.2  christos AC_DEFUN([gl_SILENT],
    810  1.1.1.2  christos [
    811  1.1.1.2  christos   exec GL_TMP_FD>&AS_MESSAGE_FD AS_MESSAGE_FD>/dev/null
    812  1.1.1.2  christos   $1
    813  1.1.1.2  christos   exec AS_MESSAGE_FD>&GL_TMP_FD GL_TMP_FD>&-
    814  1.1.1.2  christos ])
    815  1.1.1.2  christos 
    816      1.1  christos # gl_CACHE_VAL_SILENT(cache-id, command-to-set-it)
    817      1.1  christos # is like AC_CACHE_VAL(cache-id, command-to-set-it), except that it does not
    818      1.1  christos # output a spurious "(cached)" mark in the midst of other configure output.
    819      1.1  christos # This macro should be used instead of AC_CACHE_VAL when it is not surrounded
    820      1.1  christos # by an AC_MSG_CHECKING/AC_MSG_RESULT pair.
    821      1.1  christos AC_DEFUN([gl_CACHE_VAL_SILENT],
    822      1.1  christos [
    823  1.1.1.2  christos   gl_SILENT([
    824  1.1.1.2  christos     AC_CACHE_VAL([$1], [$2])
    825  1.1.1.2  christos   ])
    826  1.1.1.2  christos ])
    827  1.1.1.2  christos 
    828  1.1.1.2  christos # gl_CONDITIONAL(conditional, condition)
    829  1.1.1.2  christos # is like AM_CONDITIONAL(conditional, condition), except that it does not
    830  1.1.1.2  christos # produce an error
    831  1.1.1.2  christos #   configure: error: conditional "..." was never defined.
    832  1.1.1.2  christos #   Usually this means the macro was only invoked conditionally.
    833  1.1.1.2  christos # when only invoked conditionally. Instead, in that case, both the _TRUE
    834  1.1.1.2  christos # and the _FALSE case are disabled.
    835  1.1.1.2  christos AC_DEFUN([gl_CONDITIONAL],
    836  1.1.1.2  christos [
    837  1.1.1.2  christos   pushdef([AC_CONFIG_COMMANDS_PRE], [:])dnl
    838  1.1.1.2  christos   AM_CONDITIONAL([$1], [$2])
    839  1.1.1.2  christos   popdef([AC_CONFIG_COMMANDS_PRE])dnl
    840  1.1.1.2  christos   if test -z "${[$1]_TRUE}" && test -z "${[$1]_FALSE}"; then
    841  1.1.1.2  christos     [$1]_TRUE='#'
    842  1.1.1.2  christos     [$1]_FALSE='#'
    843  1.1.1.2  christos   fi
    844  1.1.1.2  christos ])
    845  1.1.1.2  christos 
    846  1.1.1.2  christos # gl_CC_ALLOW_WARNINGS
    847  1.1.1.2  christos # sets and substitutes a variable GL_CFLAG_ALLOW_WARNINGS, to a $(CC) option
    848  1.1.1.2  christos # that reverts a preceding '-Werror' option, if available.
    849  1.1.1.2  christos # This is expected to be '-Wno-error' on gcc, clang (except clang/MSVC), xlclang
    850  1.1.1.2  christos # and empty otherwise.
    851  1.1.1.2  christos AC_DEFUN([gl_CC_ALLOW_WARNINGS],
    852  1.1.1.2  christos [
    853  1.1.1.2  christos   AC_REQUIRE([AC_PROG_CC])
    854  1.1.1.2  christos   AC_CACHE_CHECK([for C compiler option to allow warnings],
    855  1.1.1.2  christos     [gl_cv_cc_wallow],
    856  1.1.1.2  christos     [rm -f conftest*
    857  1.1.1.2  christos      echo 'int dummy;' > conftest.c
    858  1.1.1.2  christos      AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -c conftest.c 2>conftest1.err]) >/dev/null
    859  1.1.1.2  christos      AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Wno-error -c conftest.c 2>conftest2.err]) >/dev/null
    860  1.1.1.2  christos      dnl Test the number of error output lines, because AIX xlc accepts the
    861  1.1.1.2  christos      dnl option '-Wno-error', just to produce a warning
    862  1.1.1.2  christos      dnl "Option -Wno-error was incorrectly specified. The option will be ignored."
    863  1.1.1.2  christos      dnl afterwards.
    864  1.1.1.2  christos      if test $? = 0 && test `wc -l < conftest1.err` = `wc -l < conftest2.err`; then
    865  1.1.1.2  christos        gl_cv_cc_wallow='-Wno-error'
    866  1.1.1.2  christos      else
    867  1.1.1.2  christos        gl_cv_cc_wallow=none
    868  1.1.1.2  christos      fi
    869  1.1.1.2  christos      rm -f conftest*
    870  1.1.1.2  christos     ])
    871  1.1.1.2  christos   case "$gl_cv_cc_wallow" in
    872  1.1.1.2  christos     none) GL_CFLAG_ALLOW_WARNINGS='' ;;
    873  1.1.1.2  christos     *)    GL_CFLAG_ALLOW_WARNINGS="$gl_cv_cc_wallow" ;;
    874  1.1.1.2  christos   esac
    875  1.1.1.2  christos   AC_SUBST([GL_CFLAG_ALLOW_WARNINGS])
    876      1.1  christos ])
    877      1.1  christos 
    878  1.1.1.2  christos # gl_CXX_ALLOW_WARNINGS
    879  1.1.1.2  christos # sets and substitutes a variable GL_CXXFLAG_ALLOW_WARNINGS, to a $(CC) option
    880  1.1.1.2  christos # that reverts a preceding '-Werror' option, if available.
    881  1.1.1.2  christos AC_DEFUN([gl_CXX_ALLOW_WARNINGS],
    882  1.1.1.2  christos [
    883  1.1.1.2  christos   dnl Requires AC_PROG_CXX or gl_PROG_ANSI_CXX.
    884  1.1.1.2  christos   if test -n "$CXX" && test "$CXX" != no; then
    885  1.1.1.2  christos     AC_CACHE_CHECK([for C++ compiler option to allow warnings],
    886  1.1.1.2  christos       [gl_cv_cxx_wallow],
    887  1.1.1.2  christos       [rm -f conftest*
    888  1.1.1.2  christos        echo 'int dummy;' > conftest.cc
    889  1.1.1.2  christos        AC_TRY_COMMAND([${CXX-c++} $CXXFLAGS $CPPFLAGS -c conftest.cc 2>conftest1.err]) >/dev/null
    890  1.1.1.2  christos        AC_TRY_COMMAND([${CXX-c++} $CXXFLAGS $CPPFLAGS -Wno-error -c conftest.cc 2>conftest2.err]) >/dev/null
    891  1.1.1.2  christos        dnl Test the number of error output lines, because AIX xlC accepts the
    892  1.1.1.2  christos        dnl option '-Wno-error', just to produce a warning
    893  1.1.1.2  christos        dnl "Option -Wno-error was incorrectly specified. The option will be ignored."
    894  1.1.1.2  christos        dnl afterwards.
    895  1.1.1.2  christos        if test $? = 0 && test `wc -l < conftest1.err` = `wc -l < conftest2.err`; then
    896  1.1.1.2  christos          gl_cv_cxx_wallow='-Wno-error'
    897  1.1.1.2  christos        else
    898  1.1.1.2  christos          gl_cv_cxx_wallow=none
    899  1.1.1.2  christos        fi
    900  1.1.1.2  christos        rm -f conftest*
    901  1.1.1.2  christos       ])
    902  1.1.1.2  christos     case "$gl_cv_cxx_wallow" in
    903  1.1.1.2  christos       none) GL_CXXFLAG_ALLOW_WARNINGS='' ;;
    904  1.1.1.2  christos       *)    GL_CXXFLAG_ALLOW_WARNINGS="$gl_cv_cxx_wallow" ;;
    905  1.1.1.2  christos     esac
    906  1.1.1.2  christos   else
    907  1.1.1.2  christos     GL_CXXFLAG_ALLOW_WARNINGS=''
    908  1.1.1.2  christos   fi
    909  1.1.1.2  christos   AC_SUBST([GL_CXXFLAG_ALLOW_WARNINGS])
    910  1.1.1.2  christos ])
    911  1.1.1.2  christos 
    912  1.1.1.2  christos # gl_CC_GNULIB_WARNINGS
    913  1.1.1.2  christos # sets and substitutes a variable GL_CFLAG_GNULIB_WARNINGS, to a $(CC) option
    914  1.1.1.2  christos # set that enables or disables warnings as suitable for the Gnulib coding style.
    915  1.1.1.2  christos AC_DEFUN([gl_CC_GNULIB_WARNINGS],
    916  1.1.1.2  christos [
    917  1.1.1.2  christos   AC_REQUIRE([gl_CC_ALLOW_WARNINGS])
    918  1.1.1.2  christos   dnl Assume that the compiler supports -Wno-* options only if it also supports
    919  1.1.1.2  christos   dnl -Wno-error.
    920  1.1.1.2  christos   GL_CFLAG_GNULIB_WARNINGS=''
    921  1.1.1.2  christos   if test -n "$GL_CFLAG_ALLOW_WARNINGS"; then
    922  1.1.1.2  christos     dnl Enable these warning options:
    923  1.1.1.2  christos     dnl
    924  1.1.1.2  christos     dnl                                       GCC             clang
    925  1.1.1.2  christos     dnl -Wno-cast-qual                        >= 3            >= 3.9
    926  1.1.1.2  christos     dnl -Wno-conversion                       >= 3            >= 3.9
    927  1.1.1.2  christos     dnl -Wno-float-conversion                 >= 4.9          >= 3.9
    928  1.1.1.2  christos     dnl -Wno-float-equal                      >= 3            >= 3.9
    929  1.1.1.2  christos     dnl -Wimplicit-fallthrough                >= 7            >= 3.9
    930  1.1.1.2  christos     dnl -Wno-pedantic                         >= 4.8          >= 3.9
    931  1.1.1.2  christos     dnl -Wno-sign-compare                     >= 3            >= 3.9
    932  1.1.1.2  christos     dnl -Wno-sign-conversion                  >= 4.3          >= 3.9
    933  1.1.1.2  christos     dnl -Wno-type-limits                      >= 4.3          >= 3.9
    934  1.1.1.2  christos     dnl -Wno-undef                            >= 3            >= 3.9
    935  1.1.1.2  christos     dnl -Wno-unsuffixed-float-constants       >= 4.5
    936  1.1.1.2  christos     dnl -Wno-unused-function                  >= 3            >= 3.9
    937  1.1.1.2  christos     dnl -Wno-unused-parameter                 >= 3            >= 3.9
    938  1.1.1.2  christos     dnl
    939  1.1.1.2  christos     cat > conftest.c <<\EOF
    940  1.1.1.2  christos       #if __GNUC__ >= 3 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
    941  1.1.1.2  christos       -Wno-cast-qual
    942  1.1.1.2  christos       -Wno-conversion
    943  1.1.1.2  christos       -Wno-float-equal
    944  1.1.1.2  christos       -Wno-sign-compare
    945  1.1.1.2  christos       -Wno-undef
    946  1.1.1.2  christos       -Wno-unused-function
    947  1.1.1.2  christos       -Wno-unused-parameter
    948  1.1.1.2  christos       #endif
    949  1.1.1.2  christos       #if __GNUC__ + (__GNUC_MINOR__ >= 9) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
    950  1.1.1.2  christos       -Wno-float-conversion
    951  1.1.1.2  christos       #endif
    952  1.1.1.2  christos       #if __GNUC__ >= 7 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
    953  1.1.1.2  christos       -Wimplicit-fallthrough
    954  1.1.1.2  christos       #endif
    955  1.1.1.2  christos       #if __GNUC__ + (__GNUC_MINOR__ >= 8) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
    956  1.1.1.2  christos       -Wno-pedantic
    957  1.1.1.2  christos       #endif
    958  1.1.1.2  christos       #if __GNUC__ + (__GNUC_MINOR__ >= 3) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
    959  1.1.1.2  christos       -Wno-sign-conversion
    960  1.1.1.2  christos       -Wno-type-limits
    961  1.1.1.2  christos       #endif
    962  1.1.1.2  christos       #if __GNUC__ + (__GNUC_MINOR__ >= 5) > 4
    963  1.1.1.2  christos       -Wno-unsuffixed-float-constants
    964  1.1.1.2  christos       #endif
    965  1.1.1.2  christos EOF
    966  1.1.1.2  christos     gl_command="$CC $CFLAGS $CPPFLAGS -E conftest.c > conftest.out"
    967  1.1.1.2  christos     if AC_TRY_EVAL([gl_command]); then
    968  1.1.1.2  christos       gl_options=`grep -v '#' conftest.out`
    969  1.1.1.2  christos       for word in $gl_options; do
    970  1.1.1.2  christos         GL_CFLAG_GNULIB_WARNINGS="$GL_CFLAG_GNULIB_WARNINGS $word"
    971  1.1.1.2  christos       done
    972  1.1.1.2  christos     fi
    973  1.1.1.2  christos     rm -f conftest.c conftest.out
    974  1.1.1.2  christos   fi
    975  1.1.1.2  christos   AC_SUBST([GL_CFLAG_GNULIB_WARNINGS])
    976  1.1.1.2  christos ])
    977  1.1.1.2  christos 
    978  1.1.1.2  christos dnl gl_CONDITIONAL_HEADER([foo.h])
    979  1.1.1.2  christos dnl takes a shell variable GL_GENERATE_FOO_H (with value true or false) as input
    980  1.1.1.2  christos dnl and produces
    981  1.1.1.2  christos dnl   - an AC_SUBSTed variable FOO_H that is either a file name or empty, based
    982  1.1.1.2  christos dnl     on whether GL_GENERATE_FOO_H is true or false,
    983  1.1.1.2  christos dnl   - an Automake conditional GL_GENERATE_FOO_H that evaluates to the value of
    984  1.1.1.2  christos dnl     the shell variable GL_GENERATE_FOO_H.
    985  1.1.1.2  christos AC_DEFUN([gl_CONDITIONAL_HEADER],
    986  1.1.1.2  christos [
    987  1.1.1.2  christos   m4_pushdef([gl_header_name], AS_TR_SH(m4_toupper($1)))
    988  1.1.1.2  christos   m4_pushdef([gl_generate_var], [GL_GENERATE_]AS_TR_SH(m4_toupper($1)))
    989  1.1.1.2  christos   m4_pushdef([gl_generate_cond], [GL_GENERATE_]AS_TR_SH(m4_toupper($1)))
    990  1.1.1.2  christos   case "$gl_generate_var" in
    991  1.1.1.2  christos     false) gl_header_name='' ;;
    992  1.1.1.2  christos     true)
    993  1.1.1.2  christos       dnl It is OK to use a .h file in lib/ from within tests/, but not vice
    994  1.1.1.2  christos       dnl versa.
    995  1.1.1.2  christos       if test -z "$gl_header_name"; then
    996  1.1.1.2  christos         gl_header_name="${gl_source_base_prefix}$1"
    997  1.1.1.2  christos       fi
    998  1.1.1.2  christos       ;;
    999  1.1.1.2  christos     *) echo "*** gl_generate_var is not set correctly" 1>&2; exit 1 ;;
   1000  1.1.1.2  christos   esac
   1001  1.1.1.2  christos   AC_SUBST(gl_header_name)
   1002  1.1.1.2  christos   gl_CONDITIONAL(gl_generate_cond, [$gl_generate_var])
   1003  1.1.1.2  christos   m4_popdef([gl_generate_cond])
   1004  1.1.1.2  christos   m4_popdef([gl_generate_var])
   1005  1.1.1.2  christos   m4_popdef([gl_header_name])
   1006  1.1.1.2  christos ])
   1007  1.1.1.2  christos 
   1008  1.1.1.2  christos dnl Expands to some code for use in .c programs that, on native Windows, defines
   1009  1.1.1.2  christos dnl the Microsoft deprecated alias function names to the underscore-prefixed
   1010  1.1.1.2  christos dnl actual function names. With this macro, these function names are available
   1011  1.1.1.2  christos dnl without linking with '-loldnames' and without generating warnings.
   1012  1.1.1.2  christos dnl Usage: Use it after all system header files are included.
   1013  1.1.1.2  christos dnl          #include <...>
   1014  1.1.1.2  christos dnl          #include <...>
   1015  1.1.1.2  christos dnl          ]GL_MDA_DEFINES[
   1016  1.1.1.2  christos dnl          ...
   1017  1.1.1.2  christos AC_DEFUN([GL_MDA_DEFINES],[
   1018  1.1.1.2  christos AC_REQUIRE([_GL_MDA_DEFINES])
   1019  1.1.1.2  christos [$gl_mda_defines]
   1020  1.1.1.2  christos ])
   1021  1.1.1.2  christos AC_DEFUN([_GL_MDA_DEFINES],
   1022  1.1.1.2  christos [gl_mda_defines='
   1023  1.1.1.2  christos #if defined _WIN32 && !defined __CYGWIN__
   1024  1.1.1.2  christos #define access    _access
   1025  1.1.1.2  christos #define chdir     _chdir
   1026  1.1.1.2  christos #define chmod     _chmod
   1027  1.1.1.2  christos #define close     _close
   1028  1.1.1.2  christos #define creat     _creat
   1029  1.1.1.2  christos #define dup       _dup
   1030  1.1.1.2  christos #define dup2      _dup2
   1031  1.1.1.2  christos #define ecvt      _ecvt
   1032  1.1.1.2  christos #define execl     _execl
   1033  1.1.1.2  christos #define execle    _execle
   1034  1.1.1.2  christos #define execlp    _execlp
   1035  1.1.1.2  christos #define execv     _execv
   1036  1.1.1.2  christos #define execve    _execve
   1037  1.1.1.2  christos #define execvp    _execvp
   1038  1.1.1.2  christos #define execvpe   _execvpe
   1039  1.1.1.2  christos #define fcloseall _fcloseall
   1040  1.1.1.2  christos #define fcvt      _fcvt
   1041  1.1.1.2  christos #define fdopen    _fdopen
   1042  1.1.1.2  christos #define fileno    _fileno
   1043  1.1.1.2  christos #define gcvt      _gcvt
   1044  1.1.1.2  christos #define getcwd    _getcwd
   1045  1.1.1.2  christos #define getpid    _getpid
   1046  1.1.1.2  christos #define getw      _getw
   1047  1.1.1.2  christos #define isatty    _isatty
   1048  1.1.1.2  christos #define j0        _j0
   1049  1.1.1.2  christos #define j1        _j1
   1050  1.1.1.2  christos #define jn        _jn
   1051  1.1.1.2  christos #define lfind     _lfind
   1052  1.1.1.2  christos #define lsearch   _lsearch
   1053  1.1.1.2  christos #define lseek     _lseek
   1054  1.1.1.2  christos #define memccpy   _memccpy
   1055  1.1.1.2  christos #define mkdir     _mkdir
   1056  1.1.1.2  christos #define mktemp    _mktemp
   1057  1.1.1.2  christos #define open      _open
   1058  1.1.1.2  christos #define putenv    _putenv
   1059  1.1.1.2  christos #define putw      _putw
   1060  1.1.1.2  christos #define read      _read
   1061  1.1.1.2  christos #define rmdir     _rmdir
   1062  1.1.1.2  christos #define strdup    _strdup
   1063  1.1.1.2  christos #define swab      _swab
   1064  1.1.1.2  christos #define tempnam   _tempnam
   1065  1.1.1.2  christos #define tzset     _tzset
   1066  1.1.1.2  christos #define umask     _umask
   1067  1.1.1.2  christos #define unlink    _unlink
   1068  1.1.1.2  christos #define utime     _utime
   1069  1.1.1.2  christos #define wcsdup    _wcsdup
   1070  1.1.1.2  christos #define write     _write
   1071  1.1.1.2  christos #define y0        _y0
   1072  1.1.1.2  christos #define y1        _y1
   1073  1.1.1.2  christos #define yn        _yn
   1074  1.1.1.2  christos #endif
   1075  1.1.1.2  christos '
   1076  1.1.1.2  christos ])
   1077