* atanl.c, logl.c: Add GPL notice, and make the code more similar to glibc.
[gnulib.git] / m4 / eoverflow.m4
1 # eoverflow.m4 serial 1
2 dnl Copyright (C) 2004 Free Software Foundation, Inc.
3 dnl This file is free software, distributed under the terms of the GNU
4 dnl General Public License.  As a special exception to the GNU General
5 dnl Public License, this file may be distributed as part of a program
6 dnl that contains a configuration script generated by Autoconf, under
7 dnl the same distribution terms as the rest of that program.
8
9 dnl From Bruno Haible.
10
11 # The EOVERFLOW errno value ought to be defined in <errno.h>, according to
12 # POSIX.  But some systems (like AIX 3) don't define it, and some systems
13 # (like OSF/1) define it when _XOPEN_SOURCE_EXTENDED is defined.
14
15 # Define EOVERFLOW as a C macro and as a substituted macro in such a way that
16 # 1. on all systems, after inclusion of <errno.h>, EOVERFLOW is usable,
17 # 2. on systems where EOVERFLOW is defined elsewhere, we use the same numeric
18 #    value.
19
20 AC_DEFUN([gl_EOVERFLOW],
21 [
22   AC_REQUIRE([AC_PROG_CC])dnl
23
24   AC_CACHE_CHECK([for EOVERFLOW], ac_cv_decl_EOVERFLOW, [
25     AC_EGREP_CPP(yes,[
26 #include <errno.h>
27 #ifdef EOVERFLOW
28 yes
29 #endif
30       ], have_eoverflow=1)
31     if test -n "$have_eoverflow"; then
32       dnl EOVERFLOW exists in <errno.h>. Don't need to define EOVERFLOW ourselves.
33       ac_cv_decl_EOVERFLOW=yes
34     else
35       AC_EGREP_CPP(yes,[
36 #define _XOPEN_SOURCE_EXTENDED 1
37 #include <errno.h>
38 #ifdef EOVERFLOW
39 yes
40 #endif
41         ], have_eoverflow=1)
42       if test -n "$have_eoverflow"; then
43         dnl EOVERFLOW exists but is hidden.
44         dnl Define it to the same value.
45         _AC_COMPUTE_INT([EOVERFLOW], ac_cv_decl_EOVERFLOW, [
46 #define _XOPEN_SOURCE_EXTENDED 1
47 #include <errno.h>
48 /* The following two lines are a workaround against an autoconf-2.52 bug.  */
49 #include <stdio.h>
50 #include <stdlib.h>
51 ])
52       else
53         dnl EOVERFLOW isn't defined by the system. Define EOVERFLOW ourselves, but
54         dnl don't define it as EINVAL, because snprintf() callers want to
55         dnl distinguish EINVAL and EOVERFLOW.
56         ac_cv_decl_EOVERFLOW=E2BIG
57       fi
58     fi
59   ])
60   if test "$ac_cv_decl_EOVERFLOW" != yes; then
61     AC_DEFINE_UNQUOTED([EOVERFLOW], [$ac_cv_decl_EOVERFLOW],
62                        [Define as good substitute value for EOVERFLOW.])
63     EOVERFLOW="$ac_cv_decl_EOVERFLOW"
64     AC_SUBST(EOVERFLOW)
65   fi
66 ])