~ubuntu-branches/ubuntu/oneiric/gnupg2/oneiric-updates

« back to all changes in this revision

Viewing changes to m4/size_max.m4

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Viehmann
  • Date: 2008-10-04 10:25:53 UTC
  • mfrom: (5.1.15 intrepid)
  • Revision ID: james.westby@ubuntu.com-20081004102553-fv62pp8dsitxli47
Tags: 2.0.9-3.1
* Non-maintainer upload.
* agent/gpg-agent.c: Deinit the threading library before exec'ing
  the command to run in --daemon mode. And because that still doesn't
  restore the sigprocmask, do that manually. Closes: #499569

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# size_max.m4 serial 2
2
 
dnl Copyright (C) 2003 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.
 
1
# size_max.m4 serial 5
 
2
dnl Copyright (C) 2003, 2005-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.
8
6
 
9
7
dnl From Bruno Haible.
10
8
 
13
11
  AC_CHECK_HEADERS(stdint.h)
14
12
  dnl First test whether the system already has SIZE_MAX.
15
13
  AC_MSG_CHECKING([for SIZE_MAX])
16
 
  result=
17
 
  AC_EGREP_CPP([Found it], [
 
14
  AC_CACHE_VAL([gl_cv_size_max], [
 
15
    gl_cv_size_max=
 
16
    AC_EGREP_CPP([Found it], [
18
17
#include <limits.h>
19
18
#if HAVE_STDINT_H
20
19
#include <stdint.h>
22
21
#ifdef SIZE_MAX
23
22
Found it
24
23
#endif
25
 
], result=yes)
26
 
  if test -z "$result"; then
27
 
    dnl Define it ourselves. Here we assume that the type 'size_t' is not wider
28
 
    dnl than the type 'unsigned long'.
29
 
    dnl The _AC_COMPUTE_INT macro works up to LONG_MAX, since it uses 'expr',
30
 
    dnl which is guaranteed to work from LONG_MIN to LONG_MAX.
31
 
    _AC_COMPUTE_INT([~(size_t)0 / 10], res_hi,
32
 
      [#include <stddef.h>], result=?)
33
 
    _AC_COMPUTE_INT([~(size_t)0 % 10], res_lo,
34
 
      [#include <stddef.h>], result=?)
35
 
    _AC_COMPUTE_INT([sizeof (size_t) <= sizeof (unsigned int)], fits_in_uint,
36
 
      [#include <stddef.h>], result=?)
37
 
    if test "$fits_in_uint" = 1; then
38
 
      dnl Even though SIZE_MAX fits in an unsigned int, it must be of type
39
 
      dnl 'unsigned long' if the type 'size_t' is the same as 'unsigned long'.
40
 
      AC_TRY_COMPILE([#include <stddef.h>
41
 
        extern size_t foo;
42
 
        extern unsigned long foo;
43
 
        ], [], fits_in_uint=0)
44
 
    fi
45
 
    if test -z "$result"; then
46
 
      if test "$fits_in_uint" = 1; then
47
 
        result="$res_hi$res_lo"U
 
24
], gl_cv_size_max=yes)
 
25
    if test -z "$gl_cv_size_max"; then
 
26
      dnl Define it ourselves. Here we assume that the type 'size_t' is not wider
 
27
      dnl than the type 'unsigned long'. Try hard to find a definition that can
 
28
      dnl be used in a preprocessor #if, i.e. doesn't contain a cast.
 
29
      _AC_COMPUTE_INT([sizeof (size_t) * CHAR_BIT - 1], size_t_bits_minus_1,
 
30
        [#include <stddef.h>
 
31
#include <limits.h>], size_t_bits_minus_1=)
 
32
      _AC_COMPUTE_INT([sizeof (size_t) <= sizeof (unsigned int)], fits_in_uint,
 
33
        [#include <stddef.h>], fits_in_uint=)
 
34
      if test -n "$size_t_bits_minus_1" && test -n "$fits_in_uint"; then
 
35
        if test $fits_in_uint = 1; then
 
36
          dnl Even though SIZE_MAX fits in an unsigned int, it must be of type
 
37
          dnl 'unsigned long' if the type 'size_t' is the same as 'unsigned long'.
 
38
          AC_TRY_COMPILE([#include <stddef.h>
 
39
            extern size_t foo;
 
40
            extern unsigned long foo;
 
41
            ], [], fits_in_uint=0)
 
42
        fi
 
43
        dnl We cannot use 'expr' to simplify this expression, because 'expr'
 
44
        dnl works only with 'long' integers in the host environment, while we
 
45
        dnl might be cross-compiling from a 32-bit platform to a 64-bit platform.
 
46
        if test $fits_in_uint = 1; then
 
47
          gl_cv_size_max="(((1U << $size_t_bits_minus_1) - 1) * 2 + 1)"
 
48
        else
 
49
          gl_cv_size_max="(((1UL << $size_t_bits_minus_1) - 1) * 2 + 1)"
 
50
        fi
48
51
      else
49
 
        result="$res_hi$res_lo"UL
 
52
        dnl Shouldn't happen, but who knows...
 
53
        gl_cv_size_max='((size_t)~(size_t)0)'
50
54
      fi
51
 
    else
52
 
      dnl Shouldn't happen, but who knows...
53
 
      result='~(size_t)0'
54
55
    fi
55
 
  fi
56
 
  AC_MSG_RESULT([$result])
57
 
  if test "$result" != yes; then
58
 
    AC_DEFINE_UNQUOTED([SIZE_MAX], [$result],
 
56
  ])
 
57
  AC_MSG_RESULT([$gl_cv_size_max])
 
58
  if test "$gl_cv_size_max" != yes; then
 
59
    AC_DEFINE_UNQUOTED([SIZE_MAX], [$gl_cv_size_max],
59
60
      [Define as the maximum value of type 'size_t', if the system doesn't define it.])
60
61
  fi
61
62
])