Blame m4/gnulib-common.m4

Packit Service 4684c1
# gnulib-common.m4 serial 50
Packit Service 4684c1
dnl Copyright (C) 2007-2020 Free Software Foundation, Inc.
Packit Service 4684c1
dnl This file is free software; the Free Software Foundation
Packit Service 4684c1
dnl gives unlimited permission to copy and/or distribute it,
Packit Service 4684c1
dnl with or without modifications, as long as this notice is preserved.
Packit Service 4684c1
Packit Service 4684c1
AC_PREREQ([2.62])
Packit Service 4684c1
Packit Service 4684c1
# gl_COMMON
Packit Service 4684c1
# is expanded unconditionally through gnulib-tool magic.
Packit Service 4684c1
AC_DEFUN([gl_COMMON], [
Packit Service 4684c1
  dnl Use AC_REQUIRE here, so that the code is expanded once only.
Packit Service 4684c1
  AC_REQUIRE([gl_00GNULIB])
Packit Service 4684c1
  AC_REQUIRE([gl_COMMON_BODY])
Packit Service 4684c1
  AC_REQUIRE([gl_ZZGNULIB])
Packit Service 4684c1
])
Packit Service 4684c1
AC_DEFUN([gl_COMMON_BODY], [
Packit Service 4684c1
  AH_VERBATIM([_GL_GNUC_PREREQ],
Packit Service 4684c1
[/* True if the compiler says it groks GNU C version MAJOR.MINOR.  */
Packit Service 4684c1
#if defined __GNUC__ && defined __GNUC_MINOR__
Packit Service 4684c1
# define _GL_GNUC_PREREQ(major, minor) \
Packit Service 4684c1
    ((major) < __GNUC__ + ((minor) <= __GNUC_MINOR__))
Packit Service 4684c1
#else
Packit Service 4684c1
# define _GL_GNUC_PREREQ(major, minor) 0
Packit Service 4684c1
#endif
Packit Service 4684c1
])
Packit Service 4684c1
  AH_VERBATIM([_Noreturn],
Packit Service 4684c1
[/* The _Noreturn keyword of C11.  */
Packit Service 4684c1
#ifndef _Noreturn
Packit Service 4684c1
# if (defined __cplusplus \
Packit Service 4684c1
      && ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \
Packit Service 4684c1
          || (defined _MSC_VER && 1900 <= _MSC_VER)) \
Packit Service 4684c1
      && 0)
Packit Service 4684c1
    /* [[noreturn]] is not practically usable, because with it the syntax
Packit Service 4684c1
         extern _Noreturn void func (...);
Packit Service 4684c1
       would not be valid; such a declaration would only be valid with 'extern'
Packit Service 4684c1
       and '_Noreturn' swapped, or without the 'extern' keyword.  However, some
Packit Service 4684c1
       AIX system header files and several gnulib header files use precisely
Packit Service 4684c1
       this syntax with 'extern'.  */
Packit Service 4684c1
#  define _Noreturn [[noreturn]]
Packit Service 4684c1
# elif ((!defined __cplusplus || defined __clang__) \
Packit Service 4684c1
        && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0)  \
Packit Service 4684c1
            || _GL_GNUC_PREREQ (4, 7) \
Packit Service 4684c1
            || (defined __apple_build_version__ \
Packit Service 4684c1
                ? 6000000 <= __apple_build_version__ \
Packit Service 4684c1
                : 3 < __clang_major__ + (5 <= __clang_minor__))))
Packit Service 4684c1
   /* _Noreturn works as-is.  */
