~ubuntu-branches/ubuntu/vivid/gzip/vivid

« back to all changes in this revision

Viewing changes to m4/calloc.m4

  • Committer: Steve Langasek
  • Date: 2012-06-29 02:07:40 UTC
  • mfrom: (4.1.9 sid)
  • Revision ID: steve.langasek@canonical.com-20120629020740-qqikrblzana08v2y
Merge version 1.5-1.1 from Debian

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# calloc.m4 serial 9
 
1
# calloc.m4 serial 15
2
2
 
3
 
# Copyright (C) 2004-2010 Free Software Foundation, Inc.
 
3
# Copyright (C) 2004-2012 Free Software Foundation, Inc.
4
4
# This file is free software; the Free Software Foundation
5
5
# gives unlimited permission to copy and/or distribute it,
6
6
# with or without modifications, as long as this notice is preserved.
14
14
 
15
15
# _AC_FUNC_CALLOC_IF([IF-WORKS], [IF-NOT])
16
16
# -------------------------------------
17
 
# If `calloc (0, 0)' is properly handled, run IF-WORKS, otherwise, IF-NOT.
 
17
# If 'calloc (0, 0)' is properly handled, run IF-WORKS, otherwise, IF-NOT.
18
18
AC_DEFUN([_AC_FUNC_CALLOC_IF],
19
 
[AC_REQUIRE([AC_TYPE_SIZE_T])dnl
20
 
AC_CACHE_CHECK([for GNU libc compatible calloc], [ac_cv_func_calloc_0_nonnull],
21
 
[AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
22
 
                  [[exit (!calloc (0, 0) || calloc ((size_t) -1 / 8 + 1, 8));]])],
23
 
               [ac_cv_func_calloc_0_nonnull=yes],
24
 
               [ac_cv_func_calloc_0_nonnull=no],
25
 
               [ac_cv_func_calloc_0_nonnull=no])])
26
 
AS_IF([test $ac_cv_func_calloc_0_nonnull = yes], [$1], [$2])
 
19
[
 
20
  AC_REQUIRE([AC_TYPE_SIZE_T])dnl
 
21
  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
 
22
  AC_CACHE_CHECK([for GNU libc compatible calloc],
 
23
    [ac_cv_func_calloc_0_nonnull],
 
24
    [AC_RUN_IFELSE(
 
25
       [AC_LANG_PROGRAM(
 
26
          [AC_INCLUDES_DEFAULT],
 
27
          [[int result = 0;
 
28
            if (!calloc (0, 0))
 
29
              result |= 1;
 
30
            if (calloc ((size_t) -1 / 8 + 1, 8))
 
31
              result |= 2;
 
32
            return result;
 
33
          ]])],
 
34
       [ac_cv_func_calloc_0_nonnull=yes],
 
35
       [ac_cv_func_calloc_0_nonnull=no],
 
36
       [case "$host_os" in
 
37
                  # Guess yes on glibc systems.
 
38
          *-gnu*) ac_cv_func_calloc_0_nonnull="guessing yes" ;;
 
39
                  # If we don't know, assume the worst.
 
40
          *)      ac_cv_func_calloc_0_nonnull="guessing no" ;;
 
41
        esac
 
42
       ])])
 
43
  case "$ac_cv_func_calloc_0_nonnull" in
 
44
    *yes)
 
45
      $1
 
46
      ;;
 
47
    *)
 
48
      $2
 
49
      ;;
 
50
  esac
27
51
])# AC_FUNC_CALLOC
28
52
 
29
53
 
30
 
# AC_FUNC_CALLOC
31
 
# ---------------
32
 
# Report whether `calloc (0, 0)' is properly handled, and replace calloc if
 
54
# gl_FUNC_CALLOC_GNU
 
55
# ------------------
 
56
# Report whether 'calloc (0, 0)' is properly handled, and replace calloc if
33
57
# needed.
34
 
AC_DEFUN([AC_FUNC_CALLOC],
35
 
[_AC_FUNC_CALLOC_IF(
36
 
  [AC_DEFINE([HAVE_CALLOC], [1],
37
 
             [Define to 1 if your system has a GNU libc compatible `calloc'
38
 
              function, and to 0 otherwise.])],
39
 
  [AC_DEFINE([HAVE_CALLOC], [0])
40
 
   AC_LIBOBJ([calloc])
41
 
   AC_DEFINE([calloc], [rpl_calloc],
42
 
      [Define to rpl_calloc if the replacement function should be used.])])
43
 
])# AC_FUNC_CALLOC
 
58
AC_DEFUN([gl_FUNC_CALLOC_GNU],
 
59
[
 
60
  AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
 
61
  _AC_FUNC_CALLOC_IF(
 
62
    [AC_DEFINE([HAVE_CALLOC_GNU], [1],
 
63
               [Define to 1 if your system has a GNU libc compatible 'calloc'
 
64
                function, and to 0 otherwise.])],
 
65
    [AC_DEFINE([HAVE_CALLOC_GNU], [0])
 
66
     REPLACE_CALLOC=1
 
67
    ])
 
68
])# gl_FUNC_CALLOC_GNU
44
69
 
45
70
 
46
71
# gl_FUNC_CALLOC_POSIX
49
74
# fails), and replace calloc if it is not.
50
75
AC_DEFUN([gl_FUNC_CALLOC_POSIX],
51
76
[
 
77
  AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
52
78
  AC_REQUIRE([gl_CHECK_MALLOC_POSIX])
53
79
  if test $gl_cv_func_malloc_posix = yes; then
54
 
    HAVE_CALLOC_POSIX=1
55
80
    AC_DEFINE([HAVE_CALLOC_POSIX], [1],
56
81
      [Define if the 'calloc' function is POSIX compliant.])
57
82
  else
58
 
    AC_LIBOBJ([calloc])
59
 
    HAVE_CALLOC_POSIX=0
 
83
    REPLACE_CALLOC=1
60
84
  fi
61
 
  AC_SUBST([HAVE_CALLOC_POSIX])
62
85
])