mirror of
git://git.sv.gnu.org/autoconf
synced 2024-11-21 01:01:48 +08:00
Find a means to extract integers from the compiler.
Use this technology to compute `sizeof' even when cross-compiling. Ideas and initial suggestion by Kaveh Ghazi. Binary search by Bruno Haible. * aclang.m4 (AC_LANG_BOOL_COMPILE_TRY, AC_LANG_BOOL_COMPILE_TRY(C), AC_LANG_BOOL_COMPILE_TRY(C++), AC_LANG_INT_SAVE, AC_LANG_INT_SAVE(C), AC_LANG_INT_SAVE(C++)): New macros. * acgeneral.m4 (_AC_COMPUTE_INT_COMPILE, _AC_COMPUTE_INT_RUN, _AC_COMPUTE_INT): New. (AC_CHECK_SIZEOF): Use them. Check whether the type exists beforehand. * tests/semantics.m4 (AC_CHECK_SIZEOF): Strengthen.
This commit is contained in:
parent
3bfdd156e9
commit
ca10061659
17
ChangeLog
17
ChangeLog
@ -1,3 +1,20 @@
|
||||
2000-05-26 Akim Demaille <akim@epita.fr>
|
||||
|
||||
Find a means to extract integers from the compiler.
|
||||
Use this technology to compute `sizeof' even when cross-compiling.
|
||||
Ideas and initial suggestion by Kaveh Ghazi.
|
||||
Binary search by Bruno Haible.
|
||||
|
||||
* aclang.m4 (AC_LANG_BOOL_COMPILE_TRY,
|
||||
AC_LANG_BOOL_COMPILE_TRY(C), AC_LANG_BOOL_COMPILE_TRY(C++),
|
||||
AC_LANG_INT_SAVE, AC_LANG_INT_SAVE(C), AC_LANG_INT_SAVE(C++)): New
|
||||
macros.
|
||||
* acgeneral.m4 (_AC_COMPUTE_INT_COMPILE, _AC_COMPUTE_INT_RUN,
|
||||
_AC_COMPUTE_INT): New.
|
||||
(AC_CHECK_SIZEOF): Use them.
|
||||
Check whether the type exists beforehand.
|
||||
* tests/semantics.m4 (AC_CHECK_SIZEOF): Strengthen.
|
||||
|
||||
2000-05-26 Ossama Othman <ossama@ece.uci.edu>
|
||||
|
||||
* aclang.m4 (AC_PROG_CXX): Look for aCC KCC RCC xlC_r xlC.
|
||||
|
3
NEWS
3
NEWS
@ -173,6 +173,9 @@ test cases in this new frame work.
|
||||
- AC_PROG_LEX
|
||||
Now integrates `AC_DECL_YYTEXT' which is obsoleted.
|
||||
|
||||
- AC_CHECK_SIZEOF
|
||||
No longer needs a cross-compilation size.
|
||||
|
||||
** C++ compatibility
|
||||
Every macro has been revisited in order to support at best CC=c++.
|
||||
|
||||
|
88
acgeneral.m4
88
acgeneral.m4
@ -3167,36 +3167,76 @@ AC_CHECK_FUNCS([$1], , [AC_LIBOBJ(${ac_func})])
|
||||
])
|
||||
|
||||
|
||||
|
||||
## ----------------------------------- ##
|
||||
## Checking compiler characteristics. ##
|
||||
## ----------------------------------- ##
|
||||
|
||||
|
||||
# AC_CHECK_SIZEOF(TYPE, [CROSS-SIZE], [INCLUDES])
|
||||
# -----------------------------------------------
|
||||
# This macro will probably be obsoleted by the macros of Kaveh. In
|
||||
# addition `CHECK' is not a proper name (is not boolean).
|
||||
# _AC_COMPUTE_INT_COMPILE(EXPRESSION, VARIABLE, [INCLUDES])
|
||||
# ---------------------------------------------------------
|
||||
# Compute the integer EXPRESSION and store the result in the VARIABLE.
|
||||
# Works OK if cross compiling.
|
||||
define([_AC_COMPUTE_INT_COMPILE],
|
||||
[# Depending upon the size, compute the lo and hi bounds.
|
||||
AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([$3], [($1) >= 0])],
|
||||
[ac_lo=0 ac_try=0
|
||||
while true; do
|
||||
AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([$3], [($1) <= $ac_try])],
|
||||
[ac_hi=$ac_try; break],
|
||||
[ac_lo=`expr $ac_try + 1` ac_try=`expr 2 '*' $ac_try + 1`])
|
||||
done],
|
||||
[ac_hi=-1 ac_try=-1
|
||||
while true; do
|
||||
AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([$3], [($1) >= $ac_try])],
|
||||
[ac_lo=$ac_try; break],
|
||||
[ac_hi=`expr $ac_try - 1` ac_try=`expr 2 '*' $ac_try`])
|
||||
done])
|
||||
# Binary search between lo and hi bounds.
|
||||
while test "x$ac_lo" != "x$ac_hi"; do
|
||||
ac_try=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo`
|
||||
AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([$3], [($1) <= $ac_try])],
|
||||
[ac_hi=$ac_try], [ac_lo=`expr $ac_try + 1`])
|
||||
done
|
||||
$2=$ac_lo[]dnl
|
||||
])# _AC_COMPUTE_INT_COMPILE
|
||||
|
||||
|
||||
# _AC_COMPUTE_INT_RUN(EXPRESSION, VARIABLE, [INCLUDES], [IF-FAILS])
|
||||
# -----------------------------------------------------------------
|
||||
# Store the evaluation of the integer EXPRESSION in VARIABLE.
|
||||
define([_AC_COMPUTE_INT_RUN],
|
||||
[AC_RUN_IFELSE([AC_LANG_INT_SAVE([$3], [$1])],
|
||||
[$2=`cat conftestval`], [$4])])
|
||||
|
||||
|
||||
# _AC_COMPUTE_INT(EXPRESSION, VARIABLE, INCLUDES, IF-FAILS)
|
||||
# ---------------------------------------------------------
|
||||
define([_AC_COMPUTE_INT],
|
||||
[if test "$cross_compiling" = yes; then
|
||||
_AC_COMPUTE_INT_COMPILE([$1], [$2], [$3])
|
||||
else
|
||||
_AC_COMPUTE_INT_RUN([$1], [$2], [$3], [$4])
|
||||
fi[]dnl
|
||||
])# _AC_COMPUTE_INT
|
||||
|
||||
|
||||
# AC_CHECK_SIZEOF(TYPE, [IGNORED], [INCLUDES])
|
||||
# --------------------------------------------
|
||||
AC_DEFUN([AC_CHECK_SIZEOF],
|
||||
[AC_VAR_PUSHDEF([ac_Sizeof], [ac_cv_sizeof_$1])dnl
|
||||
AC_CACHE_CHECK([size of $1], ac_Sizeof,
|
||||
[AC_TRY_RUN(AC_INCLUDES_DEFAULT([$3])
|
||||
[int
|
||||
main ()
|
||||
{
|
||||
FILE *f = fopen ("conftestval", "w");
|
||||
if (!f)
|
||||
exit (1);
|
||||
fprintf (f, "%d\n", sizeof ($1));
|
||||
exit (0);
|
||||
}],
|
||||
AC_VAR_SET(ac_Sizeof, `cat conftestval`),
|
||||
AC_VAR_SET(ac_Sizeof, 0),
|
||||
ifval([$2], AC_VAR_SET(ac_Sizeof, $2)))])
|
||||
AC_DEFINE_UNQUOTED(AC_TR_CPP(sizeof_$1),
|
||||
AC_VAR_GET(ac_Sizeof),
|
||||
[The number of bytes in a `]$1['.])
|
||||
AC_VAR_POPDEF([ac_Sizeof])dnl
|
||||
])
|
||||
[AC_VAR_IF_INDIR([$1], [AC_FATAL([$0: requires literal arguments])])dnl
|
||||
AC_CHECK_TYPE([$1], [], [], [$3])
|
||||
AC_CACHE_CHECK([size of $1], AC_TR_SH([ac_cv_sizeof_$1]),
|
||||
[if test "$AC_TR_SH([ac_cv_type_$1])" = yes; then
|
||||
_AC_COMPUTE_INT([sizeof ($1)],
|
||||
[AC_TR_SH([ac_cv_sizeof_$1])],
|
||||
[AC_INCLUDES_DEFAULT([$3])])
|
||||
else
|
||||
AC_TR_SH([ac_cv_sizeof_$1])=0
|
||||
fi])dnl
|
||||
AC_DEFINE_UNQUOTED(AC_TR_CPP(sizeof_$1), $AC_TR_SH([ac_cv_sizeof_$1]),
|
||||
[The size of a `$1', as computed by sizeof.])
|
||||
])# AC_CHECK_SIZEOF
|
||||
|
||||
|
||||
|
||||
|
45
aclang.m4
45
aclang.m4
@ -263,6 +263,21 @@ AC_DEFUN([AC_LANG_FUNC_LINK_TRY],
|
||||
[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
|
||||
|
||||
|
||||
# AC_LANG_BOOL_COMPILE_TRY(PROLOGUE, EXPRESSION)
|
||||
# ----------------------------------------------
|
||||
# Produce a program that compiles with success iff the boolean EXPRESSION
|
||||
# evaluates to true at compile time.
|
||||
AC_DEFUN([AC_LANG_BOOL_COMPILE_TRY],
|
||||
[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
|
||||
|
||||
|
||||
# AC_LANG_INT_SAVE(PROLOGUE, EXPRESSION)
|
||||
# --------------------------------------
|
||||
# Produce a program that saves the runtime evaluation of the integer
|
||||
# EXPRESSION into `conftestval'.
|
||||
AC_DEFUN([AC_LANG_INT_SAVE],
|
||||
[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
|
||||
|
||||
|
||||
# --------------- #
|
||||
# 2b. C sources. #
|
||||
@ -338,6 +353,24 @@ f = $1;
|
||||
])])
|
||||
|
||||
|
||||
# AC_LANG_BOOL_COMPILE_TRY(C)(PROLOGUE, EXPRESSION)
|
||||
# -------------------------------------------------
|
||||
define([AC_LANG_BOOL_COMPILE_TRY(C)],
|
||||
[AC_LANG_PROGRAM([$1], [int _array_ @<:@1 - 2 * !($2)@:>@])])
|
||||
|
||||
|
||||
# AC_LANG_INT_SAVE(C)(PROLOGUE, EXPRESSION)
|
||||
# -----------------------------------------
|
||||
# We need `stdio.h' to open a `FILE', so the prologue defaults to the
|
||||
# inclusion of `stdio.h'.
|
||||
define([AC_LANG_INT_SAVE(C)],
|
||||
[AC_LANG_PROGRAM([m4_default([$1], [@%:@include "stdio.h"])],
|
||||
[FILE *f = fopen ("conftestval", "w");
|
||||
if (!f)
|
||||
exit (1);
|
||||
fprintf (f, "%d\n", ($2));])])
|
||||
|
||||
|
||||
# ----------------- #
|
||||
# 2c. C++ sources. #
|
||||
# ----------------- #
|
||||
@ -371,6 +404,18 @@ define([AC_LANG_CALL(C++)], defn([AC_LANG_CALL(C)]))
|
||||
define([AC_LANG_FUNC_LINK_TRY(C++)], defn([AC_LANG_FUNC_LINK_TRY(C)]))
|
||||
|
||||
|
||||
# AC_LANG_BOOL_COMPILE_TRY(C++)(PROLOGUE, EXPRESSION)
|
||||
# ---------------------------------------------------
|
||||
# Same as C.
|
||||
define([AC_LANG_BOOL_COMPILE_TRY(C++)], defn([AC_LANG_BOOL_COMPILE_TRY(C)]))
|
||||
|
||||
|
||||
# AC_LANG_INT_SAVE(C++)(PROLOGUE, EXPRESSION)
|
||||
# -------------------------------------------
|
||||
# Same as C.
|
||||
define([AC_LANG_INT_SAVE(C++)], defn([AC_LANG_INT_SAVE_TRY(C)]))
|
||||
|
||||
|
||||
|
||||
# ------------------------ #
|
||||
# 1d. Fortran 77 sources. #
|
||||
|
@ -3907,7 +3907,7 @@ size_t my_strlen PARAMS ((const char *));
|
||||
|
||||
@c FIXME: What the heck is this macro doing here? Move it out of
|
||||
@c the way, in its proper section!!!
|
||||
@defmac AC_CHECK_SIZEOF (@var{type}, @ovar{cross-size}, @ovar{includes})
|
||||
@defmac AC_CHECK_SIZEOF (@var{type}, @ovar{unused}, @ovar{includes})
|
||||
@maindex CHECK_SIZEOF
|
||||
Define @code{SIZEOF_@var{type}} (@pxref{Standard Symbols}) to be the
|
||||
size in bytes of @var{type}. If @samp{type} is unknown, it gets a size
|
||||
@ -3915,8 +3915,8 @@ of 0. If no @var{includes} are specified, the default includes are used
|
||||
(@pxref{Default Includes}). If you provide @var{include}, make sure to
|
||||
include @file{stdio.h} which is required for this macro to run.
|
||||
|
||||
If cross-compiling, the value @var{cross-size} is used if given,
|
||||
otherwise @code{configure} exits with an error message.
|
||||
This macro now works even when cross-compiling. The @var{unused}
|
||||
argument was used when cross-compiling.
|
||||
|
||||
For example, the call
|
||||
|
||||
|
@ -263,6 +263,21 @@ AC_DEFUN([AC_LANG_FUNC_LINK_TRY],
|
||||
[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
|
||||
|
||||
|
||||
# AC_LANG_BOOL_COMPILE_TRY(PROLOGUE, EXPRESSION)
|
||||
# ----------------------------------------------
|
||||
# Produce a program that compiles with success iff the boolean EXPRESSION
|
||||
# evaluates to true at compile time.
|
||||
AC_DEFUN([AC_LANG_BOOL_COMPILE_TRY],
|
||||
[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
|
||||
|
||||
|
||||
# AC_LANG_INT_SAVE(PROLOGUE, EXPRESSION)
|
||||
# --------------------------------------
|
||||
# Produce a program that saves the runtime evaluation of the integer
|
||||
# EXPRESSION into `conftestval'.
|
||||
AC_DEFUN([AC_LANG_INT_SAVE],
|
||||
[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
|
||||
|
||||
|
||||
# --------------- #
|
||||
# 2b. C sources. #
|
||||
@ -338,6 +353,24 @@ f = $1;
|
||||
])])
|
||||
|
||||
|
||||
# AC_LANG_BOOL_COMPILE_TRY(C)(PROLOGUE, EXPRESSION)
|
||||
# -------------------------------------------------
|
||||
define([AC_LANG_BOOL_COMPILE_TRY(C)],
|
||||
[AC_LANG_PROGRAM([$1], [int _array_ @<:@1 - 2 * !($2)@:>@])])
|
||||
|
||||
|
||||
# AC_LANG_INT_SAVE(C)(PROLOGUE, EXPRESSION)
|
||||
# -----------------------------------------
|
||||
# We need `stdio.h' to open a `FILE', so the prologue defaults to the
|
||||
# inclusion of `stdio.h'.
|
||||
define([AC_LANG_INT_SAVE(C)],
|
||||
[AC_LANG_PROGRAM([m4_default([$1], [@%:@include "stdio.h"])],
|
||||
[FILE *f = fopen ("conftestval", "w");
|
||||
if (!f)
|
||||
exit (1);
|
||||
fprintf (f, "%d\n", ($2));])])
|
||||
|
||||
|
||||
# ----------------- #
|
||||
# 2c. C++ sources. #
|
||||
# ----------------- #
|
||||
@ -371,6 +404,18 @@ define([AC_LANG_CALL(C++)], defn([AC_LANG_CALL(C)]))
|
||||
define([AC_LANG_FUNC_LINK_TRY(C++)], defn([AC_LANG_FUNC_LINK_TRY(C)]))
|
||||
|
||||
|
||||
# AC_LANG_BOOL_COMPILE_TRY(C++)(PROLOGUE, EXPRESSION)
|
||||
# ---------------------------------------------------
|
||||
# Same as C.
|
||||
define([AC_LANG_BOOL_COMPILE_TRY(C++)], defn([AC_LANG_BOOL_COMPILE_TRY(C)]))
|
||||
|
||||
|
||||
# AC_LANG_INT_SAVE(C++)(PROLOGUE, EXPRESSION)
|
||||
# -------------------------------------------
|
||||
# Same as C.
|
||||
define([AC_LANG_INT_SAVE(C++)], defn([AC_LANG_INT_SAVE_TRY(C)]))
|
||||
|
||||
|
||||
|
||||
# ------------------------ #
|
||||
# 1d. Fortran 77 sources. #
|
||||
|
@ -263,6 +263,21 @@ AC_DEFUN([AC_LANG_FUNC_LINK_TRY],
|
||||
[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
|
||||
|
||||
|
||||
# AC_LANG_BOOL_COMPILE_TRY(PROLOGUE, EXPRESSION)
|
||||
# ----------------------------------------------
|
||||
# Produce a program that compiles with success iff the boolean EXPRESSION
|
||||
# evaluates to true at compile time.
|
||||
AC_DEFUN([AC_LANG_BOOL_COMPILE_TRY],
|
||||
[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
|
||||
|
||||
|
||||
# AC_LANG_INT_SAVE(PROLOGUE, EXPRESSION)
|
||||
# --------------------------------------
|
||||
# Produce a program that saves the runtime evaluation of the integer
|
||||
# EXPRESSION into `conftestval'.
|
||||
AC_DEFUN([AC_LANG_INT_SAVE],
|
||||
[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
|
||||
|
||||
|
||||
# --------------- #
|
||||
# 2b. C sources. #
|
||||
@ -338,6 +353,24 @@ f = $1;
|
||||
])])
|
||||
|
||||
|
||||
# AC_LANG_BOOL_COMPILE_TRY(C)(PROLOGUE, EXPRESSION)
|
||||
# -------------------------------------------------
|
||||
define([AC_LANG_BOOL_COMPILE_TRY(C)],
|
||||
[AC_LANG_PROGRAM([$1], [int _array_ @<:@1 - 2 * !($2)@:>@])])
|
||||
|
||||
|
||||
# AC_LANG_INT_SAVE(C)(PROLOGUE, EXPRESSION)
|
||||
# -----------------------------------------
|
||||
# We need `stdio.h' to open a `FILE', so the prologue defaults to the
|
||||
# inclusion of `stdio.h'.
|
||||
define([AC_LANG_INT_SAVE(C)],
|
||||
[AC_LANG_PROGRAM([m4_default([$1], [@%:@include "stdio.h"])],
|
||||
[FILE *f = fopen ("conftestval", "w");
|
||||
if (!f)
|
||||
exit (1);
|
||||
fprintf (f, "%d\n", ($2));])])
|
||||
|
||||
|
||||
# ----------------- #
|
||||
# 2c. C++ sources. #
|
||||
# ----------------- #
|
||||
@ -371,6 +404,18 @@ define([AC_LANG_CALL(C++)], defn([AC_LANG_CALL(C)]))
|
||||
define([AC_LANG_FUNC_LINK_TRY(C++)], defn([AC_LANG_FUNC_LINK_TRY(C)]))
|
||||
|
||||
|
||||
# AC_LANG_BOOL_COMPILE_TRY(C++)(PROLOGUE, EXPRESSION)
|
||||
# ---------------------------------------------------
|
||||
# Same as C.
|
||||
define([AC_LANG_BOOL_COMPILE_TRY(C++)], defn([AC_LANG_BOOL_COMPILE_TRY(C)]))
|
||||
|
||||
|
||||
# AC_LANG_INT_SAVE(C++)(PROLOGUE, EXPRESSION)
|
||||
# -------------------------------------------
|
||||
# Same as C.
|
||||
define([AC_LANG_INT_SAVE(C++)], defn([AC_LANG_INT_SAVE_TRY(C)]))
|
||||
|
||||
|
||||
|
||||
# ------------------------ #
|
||||
# 1d. Fortran 77 sources. #
|
||||
|
@ -3167,36 +3167,76 @@ AC_CHECK_FUNCS([$1], , [AC_LIBOBJ(${ac_func})])
|
||||
])
|
||||
|
||||
|
||||
|
||||
## ----------------------------------- ##
|
||||
## Checking compiler characteristics. ##
|
||||
## ----------------------------------- ##
|
||||
|
||||
|
||||
# AC_CHECK_SIZEOF(TYPE, [CROSS-SIZE], [INCLUDES])
|
||||
# -----------------------------------------------
|
||||
# This macro will probably be obsoleted by the macros of Kaveh. In
|
||||
# addition `CHECK' is not a proper name (is not boolean).
|
||||
# _AC_COMPUTE_INT_COMPILE(EXPRESSION, VARIABLE, [INCLUDES])
|
||||
# ---------------------------------------------------------
|
||||
# Compute the integer EXPRESSION and store the result in the VARIABLE.
|
||||
# Works OK if cross compiling.
|
||||
define([_AC_COMPUTE_INT_COMPILE],
|
||||
[# Depending upon the size, compute the lo and hi bounds.
|
||||
AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([$3], [($1) >= 0])],
|
||||
[ac_lo=0 ac_try=0
|
||||
while true; do
|
||||
AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([$3], [($1) <= $ac_try])],
|
||||
[ac_hi=$ac_try; break],
|
||||
[ac_lo=`expr $ac_try + 1` ac_try=`expr 2 '*' $ac_try + 1`])
|
||||
done],
|
||||
[ac_hi=-1 ac_try=-1
|
||||
while true; do
|
||||
AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([$3], [($1) >= $ac_try])],
|
||||
[ac_lo=$ac_try; break],
|
||||
[ac_hi=`expr $ac_try - 1` ac_try=`expr 2 '*' $ac_try`])
|
||||
done])
|
||||
# Binary search between lo and hi bounds.
|
||||
while test "x$ac_lo" != "x$ac_hi"; do
|
||||
ac_try=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo`
|
||||
AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([$3], [($1) <= $ac_try])],
|
||||
[ac_hi=$ac_try], [ac_lo=`expr $ac_try + 1`])
|
||||
done
|
||||
$2=$ac_lo[]dnl
|
||||
])# _AC_COMPUTE_INT_COMPILE
|
||||
|
||||
|
||||
# _AC_COMPUTE_INT_RUN(EXPRESSION, VARIABLE, [INCLUDES], [IF-FAILS])
|
||||
# -----------------------------------------------------------------
|
||||
# Store the evaluation of the integer EXPRESSION in VARIABLE.
|
||||
define([_AC_COMPUTE_INT_RUN],
|
||||
[AC_RUN_IFELSE([AC_LANG_INT_SAVE([$3], [$1])],
|
||||
[$2=`cat conftestval`], [$4])])
|
||||
|
||||
|
||||
# _AC_COMPUTE_INT(EXPRESSION, VARIABLE, INCLUDES, IF-FAILS)
|
||||
# ---------------------------------------------------------
|
||||
define([_AC_COMPUTE_INT],
|
||||
[if test "$cross_compiling" = yes; then
|
||||
_AC_COMPUTE_INT_COMPILE([$1], [$2], [$3])
|
||||
else
|
||||
_AC_COMPUTE_INT_RUN([$1], [$2], [$3], [$4])
|
||||
fi[]dnl
|
||||
])# _AC_COMPUTE_INT
|
||||
|
||||
|
||||
# AC_CHECK_SIZEOF(TYPE, [IGNORED], [INCLUDES])
|
||||
# --------------------------------------------
|
||||
AC_DEFUN([AC_CHECK_SIZEOF],
|
||||
[AC_VAR_PUSHDEF([ac_Sizeof], [ac_cv_sizeof_$1])dnl
|
||||
AC_CACHE_CHECK([size of $1], ac_Sizeof,
|
||||
[AC_TRY_RUN(AC_INCLUDES_DEFAULT([$3])
|
||||
[int
|
||||
main ()
|
||||
{
|
||||
FILE *f = fopen ("conftestval", "w");
|
||||
if (!f)
|
||||
exit (1);
|
||||
fprintf (f, "%d\n", sizeof ($1));
|
||||
exit (0);
|
||||
}],
|
||||
AC_VAR_SET(ac_Sizeof, `cat conftestval`),
|
||||
AC_VAR_SET(ac_Sizeof, 0),
|
||||
ifval([$2], AC_VAR_SET(ac_Sizeof, $2)))])
|
||||
AC_DEFINE_UNQUOTED(AC_TR_CPP(sizeof_$1),
|
||||
AC_VAR_GET(ac_Sizeof),
|
||||
[The number of bytes in a `]$1['.])
|
||||
AC_VAR_POPDEF([ac_Sizeof])dnl
|
||||
])
|
||||
[AC_VAR_IF_INDIR([$1], [AC_FATAL([$0: requires literal arguments])])dnl
|
||||
AC_CHECK_TYPE([$1], [], [], [$3])
|
||||
AC_CACHE_CHECK([size of $1], AC_TR_SH([ac_cv_sizeof_$1]),
|
||||
[if test "$AC_TR_SH([ac_cv_type_$1])" = yes; then
|
||||
_AC_COMPUTE_INT([sizeof ($1)],
|
||||
[AC_TR_SH([ac_cv_sizeof_$1])],
|
||||
[AC_INCLUDES_DEFAULT([$3])])
|
||||
else
|
||||
AC_TR_SH([ac_cv_sizeof_$1])=0
|
||||
fi])dnl
|
||||
AC_DEFINE_UNQUOTED(AC_TR_CPP(sizeof_$1), $AC_TR_SH([ac_cv_sizeof_$1]),
|
||||
[The size of a `$1', as computed by sizeof.])
|
||||
])# AC_CHECK_SIZEOF
|
||||
|
||||
|
||||
|
||||
|
@ -263,6 +263,21 @@ AC_DEFUN([AC_LANG_FUNC_LINK_TRY],
|
||||
[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
|
||||
|
||||
|
||||
# AC_LANG_BOOL_COMPILE_TRY(PROLOGUE, EXPRESSION)
|
||||
# ----------------------------------------------
|
||||
# Produce a program that compiles with success iff the boolean EXPRESSION
|
||||
# evaluates to true at compile time.
|
||||
AC_DEFUN([AC_LANG_BOOL_COMPILE_TRY],
|
||||
[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
|
||||
|
||||
|
||||
# AC_LANG_INT_SAVE(PROLOGUE, EXPRESSION)
|
||||
# --------------------------------------
|
||||
# Produce a program that saves the runtime evaluation of the integer
|
||||
# EXPRESSION into `conftestval'.
|
||||
AC_DEFUN([AC_LANG_INT_SAVE],
|
||||
[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
|
||||
|
||||
|
||||
# --------------- #
|
||||
# 2b. C sources. #
|
||||
@ -338,6 +353,24 @@ f = $1;
|
||||
])])
|
||||
|
||||
|
||||
# AC_LANG_BOOL_COMPILE_TRY(C)(PROLOGUE, EXPRESSION)
|
||||
# -------------------------------------------------
|
||||
define([AC_LANG_BOOL_COMPILE_TRY(C)],
|
||||
[AC_LANG_PROGRAM([$1], [int _array_ @<:@1 - 2 * !($2)@:>@])])
|
||||
|
||||
|
||||
# AC_LANG_INT_SAVE(C)(PROLOGUE, EXPRESSION)
|
||||
# -----------------------------------------
|
||||
# We need `stdio.h' to open a `FILE', so the prologue defaults to the
|
||||
# inclusion of `stdio.h'.
|
||||
define([AC_LANG_INT_SAVE(C)],
|
||||
[AC_LANG_PROGRAM([m4_default([$1], [@%:@include "stdio.h"])],
|
||||
[FILE *f = fopen ("conftestval", "w");
|
||||
if (!f)
|
||||
exit (1);
|
||||
fprintf (f, "%d\n", ($2));])])
|
||||
|
||||
|
||||
# ----------------- #
|
||||
# 2c. C++ sources. #
|
||||
# ----------------- #
|
||||
@ -371,6 +404,18 @@ define([AC_LANG_CALL(C++)], defn([AC_LANG_CALL(C)]))
|
||||
define([AC_LANG_FUNC_LINK_TRY(C++)], defn([AC_LANG_FUNC_LINK_TRY(C)]))
|
||||
|
||||
|
||||
# AC_LANG_BOOL_COMPILE_TRY(C++)(PROLOGUE, EXPRESSION)
|
||||
# ---------------------------------------------------
|
||||
# Same as C.
|
||||
define([AC_LANG_BOOL_COMPILE_TRY(C++)], defn([AC_LANG_BOOL_COMPILE_TRY(C)]))
|
||||
|
||||
|
||||
# AC_LANG_INT_SAVE(C++)(PROLOGUE, EXPRESSION)
|
||||
# -------------------------------------------
|
||||
# Same as C.
|
||||
define([AC_LANG_INT_SAVE(C++)], defn([AC_LANG_INT_SAVE_TRY(C)]))
|
||||
|
||||
|
||||
|
||||
# ------------------------ #
|
||||
# 1d. Fortran 77 sources. #
|
||||
|
@ -84,7 +84,6 @@ AT_TEST_MACRO(AC_CHECK_MEMBERS,
|
||||
])])
|
||||
|
||||
|
||||
|
||||
# AC_CHECK_SIZEOF
|
||||
# ---------------
|
||||
AT_TEST_MACRO(AC_CHECK_SIZEOF,
|
||||
@ -95,14 +94,30 @@ typedef struct
|
||||
{
|
||||
char a;
|
||||
char b;
|
||||
} charchar;])],
|
||||
} charchar;])
|
||||
AC_CHECK_SIZEOF(charcharchar)
|
||||
|
||||
# Exercize the code used when cross-compiling
|
||||
cross_compiling=yes
|
||||
AC_CHECK_SIZEOF(unsigned char)
|
||||
AC_CHECK_SIZEOF(ucharchar,,
|
||||
[#include <stdio.h>
|
||||
typedef struct
|
||||
{
|
||||
unsigned char a;
|
||||
unsigned char b;
|
||||
} ucharchar;])
|
||||
AC_CHECK_SIZEOF(ucharcharchar)],
|
||||
[AT_CHECK_DEFINES(
|
||||
[#define SIZEOF_CHAR 1
|
||||
#define SIZEOF_CHARCHAR 2
|
||||
#define SIZEOF_CHARCHARCHAR 0
|
||||
#define SIZEOF_UCHARCHAR 2
|
||||
#define SIZEOF_UCHARCHARCHAR 0
|
||||
#define SIZEOF_UNSIGNED_CHAR 1
|
||||
])])
|
||||
|
||||
|
||||
|
||||
# AC_CHECK_TYPES
|
||||
# --------------
|
||||
# Check that it performs the correct actions.
|
||||
|
Loading…
Reference in New Issue
Block a user