|
Packit Service |
4684c1 |
# perror.m4 serial 9
|
|
Packit Service |
4684c1 |
dnl Copyright (C) 2008-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_DEFUN([gl_FUNC_PERROR],
|
|
Packit Service |
4684c1 |
[
|
|
Packit Service |
4684c1 |
AC_REQUIRE([gl_STDIO_H_DEFAULTS])
|
|
Packit Service |
4684c1 |
AC_REQUIRE([gl_HEADER_ERRNO_H])
|
|
Packit Service |
4684c1 |
AC_REQUIRE([gl_FUNC_STRERROR_R])
|
|
Packit Service |
4684c1 |
AC_REQUIRE([gl_FUNC_STRERROR_0])
|
|
Packit Service |
4684c1 |
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
|
|
Packit Service |
4684c1 |
dnl We intentionally do not check for the broader REPLACE_STRERROR_R,
|
|
Packit Service |
4684c1 |
dnl since on glibc systems, strerror_r is replaced only for signature
|
|
Packit Service |
4684c1 |
dnl issues, and perror is just fine. Rather, we only want to
|
|
Packit Service |
4684c1 |
dnl replace perror if strerror_r was replaced for a content fix.
|
|
Packit Service |
4684c1 |
if test "$ERRNO_H:$REPLACE_STRERROR_0" != :0; then
|
|
Packit Service |
4684c1 |
dnl The system's perror() cannot know about the new errno values we add
|
|
Packit Service |
4684c1 |
dnl to <errno.h>, or any fix for strerror(0). Replace it.
|
|
Packit Service |
4684c1 |
REPLACE_PERROR=1
|
|
Packit Service |
4684c1 |
fi
|
|
Packit Service |
4684c1 |
case ${gl_cv_func_strerror_r_works-unset} in
|
|
Packit Service |
4684c1 |
unset|*yes)
|
|
Packit Service |
4684c1 |
AC_CACHE_CHECK([whether perror matches strerror],
|
|
Packit Service |
4684c1 |
[gl_cv_func_perror_works],
|
|
Packit Service |
4684c1 |
[AC_RUN_IFELSE(
|
|
Packit Service |
4684c1 |
[AC_LANG_PROGRAM(
|
|
Packit Service |
4684c1 |
[[#include <errno.h>
|
|
Packit Service |
4684c1 |
#include <stdio.h>
|
|
Packit Service |
4684c1 |
#include <stdlib.h>
|
|
Packit Service |
4684c1 |
#include <string.h>
|
|
Packit Service |
4684c1 |
]],
|
|
Packit Service |
4684c1 |
[[char *str = strerror (-1);
|
|
Packit Service |
4684c1 |
if (!getenv("CONFTEST_OUTPUT")) return 0;
|
|
Packit Service |
4684c1 |
if (!str) str = "";
|
|
Packit Service |
4684c1 |
puts (str);
|
|
Packit Service |
4684c1 |
errno = -1;
|
|
Packit Service |
4684c1 |
perror ("");
|
|
Packit Service |
4684c1 |
return 0;
|
|
Packit Service |
4684c1 |
]])],
|
|
Packit Service |
4684c1 |
[if CONFTEST_OUTPUT=1 ./conftest$EXEEXT >conftest.txt1 2>conftest.txt2 \
|
|
Packit Service |
4684c1 |
&& cmp conftest.txt1 conftest.txt2 >/dev/null; then
|
|
Packit Service |
4684c1 |
gl_cv_func_perror_works=yes
|
|
Packit Service |
4684c1 |
else
|
|
Packit Service |
4684c1 |
gl_cv_func_perror_works=no
|
|
Packit Service |
4684c1 |
fi
|
|
Packit Service |
4684c1 |
rm -rf conftest.txt1 conftest.txt2],
|
|
Packit Service |
4684c1 |
[gl_cv_func_perror_works=no],
|
|
Packit Service |
4684c1 |
[case "$host_os" in
|
|
Packit Service |
4684c1 |
# Guess yes on musl systems.
|
|
Packit Service |
4684c1 |
*-musl*) gl_cv_func_perror_works="guessing yes" ;;
|
|
Packit Service |
4684c1 |
# Guess yes on native Windows.
|
|
Packit Service |
4684c1 |
mingw*) gl_cv_func_perror_works="guessing yes" ;;
|
|
Packit Service |
4684c1 |
# Otherwise obey --enable-cross-guesses.
|
|
Packit Service |
4684c1 |
*) gl_cv_func_perror_works="$gl_cross_guess_normal" ;;
|
|
Packit Service |
4684c1 |
esac
|
|
Packit Service |
4684c1 |
])
|
|
Packit Service |
4684c1 |
])
|
|
Packit Service |
4684c1 |
case "$gl_cv_func_perror_works" in
|
|
Packit Service |
4684c1 |
*yes) ;;
|
|
Packit Service |
4684c1 |
*) REPLACE_PERROR=1 ;;
|
|
Packit Service |
4684c1 |
esac
|
|
Packit Service |
4684c1 |
;;
|
|
Packit Service |
4684c1 |
*)
|
|
Packit Service |
4684c1 |
dnl The system's perror() probably inherits the bugs in the
|
|
Packit Service |
4684c1 |
dnl system's strerror_r(). Replace it.
|
|
Packit Service |
4684c1 |
REPLACE_PERROR=1
|
|
Packit Service |
4684c1 |
;;
|
|
Packit Service |
4684c1 |
esac
|
|
Packit Service |
4684c1 |
])
|