*** empty log message ***
[gnulib.git] / m4 / strerror_r.m4
1 #serial 1
2
3 dnl From Jim Meyering.
4 dnl Determine whether the strerror_r implementation is one of
5 dnl the broken ones that returns `int' rather than `char*'.
6 dnl Actually, this tests only whether it returns a scalar
7 dnl or an array, but that should be enough.
8 dnl This is used by lib/error.c.
9
10 AC_DEFUN(jm_FUNC_STRERROR_R,
11 [
12   # Check strerror_r
13   AC_CHECK_FUNCS([strerror_r])
14   if test $ac_cv_func_strerror_r = yes; then
15     AC_CHECK_HEADERS(string.h)
16     AC_CACHE_CHECK([for working strerror_r],
17                    jm_cv_func_working_strerror_r,
18      [
19       AC_TRY_COMPILE(
20        [
21 #       include <stdio.h>
22 #       if HAVE_STRING_H
23 #        include <string.h>
24 #       endif
25        ],
26        [
27          int buf; /* avoiding square brackets makes this easier */
28          char x = *strerror_r (0, buf, sizeof buf);
29        ],
30        jm_cv_func_working_strerror_r=yes,
31        jm_cv_func_working_strerror_r=no
32       )
33       if test $jm_cv_func_working_strerror_r = yes; then
34         AC_DEFINE_UNQUOTED(HAVE_WORKING_STRERROR_R, 1,
35           [Define to 1 if strerror_r returns a string.])
36       fi
37     ])
38   fi
39 ])