~ubuntu-branches/ubuntu/hardy/sigscheme/hardy-proposed

« back to all changes in this revision

Viewing changes to m4/ax_create_stdint_h.m4

  • Committer: Bazaar Package Importer
  • Author(s): NIIBE Yutaka
  • Date: 2007-01-29 15:31:24 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070129153124-j5fcqyrwcfbczma7
Tags: 0.7.4-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
dnl @synopsis AX_CREATE_STDINT_H [( HEADER-TO-GENERATE [, HEDERS-TO-CHECK])]
2
 
dnl
3
 
dnl the "ISO C9X: 7.18 Integer types <stdint.h>" section requires the
4
 
dnl existence of an include file <stdint.h> that defines a set of
5
 
dnl typedefs, especially uint8_t,int32_t,uintptr_t. Many older
6
 
dnl installations will not provide this file, but some will have the
7
 
dnl very same definitions in <inttypes.h>. In other enviroments we can
8
 
dnl use the inet-types in <sys/types.h> which would define the typedefs
9
 
dnl int8_t and u_int8_t respectivly.
10
 
dnl
11
 
dnl This macros will create a local "_stdint.h" or the headerfile given
12
 
dnl as an argument. In many cases that file will just "#include
13
 
dnl <stdint.h>" or "#include <inttypes.h>", while in other environments
14
 
dnl it will provide the set of basic 'stdint's definitions/typedefs:
15
 
dnl
16
 
dnl   int8_t,uint8_t,int16_t,uint16_t,int32_t,uint32_t,intptr_t,uintptr_t
17
 
dnl   int_least32_t.. int_fast32_t.. intmax_t
18
 
dnl
19
 
dnl which may or may not rely on the definitions of other files, or
20
 
dnl using the AC_CHECK_SIZEOF macro to determine the actual sizeof each
21
 
dnl type.
22
 
dnl
23
 
dnl if your header files require the stdint-types you will want to
24
 
dnl create an installable file mylib-int.h that all your other
25
 
dnl installable header may include. So if you have a library package
26
 
dnl named "mylib", just use
27
 
dnl
28
 
dnl      AX_CREATE_STDINT_H(mylib-int.h)
29
 
dnl
30
 
dnl in configure.ac and go to install that very header file in
31
 
dnl Makefile.am along with the other headers (mylib.h) - and the
32
 
dnl mylib-specific headers can simply use "#include <mylib-int.h>" to
33
 
dnl obtain the stdint-types.
34
 
dnl
35
 
dnl Remember, if the system already had a valid <stdint.h>, the
36
 
dnl generated file will include it directly. No need for fuzzy
37
 
dnl HAVE_STDINT_H things...
38
 
dnl
39
 
dnl @category C
40
 
dnl @author Guido Draheim <guidod@gmx.de>
41
 
dnl @version 2003-12-07
42
 
dnl @license GPLWithACException
 
1
##### http://autoconf-archive.cryp.to/ax_create_stdint_h.html
 
2
#
 
3
# SYNOPSIS
 
4
#
 
5
#   AX_CREATE_STDINT_H [( HEADER-TO-GENERATE [, HEDERS-TO-CHECK])]
 
6
#
 
7
# DESCRIPTION
 
8
#
 
9
#   the "ISO C9X: 7.18 Integer types <stdint.h>" section requires the
 
10
#   existence of an include file <stdint.h> that defines a set of
 
11
#   typedefs, especially uint8_t,int32_t,uintptr_t. Many older
 
12
#   installations will not provide this file, but some will have the
 
13
#   very same definitions in <inttypes.h>. In other enviroments we can
 
14
#   use the inet-types in <sys/types.h> which would define the typedefs
 
15
#   int8_t and u_int8_t respectivly.
 
16
#
 
17
#   This macros will create a local "_stdint.h" or the headerfile given
 
18
#   as an argument. In many cases that file will just "#include
 
19
#   <stdint.h>" or "#include <inttypes.h>", while in other environments
 
20
#   it will provide the set of basic 'stdint's definitions/typedefs:
 
21
#
 
22
#     int8_t,uint8_t,int16_t,uint16_t,int32_t,uint32_t,intptr_t,uintptr_t
 
23
#     int_least32_t.. int_fast32_t.. intmax_t
 
24
#
 
25
#   which may or may not rely on the definitions of other files, or
 
26
#   using the AC_CHECK_SIZEOF macro to determine the actual sizeof each
 
27
#   type.
 
28
#
 
29
#   if your header files require the stdint-types you will want to
 
30
#   create an installable file mylib-int.h that all your other
 
31
#   installable header may include. So if you have a library package
 
32
#   named "mylib", just use
 
33
#
 
34
#        AX_CREATE_STDINT_H(mylib-int.h)
 
35
#
 
36
#   in configure.ac and go to install that very header file in
 
37
#   Makefile.am along with the other headers (mylib.h) - and the
 
38
#   mylib-specific headers can simply use "#include <mylib-int.h>" to
 
39
#   obtain the stdint-types.
 
40
#
 
41
#   Remember, if the system already had a valid <stdint.h>, the
 
42
#   generated file will include it directly. No need for fuzzy
 
