annotate m4/strerror.m4 @ 40196:e63f5d3edab5

relocatable-prog: Update documentation. * doc/relocatable-maint.texi (Supporting Relocation): Update to match the recent changes.
author Bruno Haible <bruno@clisp.org>
date Sun, 24 Feb 2019 01:49:15 +0100
parents b06060465f09
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19479
4bc5b8cefed7 Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents: 18993
diff changeset
1 # strerror.m4 serial 19
40057
b06060465f09 maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents: 19484
diff changeset
2 dnl Copyright (C) 2002, 2007-2019 Free Software Foundation, Inc.
5611
87c42e194f4a Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4334
diff changeset
3 dnl This file is free software; the Free Software Foundation
87c42e194f4a Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4334
diff changeset
4 dnl gives unlimited permission to copy and/or distribute it,
87c42e194f4a Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4334
diff changeset
5 dnl with or without modifications, as long as this notice is preserved.
4107
7c1a6b73f48e An autoconf macro for its associated module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6
7c1a6b73f48e An autoconf macro for its associated module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 AC_DEFUN([gl_FUNC_STRERROR],
7c1a6b73f48e An autoconf macro for its associated module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8 [
9502
9be60e099f13 Fix strerror module on Solaris 7.
Eric Blake <ebb9@byu.net>
parents: 9324
diff changeset
9 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
10429
69d9922a5bd2 Extend strerror to cover the added errno values.
Bruno Haible <bruno@clisp.org>
parents: 9921
diff changeset
10 AC_REQUIRE([gl_HEADER_ERRNO_H])
15308
a3ba680ad389 strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents: 14895
diff changeset
11 AC_REQUIRE([gl_FUNC_STRERROR_0])
16821
d9b4f726faa7 strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
12 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
14889
a78ddb38a66b strerror_r-posix: work around cygwin 1.7.9
Eric Blake <eblake@redhat.com>
parents: 14887
diff changeset
13 m4_ifdef([gl_FUNC_STRERROR_R_WORKS], [
a78ddb38a66b strerror_r-posix: work around cygwin 1.7.9
Eric Blake <eblake@redhat.com>
parents: 14887
diff changeset
14 AC_REQUIRE([gl_FUNC_STRERROR_R_WORKS])
a78ddb38a66b strerror_r-posix: work around cygwin 1.7.9
Eric Blake <eblake@redhat.com>
parents: 14887
diff changeset
15 ])
15308
a3ba680ad389 strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents: 14895
diff changeset
16 if test "$ERRNO_H:$REPLACE_STRERROR_0" = :0; then
10429
69d9922a5bd2 Extend strerror to cover the added errno values.
Bruno Haible <bruno@clisp.org>
parents: 9921
diff changeset
17 AC_CACHE_CHECK([for working strerror function],
69d9922a5bd2 Extend strerror to cover the added errno values.
Bruno Haible <bruno@clisp.org>
parents: 9921
diff changeset
18 [gl_cv_func_working_strerror],
69d9922a5bd2 Extend strerror to cover the added errno values.
Bruno Haible <bruno@clisp.org>
parents: 9921
diff changeset
19 [AC_RUN_IFELSE(
69d9922a5bd2 Extend strerror to cover the added errno values.
Bruno Haible <bruno@clisp.org>
parents: 9921
diff changeset
20 [AC_LANG_PROGRAM(
69d9922a5bd2 Extend strerror to cover the added errno values.
Bruno Haible <bruno@clisp.org>
parents: 9921
diff changeset
21 [[#include <string.h>
69d9922a5bd2 Extend strerror to cover the added errno values.
Bruno Haible <bruno@clisp.org>
parents: 9921
diff changeset
22 ]],
15308
a3ba680ad389 strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents: 14895
diff changeset
23 [[if (!*strerror (-2)) return 1;]])],
10429
69d9922a5bd2 Extend strerror to cover the added errno values.
Bruno Haible <bruno@clisp.org>
parents: 9921
diff changeset
24 [gl_cv_func_working_strerror=yes],
69d9922a5bd2 Extend strerror to cover the added errno values.
Bruno Haible <bruno@clisp.org>
parents: 9921
diff changeset
25 [gl_cv_func_working_strerror=no],
16821
d9b4f726faa7 strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
26 [case "$host_os" in
19479
4bc5b8cefed7 Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents: 18993
diff changeset
27 # Guess yes on glibc systems.
4bc5b8cefed7 Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents: 18993
diff changeset
28 *-gnu* | gnu*) gl_cv_func_working_strerror="guessing yes" ;;
4bc5b8cefed7 Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents: 18993
diff changeset
29 # If we don't know, assume the worst.
4bc5b8cefed7 Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents: 18993
diff changeset
30 *) gl_cv_func_working_strerror="guessing no" ;;
16821
d9b4f726faa7 strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
31 esac
d9b4f726faa7 strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
32 ])
10429
69d9922a5bd2 Extend strerror to cover the added errno values.
Bruno Haible <bruno@clisp.org>
parents: 9921
diff changeset
33 ])
16821
d9b4f726faa7 strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
34 case "$gl_cv_func_working_strerror" in
d9b4f726faa7 strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
35 *yes) ;;
d9b4f726faa7 strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
36 *)
d9b4f726faa7 strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
37 dnl The system's strerror() fails to return a string for out-of-range
d9b4f726faa7 strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
38 dnl integers. Replace it.
d9b4f726faa7 strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
39 REPLACE_STRERROR=1
d9b4f726faa7 strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
40 ;;
d9b4f726faa7 strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
41 esac
14892
5059ee60d09a strerror_r-posix: Tweaks.
Bruno Haible <bruno@clisp.org>
parents: 14889
diff changeset
42 m4_ifdef([gl_FUNC_STRERROR_R_WORKS], [
5059ee60d09a strerror_r-posix: Tweaks.
Bruno Haible <bruno@clisp.org>
parents: 14889
diff changeset
43 dnl If the system's strerror_r or __xpg_strerror_r clobbers strerror's
5059ee60d09a strerror_r-posix: Tweaks.
Bruno Haible <bruno@clisp.org>
parents: 14889
diff changeset
44 dnl buffer, we must replace strerror.
5059ee60d09a strerror_r-posix: Tweaks.
Bruno Haible <bruno@clisp.org>
parents: 14889
diff changeset
45 case "$gl_cv_func_strerror_r_works" in
5059ee60d09a strerror_r-posix: Tweaks.
Bruno Haible <bruno@clisp.org>
parents: 14889
diff changeset
46 *no) REPLACE_STRERROR=1 ;;
5059ee60d09a strerror_r-posix: Tweaks.
Bruno Haible <bruno@clisp.org>
parents: 14889
diff changeset
47 esac
5059ee60d09a strerror_r-posix: Tweaks.
Bruno Haible <bruno@clisp.org>
parents: 14889
diff changeset
48 ])
10429
69d9922a5bd2 Extend strerror to cover the added errno values.
Bruno Haible <bruno@clisp.org>
parents: 9921
diff changeset
49 else
69d9922a5bd2 Extend strerror to cover the added errno values.
Bruno Haible <bruno@clisp.org>
parents: 9921
diff changeset
50 dnl The system's strerror() cannot know about the new errno values we add
15308
a3ba680ad389 strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents: 14895
diff changeset
51 dnl to <errno.h>, or any fix for strerror(0). Replace it.
9321
c25260956dfa Simplify and modernize strerror substitute, partly to fix Solaris 8 bug.
Paul Eggert <eggert@cs.ucla.edu>
parents: 9224
diff changeset
52 REPLACE_STRERROR=1
10429
69d9922a5bd2 Extend strerror to cover the added errno values.
Bruno Haible <bruno@clisp.org>
parents: 9921
diff changeset
53 fi
8309
e5ee9891c553 Make it possible to compile strerror.c separately, unconditionally.
Bruno Haible <bruno@clisp.org>
parents: 5611
diff changeset
54 ])
15308
a3ba680ad389 strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents: 14895
diff changeset
55
a3ba680ad389 strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents: 14895
diff changeset
56 dnl Detect if strerror(0) passes (that is, does not set errno, and does not
a3ba680ad389 strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents: 14895
diff changeset
57 dnl return a string that matches strerror(-1)).
a3ba680ad389 strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents: 14895
diff changeset
58 AC_DEFUN([gl_FUNC_STRERROR_0],
a3ba680ad389 strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents: 14895
diff changeset
59 [
16821
d9b4f726faa7 strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
60 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
15308
a3ba680ad389 strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents: 14895
diff changeset
61 REPLACE_STRERROR_0=0
a3ba680ad389 strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents: 14895
diff changeset
62 AC_CACHE_CHECK([whether strerror(0) succeeds],
a3ba680ad389 strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents: 14895
diff changeset
63 [gl_cv_func_strerror_0_works],
a3ba680ad389 strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents: 14895
diff changeset
64 [AC_RUN_IFELSE(
a3ba680ad389 strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents: 14895
diff changeset
65 [AC_LANG_PROGRAM(
a3ba680ad389 strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents: 14895
diff changeset
66 [[#include <string.h>
a3ba680ad389 strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents: 14895
diff changeset
67 #include <errno.h>
a3ba680ad389 strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents: 14895
diff changeset
68 ]],
a3ba680ad389 strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents: 14895
diff changeset
69 [[int result = 0;
a3ba680ad389 strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents: 14895
diff changeset
70 char *str;
a3ba680ad389 strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents: 14895
diff changeset
71 errno = 0;
a3ba680ad389 strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents: 14895
diff changeset
72 str = strerror (0);
a3ba680ad389 strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents: 14895
diff changeset
73 if (!*str) result |= 1;
a3ba680ad389 strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents: 14895
diff changeset
74 if (errno) result |= 2;
a3ba680ad389 strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents: 14895
diff changeset
75 if (strstr (str, "nknown") || strstr (str, "ndefined"))
a3ba680ad389 strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents: 14895
diff changeset
76 result |= 4;
a3ba680ad389 strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents: 14895
diff changeset
77 return result;]])],
a3ba680ad389 strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents: 14895
diff changeset
78 [gl_cv_func_strerror_0_works=yes],
a3ba680ad389 strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents: 14895
diff changeset
79 [gl_cv_func_strerror_0_works=no],
16821
d9b4f726faa7 strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
80 [case "$host_os" in
19479
4bc5b8cefed7 Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents: 18993
diff changeset
81 # Guess yes on glibc systems.
4bc5b8cefed7 Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents: 18993
diff changeset
82 *-gnu* | gnu*) gl_cv_func_strerror_0_works="guessing yes" ;;
4bc5b8cefed7 Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents: 18993
diff changeset
83 # Guess yes on native Windows.
4bc5b8cefed7 Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents: 18993
diff changeset
84 mingw*) gl_cv_func_strerror_0_works="guessing yes" ;;
4bc5b8cefed7 Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents: 18993
diff changeset
85 # If we don't know, assume the worst.
4bc5b8cefed7 Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents: 18993
diff changeset
86 *) gl_cv_func_strerror_0_works="guessing no" ;;
16821
d9b4f726faa7 strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
87 esac
d9b4f726faa7 strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
88 ])
15308
a3ba680ad389 strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents: 14895
diff changeset
89 ])
16821
d9b4f726faa7 strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
90 case "$gl_cv_func_strerror_0_works" in
d9b4f726faa7 strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
91 *yes) ;;
d9b4f726faa7 strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
92 *)
d9b4f726faa7 strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
93 REPLACE_STRERROR_0=1
d9b4f726faa7 strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
94 AC_DEFINE([REPLACE_STRERROR_0], [1], [Define to 1 if strerror(0)
d9b4f726faa7 strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
95 does not return a message implying success.])
d9b4f726faa7 strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
96 ;;
d9b4f726faa7 strerror: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
97 esac
15308
a3ba680ad389 strerror_r: fix OpenBSD behavior on 0
Eric Blake <eblake@redhat.com>
parents: 14895
diff changeset
98 ])