eoverflow.m4 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # eoverflow.m4 serial 2
  2. dnl Copyright (C) 2004, 2006 Free Software Foundation, Inc.
  3. dnl This file is free software; the Free Software Foundation
  4. dnl gives unlimited permission to copy and/or distribute it,
  5. dnl with or without modifications, as long as this notice is preserved.
  6. dnl From Bruno Haible.
  7. # The EOVERFLOW errno value ought to be defined in <errno.h>, according to
  8. # POSIX. But some systems (like AIX 3) don't define it, and some systems
  9. # (like OSF/1) define it when _XOPEN_SOURCE_EXTENDED is defined.
  10. # Define EOVERFLOW as a C macro and as a substituted macro in such a way that
  11. # 1. on all systems, after inclusion of <errno.h>, EOVERFLOW is usable,
  12. # 2. on systems where EOVERFLOW is defined elsewhere, we use the same numeric
  13. # value.
  14. AC_DEFUN([gl_EOVERFLOW],
  15. [
  16. AC_REQUIRE([AC_PROG_CC])dnl
  17. AC_CACHE_CHECK([for EOVERFLOW], ac_cv_decl_EOVERFLOW, [
  18. AC_EGREP_CPP(yes,[
  19. #include <errno.h>
  20. #ifdef EOVERFLOW
  21. yes
  22. #endif
  23. ], have_eoverflow=1)
  24. if test -n "$have_eoverflow"; then
  25. dnl EOVERFLOW exists in <errno.h>. Don't need to define EOVERFLOW ourselves.
  26. ac_cv_decl_EOVERFLOW=yes
  27. else
  28. AC_EGREP_CPP(yes,[
  29. #define _XOPEN_SOURCE_EXTENDED 1
  30. #include <errno.h>
  31. #ifdef EOVERFLOW
  32. yes
  33. #endif
  34. ], have_eoverflow=1)
  35. if test -n "$have_eoverflow"; then
  36. dnl EOVERFLOW exists but is hidden.
  37. dnl Define it to the same value.
  38. AC_COMPUTE_INT([ac_cv_decl_EOVERFLOW], [EOVERFLOW], [
  39. #define _XOPEN_SOURCE_EXTENDED 1
  40. #include <errno.h>
  41. /* The following two lines are a workaround against an autoconf-2.52 bug. */
  42. #include <stdio.h>
  43. #include <stdlib.h>
  44. ])
  45. else
  46. dnl EOVERFLOW isn't defined by the system. Define EOVERFLOW ourselves, but
  47. dnl don't define it as EINVAL, because snprintf() callers want to
  48. dnl distinguish EINVAL and EOVERFLOW.
  49. ac_cv_decl_EOVERFLOW=E2BIG
  50. fi
  51. fi
  52. ])
  53. if test "$ac_cv_decl_EOVERFLOW" != yes; then
  54. AC_DEFINE_UNQUOTED([EOVERFLOW], [$ac_cv_decl_EOVERFLOW],
  55. [Define as good substitute value for EOVERFLOW.])
  56. EOVERFLOW="$ac_cv_decl_EOVERFLOW"
  57. AC_SUBST(EOVERFLOW)
  58. fi
  59. ])
  60. dnl Autoconf >= 2.61 has AC_COMPUTE_INT built-in.
  61. dnl Remove this when we can assume autoconf >= 2.61.
  62. m4_ifdef([AC_COMPUTE_INT], [], [
  63. AC_DEFUN([AC_COMPUTE_INT], [_AC_COMPUTE_INT([$2],[$1],[$3],[$4])])
  64. ])