43
#   HAVE_STDINT_H things... (oops, GCC 4.2.x has deliberatly disabled
 
44
#   its stdint.h for non-c99 compilation and the c99-mode is not the
 
45
#   default. Therefore this macro will not use the compiler's stdint.h
 
46
#   - please complain to the GCC developers).
 
47
#
 
48
# LAST MODIFICATION
 
49
#
 
50
#   2006-10-13
 
51
#
 
52
# COPYLEFT
 
53
#
 
54
#   Copyright (c) 2006 Guido U. Draheim <guidod@gmx.de>
 
55
#
 
56
#   This program is free software; you can redistribute it and/or
 
57
#   modify it under the terms of the GNU General Public License as
 
58
#   published by the Free Software Foundation; either version 2 of the
 
59
#   License, or (at your option) any later version.
 
60
#
 
61
#   This program is distributed in the hope that it will be useful, but
 
62
#   WITHOUT ANY WARRANTY; without even the implied warranty of
 
63
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 
64
#   General Public License for more details.
 
65
#
 
66
#   You should have received a copy of the GNU General Public License
 
67
#   along with this program; if not, write to the Free Software
 
68
#   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 
69
#   02111-1307, USA.
 
70
#
 
71
#   As a special exception, the respective Autoconf Macro's copyright
 
72
#   owner gives unlimited permission to copy, distribute and modify the
 
73
#   configure scripts that are the output of Autoconf when processing
 
74
#   the Macro. You need not follow the terms of the GNU General Public
 
75
#   License when using or distributing such scripts, even though
 
76
#   portions of the text of the Macro appear in them. The GNU General
 
77
#   Public License (GPL) does govern all other use of the material that
 
78
#   constitutes the Autoconf Macro.
 
79
#
 
80
#   This special exception to the GPL applies to versions of the
 
81
#   Autoconf Macro released by the Autoconf Macro Archive. When you
 
82
#   make and distribute a modified version of the Autoconf Macro, you
 
83
#   may extend this special exception to the GPL to apply to your
 
84
#   modified version as well.
43
85
 
44
86
AC_DEFUN([AX_CHECK_DATA_MODEL],[
45
87
   AC_CHECK_SIZEOF(char)
83
125
AC_CACHE_CHECK([for stdint uintptr_t], [ac_cv_header_stdint_x],[
84
126
 ac_cv_header_stdint_x="" # the 1997 typedefs (inttypes.h)
85
127
  AC_MSG_RESULT([(..)])
86
 
  for i in m4_ifval([$1],[$1],[stdint.h inttypes.h sys/inttypes.h]) ; do
 
128
  for i in m4_ifval([$1],[$1],[stdint.h inttypes.h sys/inttypes.h sys/types.h])
 
129
  do
87
130
   unset ac_cv_type_uintptr_t
88
131
   unset ac_cv_type_uint64_t
89
132
   AC_CHECK_TYPE(uintptr_t,[ac_cv_header_stdint_x=$i],continue,[#include <$i>])
98
141
AC_CACHE_CHECK([for stdint uint32_t], [ac_cv_header_stdint_o],[
99
142
 ac_cv_header_stdint_o="" # the 1995 typedefs (sys/inttypes.h)
100
143
  AC_MSG_RESULT([(..)])
101
 
  for i in m4_ifval([$1],[$1],[inttypes.h sys/inttypes.h stdint.h]) ; do
 
144
  for i in m4_ifval([$1],[$1],[inttypes.h sys/inttypes.h sys/types.h stdint.h])
 
145
  do
102
146
   unset ac_cv_type_uint32_t
103
147
   unset ac_cv_type_uint64_t
104
148
   AC_CHECK_TYPE(uint32_t,[ac_cv_header_stdint_o=$i],continue,[#include <$i>])
140
184
[ac_cv_stdint_result="(assuming C99 compatible system)"
141
185
 ac_cv_header_stdint_t="stdint.h"; ],
142
186
[ac_cv_header_stdint_t=""])
 
187
if test "$GCC" = "yes" && test ".$ac_cv_header_stdint_t" = "."; then
 
188
CFLAGS="-std=c99"
 
189
AC_TRY_COMPILE([#include <stdint.h>],[int_least32_t v = 0;],
 
190
[AC_MSG_WARN(your GCC compiler has a defunct stdint.h for its default-mode)])
 
191
fi
143
192
CXXFLAGS="$old_CXXFLAGS"
144
193
CPPFLAGS="$old_CPPFLAGS"
145
194
CFLAGS="$old_CFLAGS" ])
560
609
#define __intptr_t_defined
561
610
/* we encourage using "long" to store pointer values, never use "int" ! */
562
611
#if   _STDINT_LONG_MODEL+0 == 242 || _STDINT_LONG_MODEL+0 == 484
563
 
typedef  unsinged int   uintptr_t;
 
612
typedef  unsigned int   uintptr_t;
564
613
typedef           int    intptr_t;
565
614
#elif _STDINT_LONG_MODEL+0 == 244 || _STDINT_LONG_MODEL+0 == 444
566
615
typedef  unsigned long  uintptr_t;