summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2000-01-08 16:30:49 +0000
committerJim Meyering <jim@meyering.net>2000-01-08 16:30:49 +0000
commitb8342a9a20c62dc734393ad59c8557879ea194a9 (patch)
tree468bf71c094662d4ffd9d21447ec0b4f044a046a /m4
parent2170503967446c16146316158d337f2ef378ed71 (diff)
downloadcoreutils-b8342a9a20c62dc734393ad59c8557879ea194a9.tar.xz
(jm_FUNC_STRERROR_R): New file/macro.
Diffstat (limited to 'm4')
-rw-r--r--m4/strerror_r.m439
1 files changed, 39 insertions, 0 deletions
diff --git a/m4/strerror_r.m4 b/m4/strerror_r.m4
new file mode 100644
index 000000000..e886b5cc5
--- /dev/null
+++ b/m4/strerror_r.m4
@@ -0,0 +1,39 @@
+#serial 1
+
+dnl From Jim Meyering.
+dnl Determine whether the strerror_r implementation is one of
+dnl the broken ones that returns `int' rather than `char*'.
+dnl Actually, this tests only whether it returns an array,
+dnl but that should be enough.
+dnl This is used by lib/error.c.
+
+AC_DEFUN(jm_FUNC_STRERROR_R,
+[
+ # Check strerror_r
+ AC_CHECK_FUNCS([strerror_r])
+ if test $ac_cv_func_strerror_r = yes; then
+ AC_CHECK_HEADERS(string.h)
+ AC_CACHE_CHECK([for working strerror_r],
+ jm_cv_func_working_strerror_r,
+ [
+ AC_TRY_COMPILE(
+ [
+# include <stdio.h>
+# if HAVE_STRING_H
+# include <string.h>
+# endif
+ ],
+ [
+ int buf; /* avoiding square brackets makes this easier */
+ char x = *strerror_r (0, buf, sizeof buf);
+ ],
+ jm_cv_func_working_strerror_r=yes,
+ jm_cv_func_working_strerror_r=no
+ )
+ if test $jm_cv_func_working_strerror_r = yes; then
+ AC_DEFINE_UNQUOTED(HAVE_WORKING_STRERROR_R, 1,
+ [Define to 1 if strerror_r returns a string.])
+ fi
+ ])
+ fi
+])