Packit Service 4684c1
# elif _GL_GNUC_PREREQ (2, 8) || 0x5110 <= __SUNPRO_C
Packit Service 4684c1
#  define _Noreturn __attribute__ ((__noreturn__))
Packit Service 4684c1
# elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0)
Packit Service 4684c1
#  define _Noreturn __declspec (noreturn)
Packit Service 4684c1
# else
Packit Service 4684c1
#  define _Noreturn
Packit Service 4684c1
# endif
Packit Service 4684c1
#endif
Packit Service 4684c1
])
Packit Service 4684c1
  AH_VERBATIM([isoc99_inline],
Packit Service 4684c1
[/* Work around a bug in Apple GCC 4.0.1 build 5465: In C99 mode, it supports
Packit Service 4684c1
   the ISO C 99 semantics of 'extern inline' (unlike the GNU C semantics of
Packit Service 4684c1
   earlier versions), but does not display it by setting __GNUC_STDC_INLINE__.
Packit Service 4684c1
   __APPLE__ && __MACH__ test for Mac OS X.
Packit Service 4684c1
   __APPLE_CC__ tests for the Apple compiler and its version.
Packit Service 4684c1
   __STDC_VERSION__ tests for the C99 mode.  */
Packit Service 4684c1
#if defined __APPLE__ && defined __MACH__ && __APPLE_CC__ >= 5465 && !defined __cplusplus && __STDC_VERSION__ >= 199901L && !defined __GNUC_STDC_INLINE__
Packit Service 4684c1
# define __GNUC_STDC_INLINE__ 1
Packit Service 4684c1
#endif])
Packit Service 4684c1
  AH_VERBATIM([attribute],
Packit Service 4684c1
[/* Attributes.  */
Packit Service 4684c1
#ifdef __has_attribute
Packit Service 4684c1
# define _GL_HAS_ATTRIBUTE(attr) __has_attribute (__##attr##__)
Packit Service 4684c1
#else
Packit Service 4684c1
# define _GL_HAS_ATTRIBUTE(attr) _GL_ATTR_##attr
Packit Service 4684c1
# define _GL_ATTR_alloc_size _GL_GNUC_PREREQ (4, 3)
Packit Service 4684c1
# define _GL_ATTR_always_inline _GL_GNUC_PREREQ (3, 2)
Packit Service 4684c1
# define _GL_ATTR_artificial _GL_GNUC_PREREQ (4, 3)
Packit Service 4684c1
# define _GL_ATTR_cold _GL_GNUC_PREREQ (4, 3)
Packit Service 4684c1
# define _GL_ATTR_const _GL_GNUC_PREREQ (2, 95)
Packit Service 4684c1
# define _GL_ATTR_deprecated _GL_GNUC_PREREQ (3, 1)
Packit Service 4684c1
# define _GL_ATTR_error _GL_GNUC_PREREQ (4, 3)
Packit Service 4684c1
# define _GL_ATTR_externally_visible _GL_GNUC_PREREQ (4, 1)
Packit Service 4684c1
# define _GL_ATTR_fallthrough _GL_GNUC_PREREQ (7, 0)
Packit Service 4684c1
# define _GL_ATTR_format _GL_GNUC_PREREQ (2, 7)
Packit Service 4684c1
# define _GL_ATTR_leaf _GL_GNUC_PREREQ (4, 6)
Packit Service 4684c1
# ifdef _ICC
Packit Service 4684c1
#  define _GL_ATTR_may_alias 0
Packit Service 4684c1
# else
Packit Service 4684c1
#  define _GL_ATTR_may_alias _GL_GNUC_PREREQ (3, 3)
Packit Service 4684c1
# endif
Packit Service 4684c1
# define _GL_ATTR_malloc _GL_GNUC_PREREQ (3, 0)
Packit Service 4684c1
# define _GL_ATTR_noinline _GL_GNUC_PREREQ (3, 1)
Packit Service 4684c1
# define _GL_ATTR_nonnull _GL_GNUC_PREREQ (3, 3)
Packit Service 4684c1
# define _GL_ATTR_nonstring _GL_GNUC_PREREQ (8, 0)
Packit Service 4684c1
# define _GL_ATTR_nothrow _GL_GNUC_PREREQ (3, 3)
Packit Service 4684c1
# define _GL_ATTR_packed _GL_GNUC_PREREQ (2, 7)
Packit Service 4684c1
# define _GL_ATTR_pure _GL_GNUC_PREREQ (2, 96)
Packit Service 4684c1
# define _GL_ATTR_returns_nonnull _GL_GNUC_PREREQ (4, 9)
Packit Service 4684c1
# define _GL_ATTR_sentinel _GL_GNUC_PREREQ (4, 0)
Packit Service 4684c1
# define _GL_ATTR_unused _GL_GNUC_PREREQ (2, 7)
Packit Service 4684c1
# define _GL_ATTR_warn_unused_result _GL_GNUC_PREREQ (3, 4)
Packit Service 4684c1
#endif
Packit Service 4684c1
Packit Service 4684c1
]dnl There is no _GL_ATTRIBUTE_ALIGNED; use stdalign's _Alignas instead.
Packit Service 4684c1
[
Packit Service 4684c1
#if _GL_HAS_ATTRIBUTE (alloc_size)
Packit Service 4684c1
# define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args))
Packit Service 4684c1
#else
Packit Service 4684c1
# define _GL_ATTRIBUTE_ALLOC_SIZE(args)
Packit Service 4684c1
#endif
Packit Service 4684c1
Packit Service 4684c1
#if _GL_HAS_ATTRIBUTE (always_inline)
Packit Service 4684c1
# define _GL_ATTRIBUTE_ALWAYS_INLINE __attribute__ ((__always_inline__))
Packit Service 4684c1
#else
Packit Service 4684c1
# define _GL_ATTRIBUTE_ALWAYS_INLINE
Packit Service 4684c1
#endif
Packit Service 4684c1
Packit Service 4684c1
#if _GL_HAS_ATTRIBUTE (artificial)
Packit Service 4684c1
# define _GL_ATTRIBUTE_ARTIFICIAL __attribute__ ((__artificial__))
Packit Service 4684c1
#else
Packit Service 4684c1
# define _GL_ATTRIBUTE_ARTIFICIAL
Packit Service 4684c1
#endif
Packit Service 4684c1
Packit Service 4684c1
/* Avoid __attribute__ ((cold)) on MinGW; see thread starting at
Packit Service 4684c1
   <https://lists.gnu.org/r/emacs-devel/2019-04/msg01152.html>. */
Packit Service 4684c1
#if _GL_HAS_ATTRIBUTE (cold) && !defined __MINGW32__
Packit Service 4684c1
# define _GL_ATTRIBUTE_COLD __attribute__ ((__cold__))
Packit Service 4684c1
#else
Packit Service 4684c1
# define _GL_ATTRIBUTE_COLD
Packit Service 4684c1
#endif
Packit Service 4684c1
Packit Service 4684c1
#if _GL_HAS_ATTRIBUTE (const)
Packit Service 4684c1
# define _GL_ATTRIBUTE_CONST __attribute__ ((__const__))
Packit Service 4684c1
#else
Packit Service 4684c1
# define _GL_ATTRIBUTE_CONST
Packit Service 4684c1
#endif
Packit Service 4684c1
Packit Service 4684c1
#if 201710L < __STDC_VERSION__
Packit Service 4684c1
# define _GL_ATTRIBUTE_DEPRECATED [[__deprecated__]]
Packit Service 4684c1
#elif _GL_HAS_ATTRIBUTE (deprecated)
Packit Service 4684c1
# define _GL_ATTRIBUTE_DEPRECATED __attribute__ ((__deprecated__))
Packit Service 4684c1
#else
Packit Service 4684c1
# define _GL_ATTRIBUTE_DEPRECATED
Packit Service 4684c1
#endif
Packit Service 4684c1
Packit Service 4684c1
#if _GL_HAS_ATTRIBUTE (error)
Packit Service 4684c1
# define _GL_ATTRIBUTE_ERROR(msg) __attribute__ ((__error__ (msg)))
Packit Service 4684c1
# define _GL_ATTRIBUTE_WARNING(msg) __attribute__ ((__warning__ (msg)))
Packit Service 4684c1
#else
Packit Service 4684c1
# define _GL_ATTRIBUTE_ERROR(msg)
Packit Service 4684c1
# define _GL_ATTRIBUTE_WARNING(msg)
Packit Service 4684c1
#endif
Packit Service 4684c1
Packit Service 4684c1
#if _GL_HAS_ATTRIBUTE (externally_visible)
Packit Service 4684c1
# define _GL_ATTRIBUTE_EXTERNALLY_VISIBLE __attribute__ ((externally_visible))
Packit Service 4684c1
#else
Packit Service 4684c1
# define _GL_ATTRIBUTE_EXTERNALLY_VISIBLE
Packit Service 4684c1
#endif
Packit Service 4684c1
Packit Service 4684c1
/* FALLTHROUGH is special, because it always expands to something.  */
Packit Service 4684c1
#if 201710L < __STDC_VERSION__
Packit Service 4684c1
# define _GL_ATTRIBUTE_FALLTHROUGH [[__fallthrough__]]
Packit Service 4684c1
#elif _GL_HAS_ATTRIBUTE (fallthrough)
Packit Service 4684c1
# define _GL_ATTRIBUTE_FALLTHROUGH __attribute__ ((__fallthrough__))
Packit Service 4684c1
#else
Packit Service 4684c1
# define _GL_ATTRIBUTE_FALLTHROUGH ((void) 0)
Packit Service 4684c1
#endif
Packit Service 4684c1
Packit Service 4684c1
#if _GL_HAS_ATTRIBUTE (format)
Packit Service 4684c1
# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
Packit Service 4684c1
#else
Packit Service 4684c1
# define _GL_ATTRIBUTE_FORMAT(spec)
Packit Service 4684c1
#endif
Packit Service 4684c1
Packit Service 4684c1
#if _GL_HAS_ATTRIBUTE (leaf)
Packit Service 4684c1
# define _GL_ATTRIBUTE_LEAF __attribute__ ((__leaf__))
Packit Service 4684c1
#else
Packit Service 4684c1
# define _GL_ATTRIBUTE_LEAF
Packit Service 4684c1
#endif
Packit Service 4684c1
Packit Service 4684c1
#if _GL_HAS_ATTRIBUTE (may_alias)
Packit Service 4684c1
# define _GL_ATTRIBUTE_MAY_ALIAS __attribute__ ((__may_alias__))
Packit Service 4684c1
#else
Packit Service 4684c1
# define _GL_ATTRIBUTE_MAY_ALIAS
Packit Service 4684c1
#endif
Packit Service 4684c1
Packit Service 4684c1
#if 201710L < __STDC_VERSION__
Packit Service 4684c1
# define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]]
Packit Service 4684c1
#elif _GL_HAS_ATTRIBUTE (unused)
Packit Service 4684c1
# define _GL_ATTRIBUTE_MAYBE_UNUSED __attribute__ ((__unused__))
Packit Service 4684c1
#else
Packit Service 4684c1
# define _GL_ATTRIBUTE_MAYBE_UNUSED
Packit Service 4684c1
#endif
Packit Service 4684c1
/* Earlier spellings of this macro.  */
Packit Service 4684c1
#define _GL_UNUSED _GL_ATTRIBUTE_MAYBE_UNUSED
Packit Service 4684c1
#define _UNUSED_PARAMETER_ _GL_ATTRIBUTE_MAYBE_UNUSED
Packit Service 4684c1
Packit Service 4684c1
#if _GL_HAS_ATTRIBUTE (malloc)
Packit Service 4684c1
# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
Packit Service 4684c1
#else
Packit Service 4684c1
# define _GL_ATTRIBUTE_MALLOC
Packit Service 4684c1
#endif
Packit Service 4684c1
Packit Service 4684c1
#if 201710L < __STDC_VERSION__
Packit Service 4684c1
# define _GL_ATTRIBUTE_NODISCARD [[__nodiscard__]]
Packit Service 4684c1
#elif _GL_HAS_ATTRIBUTE (warn_unused_result)
Packit Service 4684c1
# define _GL_ATTRIBUTE_NODISCARD __attribute__ ((__warn_unused_result__))
Packit Service 4684c1
#else
Packit Service 4684c1
# define _GL_ATTRIBUTE_NODISCARD
Packit Service 4684c1
#endif
Packit Service 4684c1
Packit Service 4684c1
#if _GL_HAS_ATTRIBUTE (noinline)
Packit Service 4684c1
# define _GL_ATTRIBUTE_NOINLINE __attribute__ ((__noinline__))
Packit Service 4684c1
#else
Packit Service 4684c1
# define _GL_ATTRIBUTE_NOINLINE
Packit Service 4684c1
#endif
Packit Service 4684c1
Packit Service 4684c1
#if _GL_HAS_ATTRIBUTE (nonnull)
Packit Service 4684c1
# define _GL_ATTRIBUTE_NONNULL(args) __attribute__ ((__nonnull__ args))
Packit Service 4684c1
#else
Packit Service 4684c1
# define _GL_ATTRIBUTE_NONNULL(args)
Packit Service 4684c1
#endif
Packit Service 4684c1
Packit Service 4684c1
#if _GL_HAS_ATTRIBUTE (nonstring)
Packit Service 4684c1
# define _GL_ATTRIBUTE_NONSTRING __attribute__ ((__nonstring__))
Packit Service 4684c1
#else
Packit Service 4684c1
# define _GL_ATTRIBUTE_NONSTRING
Packit Service 4684c1
#endif
Packit Service 4684c1
Packit Service 4684c1
/* There is no _GL_ATTRIBUTE_NORETURN; use _Noreturn instead.  */
Packit Service 4684c1
Packit Service 4684c1
#if _GL_HAS_ATTRIBUTE (nothrow) && !defined __cplusplus
Packit Service 4684c1
# define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__))
Packit Service 4684c1
#else
Packit Service 4684c1
# define _GL_ATTRIBUTE_NOTHROW
Packit Service 4684c1
#endif
Packit Service 4684c1
Packit Service 4684c1
#if _GL_HAS_ATTRIBUTE (packed)
Packit Service 4684c1
# define _GL_ATTRIBUTE_PACKED __attribute__ ((__packed__))
Packit Service 4684c1
#else
Packit Service 4684c1
# define _GL_ATTRIBUTE_PACKED
Packit Service 4684c1
#endif
Packit Service 4684c1
Packit Service 4684c1
#if _GL_HAS_ATTRIBUTE (pure)
Packit Service 4684c1
# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
Packit Service 4684c1
#else
Packit Service 4684c1
# define _GL_ATTRIBUTE_PURE
Packit Service 4684c1
#endif
Packit Service 4684c1
Packit Service 4684c1
#if _GL_HAS_ATTRIBUTE (returns_nonnull)
Packit Service 4684c1
# define _GL_ATTRIBUTE_RETURNS_NONNULL __attribute__ ((__returns_nonnull__))
Packit Service 4684c1
#else
Packit Service 4684c1
# define _GL_ATTRIBUTE_RETURNS_NONNULL
Packit Service 4684c1
#endif
Packit Service 4684c1
Packit Service 4684c1
#if _GL_HAS_ATTRIBUTE (sentinel)
Packit Service 4684c1
# define _GL_ATTRIBUTE_SENTINEL(pos) __attribute__ ((__sentinel__ pos))
Packit Service 4684c1
#else
Packit Service 4684c1
# define _GL_ATTRIBUTE_SENTINEL(pos)
Packit Service 4684c1
#endif
Packit Service 4684c1
Packit Service 4684c1
]dnl There is no _GL_ATTRIBUTE_VISIBILITY; see m4/visibility.m4 instead.
Packit Service 4684c1
[
Packit Service 4684c1
/* To support C++ as well as C, use _GL_UNUSED_LABEL with trailing ';'.  */
Packit Service 4684c1
#if !defined __cplusplus || _GL_GNUC_PREREQ (4, 5)
Packit Service 4684c1
# define _GL_UNUSED_LABEL _GL_ATTRIBUTE_MAYBE_UNUSED
Packit Service 4684c1
#else
Packit Service 4684c1
# define _GL_UNUSED_LABEL
Packit Service 4684c1
#endif
Packit Service 4684c1
])
Packit Service 4684c1
  AH_VERBATIM([async_safe],
Packit Service 4684c1
[/* The _GL_ASYNC_SAFE marker should be attached to functions that are
Packit Service 4684c1
   signal handlers (for signals other than SIGABRT, SIGPIPE) or can be
Packit Service 4684c1
   invoked from such signal handlers.  Such functions have some restrictions:
Packit Service 4684c1
     * All functions that it calls should be marked _GL_ASYNC_SAFE as well,
Packit Service 4684c1
       or should be listed as async-signal-safe in POSIX
Packit Service 4684c1
       <https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_04>
Packit Service 4684c1
       section 2.4.3.  Note that malloc(), sprintf(), and fwrite(), in
Packit Service 4684c1
       particular, are NOT async-signal-safe.
Packit Service 4684c1
     * All memory locations (variables and struct fields) that these functions
Packit Service 4684c1
       access must be marked 'volatile'.  This holds for both read and write
Packit Service 4684c1
       accesses.  Otherwise the compiler might optimize away stores to and
Packit Service 4684c1
       reads from such locations that occur in the program, depending on its
Packit Service 4684c1
       data flow analysis.  For example, when the program contains a loop
Packit Service 4684c1
       that is intended to inspect a variable set from within a signal handler
Packit Service 4684c1
           while (!signal_occurred)
Packit Service 4684c1
             ;
Packit Service 4684c1
       the compiler is allowed to transform this into an endless loop if the
Packit Service 4684c1
       variable 'signal_occurred' is not declared 'volatile'.
Packit Service 4684c1
   Additionally, recall that:
Packit Service 4684c1
     * A signal handler should not modify errno (except if it is a handler
Packit Service 4684c1
       for a fatal signal and ends by raising the same signal again, thus
Packit Service 4684c1
       provoking the termination of the process).  If it invokes a function
Packit Service 4684c1
       that may clobber errno, it needs to save and restore the value of
Packit Service 4684c1
       errno.  */
Packit Service 4684c1
#define _GL_ASYNC_SAFE
Packit Service 4684c1
])
Packit Service 4684c1
  dnl Hint which direction to take regarding cross-compilation guesses:
Packit Service 4684c1
  dnl When a user installs a program on a platform they are not intimately
Packit Service 4684c1
  dnl familiar with, --enable-cross-guesses=conservative is the appropriate
Packit Service 4684c1
  dnl choice.  It implements the "If we don't know, assume the worst" principle.
Packit Service 4684c1
  dnl However, when an operating system developer (on a platform which is not
Packit Service 4684c1
  dnl yet known to gnulib) builds packages for their platform, they want to
Packit Service 4684c1
  dnl expose, not hide, possible platform bugs; in this case,
Packit Service 4684c1
  dnl --enable-cross-guesses=risky is the appropriate choice.
Packit Service 4684c1
  dnl Sets the variables
Packit Service 4684c1
  dnl gl_cross_guess_normal    (to be used when 'yes' is good and 'no' is bad),
Packit Service 4684c1
  dnl gl_cross_guess_inverted  (to be used when 'no' is good and 'yes' is bad).
Packit Service 4684c1
  AC_ARG_ENABLE([cross-guesses],
Packit Service 4684c1
    [AS_HELP_STRING([--enable-cross-guesses={conservative|risky}],
Packit Service 4684c1
       [specify policy for cross-compilation guesses])],
Packit Service 4684c1
    [if test "x$enableval" != xconservative && test "x$enableval" != xrisky; then
Packit Service 4684c1
       AC_MSG_WARN([invalid argument supplied to --enable-cross-guesses])
Packit Service 4684c1
       enableval=conservative
Packit Service 4684c1
     fi
Packit Service 4684c1
     gl_cross_guesses="$enableval"],
Packit Service 4684c1
    [gl_cross_guesses=conservative])
Packit Service 4684c1
  if test $gl_cross_guesses = risky; then
Packit Service 4684c1
    gl_cross_guess_normal="guessing yes"
Packit Service 4684c1
    gl_cross_guess_inverted="guessing no"
Packit Service 4684c1
  else
Packit Service 4684c1
    gl_cross_guess_normal="guessing no"
Packit Service 4684c1
    gl_cross_guess_inverted="guessing yes"
Packit Service 4684c1
  fi
Packit Service 4684c1
  dnl Preparation for running test programs:
Packit Service 4684c1
  dnl Tell glibc to write diagnostics from -D_FORTIFY_SOURCE=2 to stderr, not
Packit Service 4684c1
  dnl to /dev/tty, so they can be redirected to log files.  Such diagnostics
Packit Service 4684c1
  dnl arise e.g., in the macros gl_PRINTF_DIRECTIVE_N, gl_SNPRINTF_DIRECTIVE_N.
Packit Service 4684c1
  LIBC_FATAL_STDERR_=1
Packit Service 4684c1
  export LIBC_FATAL_STDERR_
Packit Service 4684c1
])
Packit Service 4684c1
Packit Service 4684c1
# gl_MODULE_INDICATOR_CONDITION
Packit Service 4684c1
# expands to a C preprocessor expression that evaluates to 1 or 0, depending
Packit Service 4684c1
# whether a gnulib module that has been requested shall be considered present
Packit Service 4684c1
# or not.
Packit Service 4684c1
m4_define([gl_MODULE_INDICATOR_CONDITION], [1])
Packit Service 4684c1
Packit Service 4684c1
# gl_MODULE_INDICATOR_SET_VARIABLE([modulename])
Packit Service 4684c1
# sets the shell variable that indicates the presence of the given module to
Packit Service 4684c1
# a C preprocessor expression that will evaluate to 1.
Packit Service 4684c1
AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE],
Packit Service 4684c1
[
Packit Service 4684c1
  gl_MODULE_INDICATOR_SET_VARIABLE_AUX(
Packit Service 4684c1
    [GNULIB_[]m4_translit([[$1]],
Packit Service 4684c1
                          [abcdefghijklmnopqrstuvwxyz./-],
Packit Service 4684c1
                          [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])],
Packit Service 4684c1
    [gl_MODULE_INDICATOR_CONDITION])
Packit Service 4684c1
])
Packit Service 4684c1
Packit Service 4684c1
# gl_MODULE_INDICATOR_SET_VARIABLE_AUX([variable])
Packit Service 4684c1
# modifies the shell variable to include the gl_MODULE_INDICATOR_CONDITION.
Packit Service 4684c1
# The shell variable's value is a C preprocessor expression that evaluates
Packit Service 4684c1
# to 0 or 1.
Packit Service 4684c1
AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE_AUX],
Packit Service 4684c1
[
Packit Service 4684c1
  m4_if(m4_defn([gl_MODULE_INDICATOR_CONDITION]), [1],
Packit Service 4684c1
    [
Packit Service 4684c1
     dnl Simplify the expression VALUE || 1 to 1.
Packit Service 4684c1
     $1=1
Packit Service 4684c1
    ],
Packit Service 4684c1
    [gl_MODULE_INDICATOR_SET_VARIABLE_AUX_OR([$1],
Packit Service 4684c1
                                             [gl_MODULE_INDICATOR_CONDITION])])
Packit Service 4684c1
])
Packit Service 4684c1
Packit Service 4684c1
# gl_MODULE_INDICATOR_SET_VARIABLE_AUX_OR([variable], [condition])
Packit Service 4684c1
# modifies the shell variable to include the given condition.  The shell
Packit Service 4684c1
# variable's value is a C preprocessor expression that evaluates to 0 or 1.
Packit Service 4684c1
AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE_AUX_OR],
Packit Service 4684c1
[
Packit Service 4684c1
  dnl Simplify the expression 1 || CONDITION to 1.
Packit Service 4684c1
  if test "$[]$1" != 1; then
Packit Service 4684c1
    dnl Simplify the expression 0 || CONDITION to CONDITION.
Packit Service 4684c1
    if test "$[]$1" = 0; then
Packit Service 4684c1
      $1=$2
Packit Service 4684c1
    else
Packit Service 4684c1
      $1="($[]$1 || $2)"
Packit Service 4684c1
    fi
Packit Service 4684c1
  fi
Packit Service 4684c1
])
Packit Service 4684c1
Packit Service 4684c1
# gl_MODULE_INDICATOR([modulename])
Packit Service 4684c1
# defines a C macro indicating the presence of the given module
Packit Service 4684c1
# in a location where it can be used.
Packit Service 4684c1
#                                             |  Value  |   Value   |
Packit Service 4684c1
#                                             | in lib/ | in tests/ |
Packit Service 4684c1
# --------------------------------------------+---------+-----------+
Packit Service 4684c1
# Module present among main modules:          |    1    |     1     |
Packit Service 4684c1
# --------------------------------------------+---------+-----------+
Packit Service 4684c1
# Module present among tests-related modules: |    0    |     1     |
Packit Service 4684c1
# --------------------------------------------+---------+-----------+
Packit Service 4684c1
# Module not present at all:                  |    0    |     0     |
Packit Service 4684c1
# --------------------------------------------+---------+-----------+
Packit Service 4684c1
AC_DEFUN([gl_MODULE_INDICATOR],
Packit Service 4684c1
[
Packit Service 4684c1
  AC_DEFINE_UNQUOTED([GNULIB_]m4_translit([[$1]],
Packit Service 4684c1
      [abcdefghijklmnopqrstuvwxyz./-],
Packit Service 4684c1
      [ABCDEFGHIJKLMNOPQRSTUVWXYZ___]),
Packit Service 4684c1
    [gl_MODULE_INDICATOR_CONDITION],
Packit Service 4684c1
    [Define to a C preprocessor expression that evaluates to 1 or 0,
Packit Service 4684c1
     depending whether the gnulib module $1 shall be considered present.])
Packit Service 4684c1
])
Packit Service 4684c1
Packit Service 4684c1
# gl_MODULE_INDICATOR_FOR_TESTS([modulename])
Packit Service 4684c1
# defines a C macro indicating the presence of the given module
Packit Service 4684c1
# in lib or tests. This is useful to determine whether the module
Packit Service 4684c1
# should be tested.
Packit Service 4684c1
#                                             |  Value  |   Value   |
Packit Service 4684c1
#                                             | in lib/ | in tests/ |
Packit Service 4684c1
# --------------------------------------------+---------+-----------+
Packit Service 4684c1
# Module present among main modules:          |    1    |     1     |
Packit Service 4684c1
# --------------------------------------------+---------+-----------+
Packit Service 4684c1
# Module present among tests-related modules: |    1    |     1     |
Packit Service 4684c1
# --------------------------------------------+---------+-----------+
Packit Service 4684c1
# Module not present at all:                  |    0    |     0     |
Packit Service 4684c1
# --------------------------------------------+---------+-----------+
Packit Service 4684c1
AC_DEFUN([gl_MODULE_INDICATOR_FOR_TESTS],
Packit Service 4684c1
[
Packit Service 4684c1
  AC_DEFINE([GNULIB_TEST_]m4_translit([[$1]],
Packit Service 4684c1
      [abcdefghijklmnopqrstuvwxyz./-],
Packit Service 4684c1
      [ABCDEFGHIJKLMNOPQRSTUVWXYZ___]), [1],
Packit Service 4684c1
    [Define to 1 when the gnulib module $1 should be tested.])
Packit Service 4684c1
])
Packit Service 4684c1
Packit Service 4684c1
# gl_ASSERT_NO_GNULIB_POSIXCHECK
Packit Service 4684c1
# asserts that there will never be a need to #define GNULIB_POSIXCHECK.
Packit Service 4684c1
# and thereby enables an optimization of configure and config.h.
Packit Service 4684c1
# Used by Emacs.
Packit Service 4684c1
AC_DEFUN([gl_ASSERT_NO_GNULIB_POSIXCHECK],
Packit Service 4684c1
[
Packit Service 4684c1
  dnl Override gl_WARN_ON_USE_PREPARE.
Packit Service 4684c1
  dnl But hide this definition from 'aclocal'.
Packit Service 4684c1
  AC_DEFUN([gl_W][ARN_ON_USE_PREPARE], [])
Packit Service 4684c1
])
Packit Service 4684c1
Packit Service 4684c1
# gl_ASSERT_NO_GNULIB_TESTS
Packit Service 4684c1
# asserts that there will be no gnulib tests in the scope of the configure.ac
Packit Service 4684c1
# and thereby enables an optimization of config.h.
Packit Service 4684c1
# Used by Emacs.
Packit Service 4684c1
AC_DEFUN([gl_ASSERT_NO_GNULIB_TESTS],
Packit Service 4684c1
[
Packit Service 4684c1
  dnl Override gl_MODULE_INDICATOR_FOR_TESTS.
Packit Service 4684c1
  AC_DEFUN([gl_MODULE_INDICATOR_FOR_TESTS], [])
Packit Service 4684c1
])
Packit Service 4684c1
Packit Service 4684c1
# Test whether <features.h> exists.
Packit Service 4684c1
# Set HAVE_FEATURES_H.
Packit Service 4684c1
AC_DEFUN([gl_FEATURES_H],
Packit Service 4684c1
[
Packit Service 4684c1
  AC_CHECK_HEADERS_ONCE([features.h])
Packit Service 4684c1
  if test $ac_cv_header_features_h = yes; then
Packit Service 4684c1
    HAVE_FEATURES_H=1
Packit Service 4684c1
  else
Packit Service 4684c1
    HAVE_FEATURES_H=0
Packit Service 4684c1
  fi
Packit Service 4684c1
  AC_SUBST([HAVE_FEATURES_H])
Packit Service 4684c1
])
Packit Service 4684c1
Packit Service 4684c1
# AS_VAR_IF(VAR, VALUE, [IF-MATCH], [IF-NOT-MATCH])
Packit Service 4684c1
# ----------------------------------------------------
Packit Service 4684c1
# Backport of autoconf-2.63b's macro.
Packit Service 4684c1
# Remove this macro when we can assume autoconf >= 2.64.
Packit Service 4684c1
m4_ifndef([AS_VAR_IF],
Packit Service 4684c1
[m4_define([AS_VAR_IF],
Packit Service 4684c1
[AS_IF([test x"AS_VAR_GET([$1])" = x""$2], [$3], [$4])])])
Packit Service 4684c1
Packit Service 4684c1
# gl_PROG_CC_C99
Packit Service 4684c1
# Modifies the value of the shell variable CC in an attempt to make $CC
Packit Service 4684c1
# understand ISO C99 source code.
Packit Service 4684c1
# This is like AC_PROG_CC_C99, except that
Packit Service 4684c1
# - AC_PROG_CC_C99 does not mix well with AC_PROG_CC_STDC
Packit Service 4684c1
#   <https://lists.gnu.org/r/bug-gnulib/2011-09/msg00367.html>,
Packit Service 4684c1
#   but many more packages use AC_PROG_CC_STDC than AC_PROG_CC_C99
Packit Service 4684c1
#   <https://lists.gnu.org/r/bug-gnulib/2011-09/msg00441.html>.
Packit Service 4684c1
# Remaining problems:
Packit Service 4684c1
# - When AC_PROG_CC_STDC is invoked twice, it adds the C99 enabling options
Packit Service 4684c1
#   to CC twice
Packit Service 4684c1
#   <https://lists.gnu.org/r/bug-gnulib/2011-09/msg00431.html>.
Packit Service 4684c1
# - AC_PROG_CC_STDC is likely to change now that C11 is an ISO standard.
Packit Service 4684c1
AC_DEFUN([gl_PROG_CC_C99],
Packit Service 4684c1
[
Packit Service 4684c1
  dnl Change that version number to the minimum Autoconf version that supports
Packit Service 4684c1
  dnl mixing AC_PROG_CC_C99 calls with AC_PROG_CC_STDC calls.
Packit Service 4684c1
  m4_version_prereq([9.0],
Packit Service 4684c1
    [AC_REQUIRE([AC_PROG_CC_C99])],
Packit Service 4684c1
    [AC_REQUIRE([AC_PROG_CC_STDC])])
Packit Service 4684c1
])
Packit Service 4684c1
Packit Service 4684c1
# gl_PROG_AR_RANLIB
Packit Service 4684c1
# Determines the values for AR, ARFLAGS, RANLIB that fit with the compiler.
Packit Service 4684c1
# The user can set the variables AR, ARFLAGS, RANLIB if he wants to override
Packit Service 4684c1
# the values.
Packit Service 4684c1
AC_DEFUN([gl_PROG_AR_RANLIB],
Packit Service 4684c1
[
Packit Service 4684c1
  dnl Minix 3 comes with two toolchains: The Amsterdam Compiler Kit compiler
Packit Service 4684c1
  dnl as "cc", and GCC as "gcc". They have different object file formats and
Packit Service 4684c1
  dnl library formats. In particular, the GNU binutils programs ar and ranlib
Packit Service 4684c1
  dnl produce libraries that work only with gcc, not with cc.
Packit Service 4684c1
  AC_REQUIRE([AC_PROG_CC])
Packit Service 4684c1
  dnl The '][' hides this use from 'aclocal'.
Packit Service 4684c1
  AC_BEFORE([$0], [A][M_PROG_AR])
Packit Service 4684c1
  AC_CACHE_CHECK([for Minix Amsterdam compiler], [gl_cv_c_amsterdam_compiler],
Packit Service 4684c1
    [
Packit Service 4684c1
      AC_EGREP_CPP([Amsterdam],
Packit Service 4684c1
        [
Packit Service 4684c1
#ifdef __ACK__
Packit Service 4684c1
Amsterdam
Packit Service 4684c1
#endif
Packit Service 4684c1
        ],
Packit Service 4684c1
        [gl_cv_c_amsterdam_compiler=yes],
Packit Service 4684c1
        [gl_cv_c_amsterdam_compiler=no])
Packit Service 4684c1
    ])
Packit Service 4684c1
Packit Service 4684c1
  dnl Don't compete with AM_PROG_AR's decision about AR/ARFLAGS if we are not
Packit Service 4684c1
  dnl building with __ACK__.
Packit Service 4684c1
  if test $gl_cv_c_amsterdam_compiler = yes; then
Packit Service 4684c1
    if test -z "$AR"; then
Packit Service 4684c1
      AR='cc -c.a'
Packit Service 4684c1
    fi
Packit Service 4684c1
    if test -z "$ARFLAGS"; then
Packit Service 4684c1
      ARFLAGS='-o'
Packit Service 4684c1
    fi
Packit Service 4684c1
  else
Packit Service 4684c1
    dnl AM_PROG_AR was added in automake v1.11.2.  AM_PROG_AR does not AC_SUBST
Packit Service 4684c1
    dnl ARFLAGS variable (it is filed into Makefile.in directly by automake
Packit Service 4684c1
    dnl script on-demand, if not specified by ./configure of course).
Packit Service 4684c1
    dnl Don't AC_REQUIRE the AM_PROG_AR otherwise the code for __ACK__ above
Packit Service 4684c1
    dnl will be ignored.  Also, pay attention to call AM_PROG_AR in else block
Packit Service 4684c1
    dnl because AM_PROG_AR is written so it could re-set AR variable even for
Packit Service 4684c1
    dnl __ACK__.  It may seem like its easier to avoid calling the macro here,
Packit Service 4684c1
    dnl but we need to AC_SUBST both AR/ARFLAGS (thus those must have some good
Packit Service 4684c1
    dnl default value and automake should usually know them).
Packit Service 4684c1
    dnl
Packit Service 4684c1
    dnl The '][' hides this use from 'aclocal'.
Packit Service 4684c1
    m4_ifdef([A][M_PROG_AR], [A][M_PROG_AR], [:])
Packit Service 4684c1
  fi
Packit Service 4684c1
Packit Service 4684c1
  dnl In case the code above has not helped with setting AR/ARFLAGS, use
Packit Service 4684c1
  dnl Automake-documented default values for AR and ARFLAGS, but prefer
Packit Service 4684c1
  dnl ${host}-ar over ar (useful for cross-compiling).
Packit Service 4684c1
  AC_CHECK_TOOL([AR], [ar], [ar])
Packit Service 4684c1
  if test -z "$ARFLAGS"; then
Packit Service 4684c1
    ARFLAGS='cr'
Packit Service 4684c1
  fi
Packit Service 4684c1
Packit Service 4684c1
  AC_SUBST([AR])
Packit Service 4684c1
  AC_SUBST([ARFLAGS])
Packit Service 4684c1
  if test -z "$RANLIB"; then
Packit Service 4684c1
    if test $gl_cv_c_amsterdam_compiler = yes; then
Packit Service 4684c1
      RANLIB=':'
Packit Service 4684c1
    else
Packit Service 4684c1
      dnl Use the ranlib program if it is available.
Packit Service 4684c1
      AC_PROG_RANLIB
Packit Service 4684c1
    fi
Packit Service 4684c1
  fi
Packit Service 4684c1
  AC_SUBST([RANLIB])
Packit Service 4684c1
])
Packit Service 4684c1
Packit Service 4684c1
# AC_C_RESTRICT
Packit Service 4684c1
# This definition is copied from post-2.69 Autoconf and overrides the
Packit Service 4684c1
# AC_C_RESTRICT macro from autoconf 2.60..2.69.  It can be removed
Packit Service 4684c1
# once autoconf >= 2.70 can be assumed.  It's painful to check version
Packit Service 4684c1
# numbers, and in practice this macro is more up-to-date than Autoconf
Packit Service 4684c1
# is, so override Autoconf unconditionally.
Packit Service 4684c1
AC_DEFUN([AC_C_RESTRICT],
Packit Service 4684c1
[AC_CACHE_CHECK([for C/C++ restrict keyword], [ac_cv_c_restrict],
Packit Service 4684c1
  [ac_cv_c_restrict=no
Packit Service 4684c1
   # The order here caters to the fact that C++ does not require restrict.
Packit Service 4684c1
   for ac_kw in __restrict __restrict__ _Restrict restrict; do
Packit Service 4684c1
     AC_COMPILE_IFELSE(
Packit Service 4684c1
      [AC_LANG_PROGRAM(
Packit Service 4684c1
         [[typedef int *int_ptr;
Packit Service 4684c1
           int foo (int_ptr $ac_kw ip) { return ip[0]; }
Packit Service 4684c1
           int bar (int [$ac_kw]); /* Catch GCC bug 14050.  */
Packit Service 4684c1
           int bar (int ip[$ac_kw]) { return ip[0]; }
Packit Service 4684c1
         ]],
Packit Service 4684c1
         [[int s[1];
Packit Service 4684c1
           int *$ac_kw t = s;
Packit Service 4684c1
           t[0] = 0;
Packit Service 4684c1
           return foo (t) + bar (t);
Packit Service 4684c1
         ]])],
Packit Service 4684c1
      [ac_cv_c_restrict=$ac_kw])
Packit Service 4684c1
     test "$ac_cv_c_restrict" != no && break
Packit Service 4684c1
   done
Packit Service 4684c1
  ])
Packit Service 4684c1
 AH_VERBATIM([restrict],
Packit Service 4684c1
[/* Define to the equivalent of the C99 'restrict' keyword, or to
Packit Service 4684c1
   nothing if this is not supported.  Do not define if restrict is
Packit Service 4684c1
   supported directly.  */
Packit Service 4684c1
#undef restrict
Packit Service 4684c1
/* Work around a bug in older versions of Sun C++, which did not
Packit Service 4684c1
   #define __restrict__ or support _Restrict or __restrict__
Packit Service 4684c1
   even though the corresponding Sun C compiler ended up with
Packit Service 4684c1
   "#define restrict _Restrict" or "#define restrict __restrict__"
Packit Service 4684c1
   in the previous line.  This workaround can be removed once
Packit Service 4684c1
   we assume Oracle Developer Studio 12.5 (2016) or later.  */
Packit Service 4684c1
#if defined __SUNPRO_CC && !defined __RESTRICT && !defined __restrict__
Packit Service 4684c1
# define _Restrict
Packit Service 4684c1
# define __restrict__
Packit Service 4684c1
#endif])
Packit Service 4684c1
 case $ac_cv_c_restrict in
Packit Service 4684c1
   restrict) ;;
Packit Service 4684c1
   no) AC_DEFINE([restrict], []) ;;
Packit Service 4684c1
   *)  AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;;
Packit Service 4684c1
 esac
Packit Service 4684c1
])# AC_C_RESTRICT
Packit Service 4684c1
Packit Service 4684c1
# gl_BIGENDIAN
Packit Service 4684c1
# is like AC_C_BIGENDIAN, except that it can be AC_REQUIREd.
Packit Service 4684c1
# Note that AC_REQUIRE([AC_C_BIGENDIAN]) does not work reliably because some
Packit Service 4684c1
# macros invoke AC_C_BIGENDIAN with arguments.
Packit Service 4684c1
AC_DEFUN([gl_BIGENDIAN],
Packit Service 4684c1
[
Packit Service 4684c1
  AC_C_BIGENDIAN
Packit Service 4684c1
])
Packit Service 4684c1
Packit Service 4684c1
# gl_CACHE_VAL_SILENT(cache-id, command-to-set-it)
Packit Service 4684c1
# is like AC_CACHE_VAL(cache-id, command-to-set-it), except that it does not
Packit Service 4684c1
# output a spurious "(cached)" mark in the midst of other configure output.
Packit Service 4684c1
# This macro should be used instead of AC_CACHE_VAL when it is not surrounded
Packit Service 4684c1
# by an AC_MSG_CHECKING/AC_MSG_RESULT pair.
Packit Service 4684c1
AC_DEFUN([gl_CACHE_VAL_SILENT],
Packit Service 4684c1
[
Packit Service 4684c1
  saved_as_echo_n="$as_echo_n"
Packit Service 4684c1
  as_echo_n=':'
Packit Service 4684c1
  AC_CACHE_VAL([$1], [$2])
Packit Service 4684c1
  as_echo_n="$saved_as_echo_n"
Packit Service 4684c1
])
Packit Service 4684c1
Packit Service 4684c1
# AS_VAR_COPY was added in autoconf 2.63b
Packit Service 4684c1
m4_define_default([AS_VAR_COPY],
Packit Service 4684c1
[AS_LITERAL_IF([$1[]$2], [$1=$$2], [eval $1=\$$2])])