summaryrefslogtreecommitdiff
path: root/m4/strerror_r.m4
blob: e886b5cc5b8faa3710828740b8aca4c230be0f2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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
])