1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>
Autoconf Macro: ac_define_integer_bits
</title>
<link rel="stylesheet" type="text/css" href="ac-archive.css">
</head>
<body>
<table summary="web navigation" style="width:100%;">
<tbody>
<tr>
<td style="width:50%;" align="center">
<a href=
"http://autoconf-archive.cryp.to/ac_define_integer_bits.m4">Download M4
Source</a>
</td>
<td style="width:50%;" align="center">
<a href="macros-by-category.html">Macro Index Page</a>
</td>
</tr>
</tbody>
</table>
<hr>
<h1>
ac_define_integer_bits
</h1>
<h2>
Synopsis
</h2>
<p class="indent" style="white-space:nowrap;">
<code>AC_DEFINE_INTEGER_BITS (TYPE [, CANDIDATE-TYPE]...)</code>
</p>
<h2>
Description
</h2>
<div class="indent">
<p>
Given a TYPE of the form "int##_t" or "uint##_t", see if the datatype TYPE
is predefined. If not, then define TYPE -- both with AC_DEFINE and as a
shell variable -- to the first datatype of exactly ## bits in a list of
CANDIDATE-TYPEs. If none of the CANDIDATE-TYPEs contains exactly ## bits,
then set the TYPE shell variable to "no".
</p>
<p>
For example, the following ensures that uint64_t is defined as a 64-bit
datatype:
</p>
<pre>
AC_DEFINE_INTEGER_BITS(uint64_t, unsigned long long, unsigned __int64, long)
if test "$uint64_t" = no; then
AC_MSG_ERROR([unable to continue without a 64-bit datatype])
fi
</pre>
<p>
You should then put the following in your C code to ensure that all
datatypes defined by AC_DEFINE_INTEGER_BITS are visible to your program:
</p>
<pre>
#include "config.h"
#if HAVE_INTTYPES_H
# include <inttypes.h>
#else
# if HAVE_STDINT_H
# include <stdint.h>
# endif
#endif
</pre>
</div>
<h2>
Author
</h2>
<p class="indent">
Scott Pakin <pakin@uiuc.edu>
</p>
<h2>
Last Modified
</h2>
<p class="indent">
2002-01-31
</p>
<h2>
M4 Source Code
</h2>
<div class="indent">
<pre class="m4source">
AC_DEFUN([AC_DEFINE_INTEGER_BITS],
[m4_define([ac_datatype_bits], [m4_translit($1, [a-zA-Z_])])
m4_define([ac_datatype_bytes], [m4_eval(ac_datatype_bits/8)])
AC_CHECK_TYPE($1, ,
[
AC_MSG_NOTICE([trying to find a suitable ]ac_datatype_bytes[-byte replacement for $1])
$1=no
find_$1 ()
{
_AC_DEFINE_INTEGER_BITS_HELPER($@)
:
}
find_$1
AC_DEFINE_UNQUOTED($1, $$1,
[If not already defined, then define as a datatype of *exactly* ]ac_datatype_bits[ bits.])
])
])
dnl Iterate over arguments $2..$N, trying to find a good match for $1.
m4_define([_AC_DEFINE_INTEGER_BITS_HELPER],
[ifelse($2, , ,
[m4_define([ac_datatype_bits], [m4_translit($1, [a-zA-Z_])])
m4_define([ac_datatype_bytes], [m4_eval(ac_datatype_bits/8)])
AC_CHECK_SIZEOF($2)
if test "$AS_TR_SH(ac_cv_sizeof_$2)" -eq ac_datatype_bytes; then
$1="$2"
return
fi
_AC_DEFINE_INTEGER_BITS_HELPER($1, m4_shift(m4_shift($@)))
])
])
</pre>
</div>
</body>
</html>
|