Blame confdb/aclocal_cc.m4

Packit 0848f5
dnl AC_PROG_CC_GNU
Packit 0848f5
ifdef([AC_PROG_CC_GNU],,[AC_DEFUN([AC_PROG_CC_GNU],)])
Packit 0848f5
Packit 0848f5
dnl PAC_PROG_CC - reprioritize the C compiler search order
Packit 0848f5
AC_DEFUN([PAC_PROG_CC],[
Packit 0848f5
        dnl Many standard autoconf/automake/libtool macros, such as LT_INIT,
Packit 0848f5
        dnl perform an AC_REQUIRE([AC_PROG_CC]).  If this macro (PAC_PROG_CC)
Packit 0848f5
        dnl comes after LT_INIT (or similar) then the default compiler search
Packit 0848f5
        dnl path will be used instead.  This AC_BEFORE macro ensures that a
Packit 0848f5
        dnl warning will be emitted at autoconf-time (autogen.sh-time) to help
Packit 0848f5
        dnl developers notice this case.
Packit 0848f5
        AC_BEFORE([$0],[AC_PROG_CC])
Packit 0848f5
	PAC_PUSH_FLAG([CFLAGS])
Packit 0848f5
	AC_PROG_CC([icc pgcc xlc xlC pathcc gcc clang cc])
Packit 0848f5
	PAC_POP_FLAG([CFLAGS])
Packit 0848f5
])
Packit 0848f5
dnl
Packit 0848f5
dnl/*D
Packit 0848f5
dnl PAC_C_CHECK_COMPILER_OPTION - Check that a compiler option is accepted
Packit 0848f5
dnl without warning messages
Packit 0848f5
dnl
Packit 0848f5
dnl Synopsis:
Packit 0848f5
dnl PAC_C_CHECK_COMPILER_OPTION(optionname,action-if-ok,action-if-fail)
Packit 0848f5
dnl
Packit 0848f5
dnl Output Effects:
Packit 0848f5
dnl
Packit 0848f5
dnl If no actions are specified, a working value is added to 'COPTIONS'
Packit 0848f5
dnl
Packit 0848f5
dnl Notes:
Packit 0848f5
dnl This is now careful to check that the output is different, since 
Packit 0848f5
dnl some compilers are noisy.
Packit 0848f5
dnl 
Packit 0848f5
dnl We are extra careful to prototype the functions in case compiler options
Packit 0848f5
dnl that complain about poor code are in effect.
Packit 0848f5
dnl
Packit 0848f5
dnl Because this is a long script, we have ensured that you can pass a 
Packit 0848f5
dnl variable containing the option name as the first argument.
Packit 0848f5
dnl
Packit 0848f5
dnl D*/
Packit 0848f5
AC_DEFUN([PAC_C_CHECK_COMPILER_OPTION],[
Packit 0848f5
AC_MSG_CHECKING([whether C compiler accepts option $1])
Packit 0848f5
pac_opt="$1"
Packit 0848f5
AC_LANG_PUSH([C])
Packit 0848f5
CFLAGS_orig="$CFLAGS"
Packit 0848f5
CFLAGS_opt="$pac_opt $CFLAGS"
Packit 0848f5
pac_result="unknown"
Packit 0848f5
Packit 0848f5
AC_LANG_CONFTEST([
Packit 0848f5
	AC_LANG_PROGRAM([[#include <stdio.h>
Packit 0848f5
                          const char hw[] = "Hello, World\n";]],
Packit 0848f5
		[[fputs (hw, stdout);]])
Packit 0848f5
])
Packit 0848f5
CFLAGS="$CFLAGS_orig"
Packit 0848f5
rm -f pac_test1.log
Packit 0848f5
PAC_LINK_IFELSE_LOG([pac_test1.log], [], [
Packit 0848f5
    CFLAGS="$CFLAGS_opt"
Packit 0848f5
    rm -f pac_test2.log
Packit 0848f5
    PAC_LINK_IFELSE_LOG([pac_test2.log], [], [
Packit 0848f5
        PAC_RUNLOG_IFELSE([diff -b pac_test1.log pac_test2.log],
Packit 0848f5
                          [pac_result=yes],[pac_result=no])
Packit 0848f5
    ],[
Packit 0848f5
        pac_result=no
Packit 0848f5
    ])
Packit 0848f5
], [
Packit 0848f5
    pac_result=no
Packit 0848f5
])
Packit 0848f5
AC_MSG_RESULT([$pac_result])
Packit 0848f5
dnl Delete the conftest created by AC_LANG_CONFTEST.
Packit 0848f5
rm -f conftest.$ac_ext
Packit 0848f5
Packit 0848f5
# gcc 4.2.4 on 32-bit does not complain about the -Wno-type-limits option 
Packit 0848f5
# even though it doesn't support it.  However, when another warning is 
Packit 0848f5
# triggered, it gives an error that the option is not recognized.  So we 
Packit 0848f5
# need to test with a conftest file that will generate warnings.
Packit 0848f5
# 
Packit 0848f5
# add an extra switch, pac_c_check_compiler_option_prototest, to
Packit 0848f5
# disable this test just in case some new compiler does not like it.
Packit 0848f5
#
Packit 0848f5
# Linking with a program with an invalid prototype to ensure a compiler warning.
Packit 0848f5
Packit 0848f5
if test "$pac_result" = "yes" \
Packit 0848f5
     -a "$pac_c_check_compiler_option_prototest" != "no" ; then
Packit 0848f5
    AC_MSG_CHECKING([whether C compiler option $1 works with an invalid prototype program])
Packit 0848f5
    AC_LINK_IFELSE([
Packit 0848f5
        dnl We want a warning, but we don't want to inadvertently disable
Packit 0848f5
        dnl special warnings like -Werror-implicit-function-declaration (e.g.,
Packit 0848f5
        dnl in PAC_CC_STRICT) by compiling something that might actually be
Packit 0848f5
        dnl treated as an error by the compiler.  So we try to elicit an
Packit 0848f5
        dnl "unused variable" warning and/or an "uninitialized" warning with the
Packit 0848f5
        dnl test program below.
Packit 0848f5
        dnl
Packit 0848f5
        dnl The old sanity program was:
Packit 0848f5
        dnl   void main() {return 0;}
Packit 0848f5
        dnl which clang (but not GCC) would treat as an *error*, invalidating
Packit 0848f5
        dnl the test for any given parameter.
Packit 0848f5
        AC_LANG_SOURCE([int main(int argc, char **argv){ int foo, bar = 0; foo += 1; return foo; }])
Packit 0848f5
    ],[pac_result=yes],[pac_result=no])
Packit 0848f5
    AC_MSG_RESULT([$pac_result])
Packit 0848f5
fi
Packit 0848f5
#
Packit 0848f5
if test "$pac_result" = "yes" ; then
Packit 0848f5
    AC_MSG_CHECKING([whether routines compiled with $pac_opt can be linked with ones compiled without $pac_opt])
Packit 0848f5
    pac_result=unknown
Packit 0848f5
    CFLAGS="$CFLAGS_orig"
Packit 0848f5
    rm -f pac_test3.log
Packit 0848f5
    PAC_COMPILE_IFELSE_LOG([pac_test3.log], [
Packit 0848f5
        AC_LANG_SOURCE([
Packit 0848f5
            int foo(void);
Packit 0848f5
            int foo(void){return 0;}
Packit 0848f5
        ])
Packit 0848f5
    ],[
Packit 0848f5
        PAC_RUNLOG([mv conftest.$OBJEXT pac_conftest.$OBJEXT])
Packit 0848f5
        saved_LIBS="$LIBS"
Packit 0848f5
        LIBS="pac_conftest.$OBJEXT $LIBS"
Packit 0848f5
Packit 0848f5
        rm -f pac_test4.log
Packit 0848f5
        PAC_LINK_IFELSE_LOG([pac_test4.log], [AC_LANG_PROGRAM()], [
Packit 0848f5
            CFLAGS="$CFLAGS_opt"
Packit 0848f5
            rm -f pac_test5.log
Packit 0848f5
            PAC_LINK_IFELSE_LOG([pac_test5.log], [AC_LANG_PROGRAM()], [
Packit 0848f5
                PAC_RUNLOG_IFELSE([diff -b pac_test4.log pac_test5.log],
Packit 0848f5
                                  [pac_result=yes], [pac_result=no])
Packit 0848f5
            ],[
Packit 0848f5
                pac_result=no
Packit 0848f5
            ])
Packit 0848f5
        ],[
Packit 0848f5
            pac_result=no
Packit 0848f5
        ])
Packit 0848f5
        LIBS="$saved_LIBS"
Packit 0848f5
        rm -f pac_conftest.$OBJEXT
Packit 0848f5
    ],[
Packit 0848f5
        pac_result=no
Packit 0848f5
    ])
Packit 0848f5
    AC_MSG_RESULT([$pac_result])
Packit 0848f5
    rm -f pac_test3.log pac_test4.log pac_test5.log
Packit 0848f5
fi
Packit 0848f5
rm -f pac_test1.log pac_test2.log
Packit 0848f5
Packit 0848f5
dnl Restore CFLAGS before 2nd/3rd argument commands are executed,
Packit 0848f5
dnl as 2nd/3rd argument command could be modifying CFLAGS.
Packit 0848f5
CFLAGS="$CFLAGS_orig"
Packit 0848f5
if test "$pac_result" = "yes" ; then
Packit 0848f5
     ifelse([$2],[],[COPTIONS="$COPTIONS $1"],[$2])
Packit 0848f5
else
Packit 0848f5
     ifelse([$3],[],[:],[$3])
Packit 0848f5
fi
Packit 0848f5
AC_LANG_POP([C])
Packit 0848f5
])
Packit 0848f5
dnl
Packit 0848f5
dnl/*D
Packit 0848f5
dnl PAC_C_OPTIMIZATION - Determine C options for producing optimized code
Packit 0848f5
dnl
Packit 0848f5
dnl Synopsis
Packit 0848f5
dnl PAC_C_OPTIMIZATION([action if found])
Packit 0848f5
dnl
Packit 0848f5
dnl Output Effect:
Packit 0848f5
dnl Adds options to 'COPTIONS' if no other action is specified
Packit 0848f5
dnl 
Packit 0848f5
dnl Notes:
Packit 0848f5
dnl This is a temporary standin for compiler optimization.
Packit 0848f5
dnl It should try to match known systems to known compilers (checking, of
Packit 0848f5
dnl course), and then falling back to some common defaults.
Packit 0848f5
dnl Note that many compilers will complain about -g and aggressive
Packit 0848f5
dnl optimization.  
Packit 0848f5
dnl D*/
Packit 0848f5
AC_DEFUN([PAC_C_OPTIMIZATION],[
Packit 0848f5
    for copt in "-O4 -Ofast" "-Ofast" "-fast" "-O3" "-xO3" "-O" ; do
Packit 0848f5
        PAC_C_CHECK_COMPILER_OPTION($copt,found_opt=yes,found_opt=no)
Packit 0848f5
        if test "$found_opt" = "yes" ; then
Packit 0848f5
	    ifelse($1,,COPTIONS="$COPTIONS $copt",$1)
Packit 0848f5
	    break
Packit 0848f5
        fi
Packit 0848f5
    done
Packit 0848f5
    if test "$ac_cv_prog_gcc" = "yes" ; then
Packit 0848f5
	for copt in "-fomit-frame-pointer" "-finline-functions" \
Packit 0848f5
		 "-funroll-loops" ; do
Packit 0848f5
	    PAC_C_CHECK_COMPILER_OPTION($copt,found_opt=yes,found_opt=no)
Packit 0848f5
	    if test "$found_opt" = "yes" ; then
Packit 0848f5
	        ifelse($1,,COPTIONS="$COPTIONS $copt",$1)
Packit 0848f5
	        # no break because we're trying to add them all
Packit 0848f5
	    fi
Packit 0848f5
	done
Packit 0848f5
	# We could also look for architecture-specific gcc options
Packit 0848f5
    fi
Packit 0848f5
Packit 0848f5
])
Packit 0848f5
Packit 0848f5
dnl/*D
Packit 0848f5
dnl PAC_PROG_C_UNALIGNED_DOUBLES - Check that the C compiler allows unaligned
Packit 0848f5
dnl doubles
Packit 0848f5
dnl
Packit 0848f5
dnl Synopsis:
Packit 0848f5
dnl   PAC_PROG_C_UNALIGNED_DOUBLES(action-if-true,action-if-false,
Packit 0848f5
dnl       action-if-unknown)
Packit 0848f5
dnl
Packit 0848f5
dnl Notes:
Packit 0848f5
dnl 'action-if-unknown' is used in the case of cross-compilation.
Packit 0848f5
dnl D*/
Packit 0848f5
AC_DEFUN([PAC_PROG_C_UNALIGNED_DOUBLES],[
Packit 0848f5
AC_CACHE_CHECK([whether C compiler allows unaligned doubles],
Packit 0848f5
pac_cv_prog_c_unaligned_doubles,[
Packit 0848f5
AC_TRY_RUN([
Packit 0848f5
void fetch_double( v )
Packit 0848f5
double *v;
Packit 0848f5
{
Packit 0848f5
*v = 1.0;
Packit 0848f5
}
Packit 0848f5
int main( argc, argv )
Packit 0848f5
int argc;
Packit 0848f5
char **argv;
Packit 0848f5
{
Packit 0848f5
int p[4];
Packit 0848f5
double *p_val;
Packit 0848f5
fetch_double( (double *)&(p[0]) );
Packit 0848f5
p_val = (double *)&(p[0]);
Packit 0848f5
if (*p_val != 1.0) return 1;
Packit 0848f5
fetch_double( (double *)&(p[1]) );
Packit 0848f5
p_val = (double *)&(p[1]);
Packit 0848f5
if (*p_val != 1.0) return 1;
Packit 0848f5
return 0;
Packit 0848f5
}
Packit 0848f5
],pac_cv_prog_c_unaligned_doubles="yes",pac_cv_prog_c_unaligned_doubles="no",
Packit 0848f5
pac_cv_prog_c_unaligned_doubles="unknown")])
Packit 0848f5
ifelse($1,,,if test "X$pac_cv_prog_c_unaligned_doubles" = "yes" ; then 
Packit 0848f5
$1
Packit 0848f5
fi)
Packit 0848f5
ifelse($2,,,if test "X$pac_cv_prog_c_unaligned_doubles" = "no" ; then 
Packit 0848f5
$2
Packit 0848f5
fi)
Packit 0848f5
ifelse($3,,,if test "X$pac_cv_prog_c_unaligned_doubles" = "unknown" ; then 
Packit 0848f5
$3
Packit 0848f5
fi)
Packit 0848f5
])
Packit 0848f5
Packit 0848f5
dnl/*D 
Packit 0848f5
dnl PAC_PROG_C_WEAK_SYMBOLS - Test whether C supports weak alias symbols.
Packit 0848f5
dnl
Packit 0848f5
dnl Synopsis
Packit 0848f5
dnl PAC_PROG_C_WEAK_SYMBOLS(action-if-true,action-if-false)
Packit 0848f5
dnl
Packit 0848f5
dnl Output Effect:
Packit 0848f5
dnl Defines one of the following if a weak symbol pragma is found:
Packit 0848f5
dnl.vb
Packit 0848f5
dnl    HAVE_PRAGMA_WEAK - #pragma weak
Packit 0848f5
dnl    HAVE_PRAGMA_HP_SEC_DEF - #pragma _HP_SECONDARY_DEF
Packit 0848f5
dnl    HAVE_PRAGMA_CRI_DUP  - #pragma _CRI duplicate x as y
Packit 0848f5
dnl.ve
Packit 0848f5
dnl May also define
Packit 0848f5
dnl.vb
Packit 0848f5
dnl    HAVE_WEAK_ATTRIBUTE
Packit 0848f5
dnl.ve
Packit 0848f5
dnl if functions can be declared as 'int foo(...) __attribute__ ((weak));'
Packit 0848f5
dnl sets the shell variable pac_cv_attr_weak to yes.
Packit 0848f5
dnl Also checks for __attribute__((weak_import)) which is supported by
Packit 0848f5
dnl Apple in Mac OSX (at least in Darwin).  Note that this provides only
Packit 0848f5
dnl weak symbols, not weak aliases
Packit 0848f5
dnl 
Packit 0848f5
dnl D*/
Packit 0848f5
AC_DEFUN([PAC_PROG_C_WEAK_SYMBOLS],[
Packit 0848f5
pragma_extra_message=""
Packit 0848f5
AC_CACHE_CHECK([for type of weak symbol alias support],
Packit 0848f5
pac_cv_prog_c_weak_symbols,[
Packit 0848f5
# Test for weak symbol support...
Packit 0848f5
# We can't put # in the message because it causes autoconf to generate
Packit 0848f5
# incorrect code
Packit 0848f5
AC_TRY_LINK([
Packit 0848f5
extern int PFoo(int);
Packit 0848f5
#pragma weak PFoo = Foo
Packit 0848f5
int Foo(int a) { return a; }
Packit 0848f5
],[return PFoo(1);],has_pragma_weak=yes)
Packit 0848f5
#
Packit 0848f5
# Some systems (Linux ia64 and ecc, for example), support weak symbols
Packit 0848f5
# only within a single object file!  This tests that case.
Packit 0848f5
# Note that there is an extern int PFoo declaration before the
Packit 0848f5
# pragma.  Some compilers require this in order to make the weak symbol
Packit 0848f5
# externally visible.  
Packit 0848f5
if test "$has_pragma_weak" = yes ; then
Packit 0848f5
    PAC_COMPLINK_IFELSE([
Packit 0848f5
        AC_LANG_SOURCE([
Packit 0848f5
extern int PFoo(int);
Packit 0848f5
#pragma weak PFoo = Foo
Packit 0848f5
int Foo(int);
Packit 0848f5
int Foo(int a) { return a; }
Packit 0848f5
        ])
Packit 0848f5
    ],[
Packit 0848f5
        AC_LANG_SOURCE([
Packit 0848f5
extern int PFoo(int);
Packit 0848f5
int main(int argc, char **argv) {
Packit 0848f5
return PFoo(0);}
Packit 0848f5
        ])
Packit 0848f5
    ],[
Packit 0848f5
        PAC_COMPLINK_IFELSE([
Packit 0848f5
            AC_LANG_SOURCE([
Packit 0848f5
extern int PFoo(int);
Packit 0848f5
#pragma weak PFoo = Foo
Packit 0848f5
int Foo(int);
Packit 0848f5
int Foo(int a) { return a; }
Packit 0848f5
            ])
Packit 0848f5
        ],[
Packit 0848f5
            AC_LANG_SOURCE([
Packit 0848f5
extern int Foo(int);
Packit 0848f5
int PFoo(int a) { return a+1;}
Packit 0848f5
int main(int argc, char **argv) {
Packit 0848f5
return Foo(0);}
Packit 0848f5
            ])
Packit 0848f5
        ],[
Packit 0848f5
            pac_cv_prog_c_weak_symbols="pragma weak"
Packit 0848f5
        ],[
Packit 0848f5
            has_pragma_weak=0
Packit 0848f5
            pragma_extra_message="pragma weak accepted but does not work (probably creates two non-weak entries)"
Packit 0848f5
        ])
Packit 0848f5
    ],[
Packit 0848f5
        has_pragma_weak=0
Packit 0848f5
        pragma_extra_message="pragma weak accepted but does not work (probably creates two non-weak entries)"
Packit 0848f5
    ])
Packit 0848f5
fi
Packit 0848f5
dnl
Packit 0848f5
if test -z "$pac_cv_prog_c_weak_symbols" ; then 
Packit 0848f5
    AC_TRY_LINK([
Packit 0848f5
extern int PFoo(int);
Packit 0848f5
#pragma _HP_SECONDARY_DEF Foo  PFoo
Packit 0848f5
int Foo(int a) { return a; }
Packit 0848f5
],[return PFoo(1);],pac_cv_prog_c_weak_symbols="pragma _HP_SECONDARY_DEF")
Packit 0848f5
fi
Packit 0848f5
dnl
Packit 0848f5
if test -z "$pac_cv_prog_c_weak_symbols" ; then
Packit 0848f5
    AC_TRY_LINK([
Packit 0848f5
extern int PFoo(int);
Packit 0848f5
#pragma _CRI duplicate PFoo as Foo
Packit 0848f5
int Foo(int a) { return a; }
Packit 0848f5
],[return PFoo(1);],pac_cv_prog_c_weak_symbols="pragma _CRI duplicate x as y")
Packit 0848f5
fi
Packit 0848f5
dnl
Packit 0848f5
if test -z "$pac_cv_prog_c_weak_symbols" ; then
Packit 0848f5
    pac_cv_prog_c_weak_symbols="no"
Packit 0848f5
fi
Packit 0848f5
dnl
Packit 0848f5
dnl If there is an extra explanatory message, echo it now so that it
Packit 0848f5
dnl doesn't interfere with the cache result value
Packit 0848f5
if test -n "$pragma_extra_message" ; then
Packit 0848f5
    echo $pragma_extra_message
Packit 0848f5
fi
Packit 0848f5
dnl
Packit 0848f5
])
Packit 0848f5
if test "$pac_cv_prog_c_weak_symbols" != "no" ; then
Packit 0848f5
    case "$pac_cv_prog_c_weak_symbols" in
Packit 0848f5
        "pragma weak") AC_DEFINE(HAVE_PRAGMA_WEAK,1,[Supports weak pragma])
Packit 0848f5
        ;;
Packit 0848f5
        "pragma _HP")  AC_DEFINE(HAVE_PRAGMA_HP_SEC_DEF,1,[HP style weak pragma])
Packit 0848f5
        ;;
Packit 0848f5
        "pragma _CRI") AC_DEFINE(HAVE_PRAGMA_CRI_DUP,1,[Cray style weak pragma])
Packit 0848f5
        ;;
Packit 0848f5
    esac
Packit 0848f5
fi
Packit 0848f5
AC_CACHE_CHECK([whether __attribute__ ((weak)) allowed],
Packit 0848f5
pac_cv_attr_weak,[
Packit 0848f5
AC_TRY_COMPILE([int foo(int) __attribute__ ((weak));],[int a;],
Packit 0848f5
pac_cv_attr_weak=yes,pac_cv_attr_weak=no)])
Packit 0848f5
# Note that being able to compile with weak_import doesn't mean that
Packit 0848f5
# it works.
Packit 0848f5
AC_CACHE_CHECK([whether __attribute__ ((weak_import)) allowed],
Packit 0848f5
pac_cv_attr_weak_import,[
Packit 0848f5
AC_TRY_COMPILE([int foo(int) __attribute__ ((weak_import));],[int a;],
Packit 0848f5
pac_cv_attr_weak_import=yes,pac_cv_attr_weak_import=no)])
Packit 0848f5
# Check if the alias option for weak attributes is allowed
Packit 0848f5
AC_CACHE_CHECK([whether __attribute__((weak,alias(...))) allowed],
Packit 0848f5
pac_cv_attr_weak_alias,[
Packit 0848f5
PAC_PUSH_FLAG([CFLAGS])
Packit 0848f5
# force an error exit if the weak attribute isn't understood
Packit 0848f5
CFLAGS=-Werror
Packit 0848f5
AC_TRY_COMPILE([int __foo(int a){return 0;} int foo(int) __attribute__((weak,alias("__foo")));],[int a;],
Packit 0848f5
pac_cv_attr_weak_alias=yes,pac_cv_attr_weak_alias=no)
Packit 0848f5
# Restore original CFLAGS
Packit 0848f5
PAC_POP_FLAG([CFLAGS])])
Packit 0848f5
if test "$pac_cv_attr_weak_alias" = "yes" ; then
Packit 0848f5
    AC_DEFINE(HAVE_WEAK_ATTRIBUTE,1,[Attribute style weak pragma])
Packit 0848f5
fi
Packit 0848f5
if test "$pac_cv_prog_c_weak_symbols" = "no" -a "$pac_cv_attr_weak_alias" = "no" ; then
Packit 0848f5
    ifelse([$2],,:,[$2])
Packit 0848f5
else
Packit 0848f5
    ifelse([$1],,:,[$1])
Packit 0848f5
fi
Packit 0848f5
])
Packit 0848f5
Packit 0848f5
#
Packit 0848f5
# This is a replacement that checks that FAILURES are signaled as well
Packit 0848f5
# (later configure macros look for the .o file, not just success from the
Packit 0848f5
# compiler, but they should not HAVE to
Packit 0848f5
#
Packit 0848f5
dnl --- insert 2.52 compatibility here ---
Packit 0848f5
dnl 2.52 does not have AC_PROG_CC_WORKS
Packit 0848f5
ifdef([AC_PROG_CC_WORKS],,[AC_DEFUN([AC_PROG_CC_WORKS],)])
Packit 0848f5
dnl
Packit 0848f5
AC_DEFUN([PAC_PROG_CC_WORKS],
Packit 0848f5
[AC_PROG_CC_WORKS
Packit 0848f5
AC_MSG_CHECKING([whether the C compiler sets its return status correctly])
Packit 0848f5
AC_LANG_SAVE
Packit 0848f5
AC_LANG_C
Packit 0848f5
AC_TRY_COMPILE(,[int a = bzzzt;],notbroken=no,notbroken=yes)
Packit 0848f5
AC_MSG_RESULT($notbroken)
Packit 0848f5
if test "$notbroken" = "no" ; then
Packit 0848f5
    AC_MSG_ERROR([installation or configuration problem: C compiler does not
Packit 0848f5
correctly set error code when a fatal error occurs])
Packit 0848f5
fi
Packit 0848f5
])
Packit 0848f5
Packit 0848f5
dnl/*D 
Packit 0848f5
dnl PAC_PROG_C_MULTIPLE_WEAK_SYMBOLS - Test whether C and the
Packit 0848f5
dnl linker allow multiple weak symbols.
Packit 0848f5
dnl
Packit 0848f5
dnl Synopsis
Packit 0848f5
dnl PAC_PROG_C_MULTIPLE_WEAK_SYMBOLS(action-if-true,action-if-false)
Packit 0848f5
dnl
Packit 0848f5
dnl 
Packit 0848f5
dnl D*/
Packit 0848f5
AC_DEFUN([PAC_PROG_C_MULTIPLE_WEAK_SYMBOLS],[
Packit 0848f5
AC_CACHE_CHECK([for multiple weak symbol support],
Packit 0848f5
pac_cv_prog_c_multiple_weak_symbols,[
Packit 0848f5
# Test for multiple weak symbol support...
Packit 0848f5
PAC_COMPLINK_IFELSE([
Packit 0848f5
    AC_LANG_SOURCE([
Packit 0848f5
extern int PFoo(int);
Packit 0848f5
extern int PFoo_(int);
Packit 0848f5
extern int pfoo_(int);
Packit 0848f5
#pragma weak PFoo = Foo
Packit 0848f5
#pragma weak PFoo_ = Foo
Packit 0848f5
#pragma weak pfoo_ = Foo
Packit 0848f5
int Foo(int);
Packit 0848f5
int Foo(a) { return a; }
Packit 0848f5
    ])
Packit 0848f5
],[
Packit 0848f5
    AC_LANG_SOURCE([
Packit 0848f5
extern int PFoo(int), PFoo_(int), pfoo_(int);
Packit 0848f5
int main() {
Packit 0848f5
return PFoo(0) + PFoo_(1) + pfoo_(2);}
Packit 0848f5
    ])
Packit 0848f5
],[
Packit 0848f5
    pac_cv_prog_c_multiple_weak_symbols="yes"
Packit 0848f5
])
Packit 0848f5
dnl
Packit 0848f5
])
Packit 0848f5
if test "$pac_cv_prog_c_multiple_weak_symbols" = "yes" ; then
Packit 0848f5
    ifelse([$1],,:,[$1])
Packit 0848f5
else
Packit 0848f5
    ifelse([$2],,:,[$2])
Packit 0848f5
fi
Packit 0848f5
])
Packit 0848f5
Packit 0848f5
dnl Use the value of enable-strict to update CFLAGS
Packit 0848f5
dnl pac_cc_strict_flags contains the strict flags.
Packit 0848f5
dnl
Packit 0848f5
dnl -std=c89 is used to select the C89 version of the ANSI/ISO C standard.
Packit 0848f5
dnl As of this writing, many C compilers still accepted only this version,
Packit 0848f5
dnl not the later C99 version. When all compilers accept C99, this 
Packit 0848f5
dnl should be changed to the appropriate standard level.  Note that we've
Packit 0848f5
dnl had trouble with gcc 2.95.3 accepting -std=c89 but then trying to 
Packit 0848f5
dnl compile program with a invalid set of options 
Packit 0848f5
dnl (-D __STRICT_ANSI__-trigraphs)
Packit 0848f5
AC_DEFUN([PAC_CC_STRICT],[
Packit 0848f5
export enable_strict_done
Packit 0848f5
if test "$enable_strict_done" != "yes" ; then
Packit 0848f5
Packit 0848f5
    # Some comments on strict warning options.
Packit 0848f5
    # These were added to improve portability
Packit 0848f5
    #   -Wstack-usage=262144 -- 32 bit FreeBSD did not like the mprobe test
Packit 0848f5
    #       allocating a big variable on the stack. (See tt#2160).  The "right"
Packit 0848f5
    #       value requires further investigation; 1 MiB would have at least
Packit 0848f5
    #       caught #2160 at compile-time, and only two other tests show a
Packit 0848f5
    #       warning at 256k.
Packit 0848f5
    #
Packit 0848f5
    # These were added to reduce warnings:
Packit 0848f5
    #   -Wno-missing-field-initializers  -- We want to allow a struct to be 
Packit 0848f5
    #       initialized to zero using "struct x y = {0};" and not require 
Packit 0848f5
    #       each field to be initialized individually.
Packit 0848f5
    #   -Wno-unused-parameter -- For portability, some parameters go unused
Packit 0848f5
    #	    when we have different implementations of functions for 
Packit 0848f5
    #	    different platforms
Packit 0848f5
    #   -Wno-unused-label -- We add fn_exit: and fn_fail: on all functions, 
Packit 0848f5
    #	    but fn_fail may not be used if the function doesn't return an 
Packit 0848f5
    #	    error.
Packit 0848f5
    #   -Wno-sign-compare -- read() and write() return bytes read/written
Packit 0848f5
    #       as a signed value, but we often compare this to size_t (or
Packit 0848f5
    #	    msg_sz_t) variables.
Packit 0848f5
    #   -Wno-format-zero-length -- this warning is irritating and useless, since
Packit 0848f5
    #                              a zero-length format string is very well defined
Packit 0848f5
    # These were removed to reduce warnings:
Packit 0848f5
    #   -Wcast-qual -- Sometimes we need to cast "volatile char*" to 
Packit 0848f5
    #	    "char*", e.g., for memcpy.
Packit 0848f5
    #   -Wpadded -- We catch struct padding with asserts when we need to
Packit 0848f5
    #   -Wredundant-decls -- Having redundant declarations is benign and the 
Packit 0848f5
    #	    code already has some.
Packit 0848f5
    #   -Waggregate-return -- This seems to be a performance-related warning
Packit 0848f5
    #       aggregate return values are legal in ANSI C, but they may be returned
Packit 0848f5
    #	    in memory rather than through a register.  We do use aggregate return
Packit 0848f5
    #	    values, but they are structs of a single basic type (used to enforce
Packit 0848f5
    #	    type checking for relative vs. absolute ptrs), and with optimization
Packit 0848f5
    #	    the aggregate value is converted to a scalar.
Packit 0848f5
    #   -Wdeclaration-after-statement -- This is a C89
Packit 0848f5
    #       requirement. When compiling with C99, this should be
Packit 0848f5
    #       disabled.
Packit 0848f5
    #   -Wfloat-equal -- There are places in hwloc that set a float var to 0, then 
Packit 0848f5
    #       compare it to 0 later to see if it was updated.  Also when using strtod()
Packit 0848f5
    #       one needs to compare the return value with 0 to see whether a conversion
Packit 0848f5
    #       was performed.
Packit 0848f5
    #   -Werror-implicit-function-declaration -- implicit function declarations
Packit 0848f5
    #       should never be tolerated.  This also ensures that we get quick
Packit 0848f5
    #       compilation failures rather than later link failures that usually
Packit 0848f5
    #       come from a function name typo.
Packit 0848f5
    #   -Wcast-align -- Casting alignment warnings.  This is an
Packit 0848f5
    #       important check, but is temporarily disabled, since it is
Packit 0848f5
    #       throwing too many (correct) warnings currently, causing us
Packit 0848f5
    #       to miss other warnings.
Packit 0848f5
    #   -Wshorten-64-to-32 -- Bad type-casting warnings.  This is an
Packit 0848f5
    #       important check, but is temporarily disabled, since it is
Packit 0848f5
    #       throwing too many (correct) warnings currently, causing us
Packit 0848f5
    #       to miss other warnings.
Packit 0848f5
    #
Packit 0848f5
    # This was removed because it masks important failures (see ticket #2094).
Packit 0848f5
    # However, since Intel compiler currently does not include -Wtype-limits
Packit 0848f5
    # in -Wextra, -Wtype-limits was added to handle warnings with the Intel
Packit 0848f5
    # compiler.
Packit 0848f5
    #   -Wno-type-limits -- There are places where we compare an unsigned to 
Packit 0848f5
    #	    a constant that happens to be zero e.g., if x is unsigned and 
Packit 0848f5
    #	    MIN_VAL is zero, we'd like to do "MPIU_Assert(x >= MIN_VAL);".
Packit 0848f5
    #       Note this option is not supported by gcc 4.2.  This needs to be added 
Packit 0848f5
    #	    after most other warning flags, so that we catch a gcc bug on 32-bit 
Packit 0848f5
    #	    that doesn't give a warning that this is unsupported, unless another
Packit 0848f5
    #	    warning is triggered, and then if gives an error.
Packit 0848f5
    # the embedded newlines in this string are safe because we evaluate each
Packit 0848f5
    # argument in the for-loop below and append them to the CFLAGS with a space
Packit 0848f5
    # as the separator instead
Packit 0848f5
    pac_common_strict_flags="
Packit 0848f5
        -Wall
Packit 0848f5
        -Wextra
Packit 0848f5
        -Wno-missing-field-initializers
Packit 0848f5
        -Wstrict-prototypes
Packit 0848f5
        -Wmissing-prototypes
Packit 0848f5
        -DGCC_WALL
Packit 0848f5
        -Wno-unused-parameter
Packit 0848f5
        -Wno-unused-label
Packit 0848f5
        -Wshadow
Packit 0848f5
        -Wmissing-declarations
Packit 0848f5
        -Wno-long-long
Packit 0848f5
        -Wundef
Packit 0848f5
        -Wno-endif-labels
Packit 0848f5
        -Wpointer-arith
Packit 0848f5
        -Wbad-function-cast
Packit 0848f5
        -Wwrite-strings
Packit 0848f5
        -Wno-sign-compare
Packit 0848f5
        -Wold-style-definition
Packit 0848f5
        -Wno-multichar
Packit 0848f5
        -Wno-deprecated-declarations
Packit 0848f5
        -Wpacked
Packit 0848f5
        -Wnested-externs
Packit 0848f5
        -Winvalid-pch
Packit 0848f5
        -Wno-pointer-sign
Packit 0848f5
        -Wvariadic-macros
Packit 0848f5
        -Wno-format-zero-length
Packit 0848f5
        -Wtype-limits
Packit 0848f5
        -Werror-implicit-function-declaration
Packit 0848f5
        -Wstack-usage=262144
Packit 0848f5
    "
Packit 0848f5
Packit 0848f5
    enable_c89=no
Packit 0848f5
    enable_c99=yes
Packit 0848f5
    enable_posix=2001
Packit 0848f5
    enable_opt=yes
Packit 0848f5
    flags="`echo $1 | sed -e 's/:/ /g' -e 's/,/ /g'`"
Packit 0848f5
    for flag in ${flags}; do
Packit 0848f5
        case "$flag" in
Packit 0848f5
	     c89)
Packit 0848f5
		enable_strict_done="yes"
Packit 0848f5
		enable_c89=yes
Packit 0848f5
                enable_c99=no
Packit 0848f5
		;;
Packit 0848f5
	     c99)
Packit 0848f5
		enable_strict_done="yes"
Packit 0848f5
                enable_c89=no
Packit 0848f5
		enable_c99=yes
Packit 0848f5
		;;
Packit 0848f5
	     posix1995)
Packit 0848f5
		enable_strict_done="yes"
Packit 0848f5
		enable_posix=1995
Packit 0848f5
		;;
Packit 0848f5
	     posix|posix2001)
Packit 0848f5
		enable_strict_done="yes"
Packit 0848f5
		enable_posix=2001
Packit 0848f5
		;;
Packit 0848f5
	     posix2008)
Packit 0848f5
		enable_strict_done="yes"
Packit 0848f5
		enable_posix=2008
Packit 0848f5
		;;
Packit 0848f5
	     noposix)
Packit 0848f5
		enable_strict_done="yes"
Packit 0848f5
		enable_posix=no
Packit 0848f5
		;;
Packit 0848f5
	     opt)
Packit 0848f5
		enable_strict_done="yes"
Packit 0848f5
		enable_opt=yes
Packit 0848f5
		;;
Packit 0848f5
	     noopt)
Packit 0848f5
		enable_strict_done="yes"
Packit 0848f5
		enable_opt=no
Packit 0848f5
		;;
Packit 0848f5
	     all|yes)
Packit 0848f5
		enable_strict_done="yes"
Packit 0848f5
		enable_c99=yes
Packit 0848f5
		enable_posix=2001
Packit 0848f5
		enable_opt=yes
Packit 0848f5
	        ;;
Packit 0848f5
	     no)
Packit 0848f5
		# Accept and ignore this value
Packit 0848f5
		:
Packit 0848f5
		;;
Packit 0848f5
	     *)
Packit 0848f5
		if test -n "$flag" ; then
Packit 0848f5
		   AC_MSG_WARN([Unrecognized value for enable-strict:$flag])
Packit 0848f5
		fi
Packit 0848f5
		;;
Packit 0848f5
	esac
Packit 0848f5
    done
Packit 0848f5
Packit 0848f5
    pac_cc_strict_flags=""
Packit 0848f5
    if test "${enable_strict_done}" = "yes" ; then
Packit 0848f5
       if test "${enable_opt}" = "yes" ; then
Packit 0848f5
       	  pac_cc_strict_flags="-O2"
Packit 0848f5
       fi
Packit 0848f5
       pac_cc_strict_flags="$pac_cc_strict_flags $pac_common_strict_flags"
Packit 0848f5
       # We only allow one of strict-C99 or strict-C89 to be
Packit 0848f5
       # enabled. If C99 is enabled, we automatically disable C89.
Packit 0848f5
       if test "${enable_c99}" = "yes" ; then
Packit 0848f5
       	  PAC_APPEND_FLAG([-std=c99],[pac_cc_strict_flags])
Packit 0848f5
          # Use -D_STDC_C99= for Solaris compilers. See
Packit 0848f5
          # http://lists.gnu.org/archive/html/autoconf/2010-12/msg00059.html
Packit 0848f5
          # for discussion on why not to use -xc99
Packit 0848f5
          PAC_APPEND_FLAG([-D_STDC_C99=],[pac_cc_strict_flags])
Packit 0848f5
       elif test "${enable_c89}" = "yes" ; then
Packit 0848f5
       	  PAC_APPEND_FLAG([-std=c89],[pac_cc_strict_flags])
Packit 0848f5
       	  PAC_APPEND_FLAG([-Wdeclaration-after-statement],[pac_cc_strict_flags])
Packit 0848f5
       fi
Packit 0848f5
       # POSIX 2001 should be used with C99. But the default standard for some
Packit 0848f5
       # compilers are not C99. We must test the support of POSIX 2001 after
Packit 0848f5
       # testing C99.
Packit 0848f5
       case "$enable_posix" in
Packit 0848f5
            no)   : ;;
Packit 0848f5
            1995) PAC_APPEND_FLAG([-D_POSIX_C_SOURCE=199506L],[pac_cc_strict_flags]) ;;
Packit 0848f5
            2001) PAC_APPEND_FLAG([-D_POSIX_C_SOURCE=200112L],[pac_cc_strict_flags]) ;;
Packit 0848f5
            2008) PAC_APPEND_FLAG([-D_POSIX_C_SOURCE=200809L],[pac_cc_strict_flags]) ;;
Packit 0848f5
            *)    AC_MSG_ERROR([internal error, unexpected POSIX version: '$enable_posix']) ;;
Packit 0848f5
       esac
Packit 0848f5
    fi
Packit 0848f5
Packit 0848f5
    # See if the above options work with the compiler
Packit 0848f5
    accepted_flags=""
Packit 0848f5
    for flag in $pac_cc_strict_flags ; do
Packit 0848f5
        PAC_PUSH_FLAG([CFLAGS])
Packit 0848f5
	CFLAGS="$CFLAGS $accepted_flags"
Packit 0848f5
        PAC_C_CHECK_COMPILER_OPTION([$flag],[accepted_flags="$accepted_flags $flag"],)
Packit 0848f5
        PAC_POP_FLAG([CFLAGS])
Packit 0848f5
    done
Packit 0848f5
    pac_cc_strict_flags=$accepted_flags
Packit 0848f5
fi
Packit 0848f5
])
Packit 0848f5
Packit 0848f5
dnl/*D
Packit 0848f5
dnl PAC_ARG_STRICT - Add --enable-strict to configure.  
Packit 0848f5
dnl
Packit 0848f5
dnl Synopsis:
Packit 0848f5
dnl PAC_ARG_STRICT
Packit 0848f5
dnl 
Packit 0848f5
dnl Output effects:
Packit 0848f5
dnl Adds '--enable-strict' to the command line.
Packit 0848f5
dnl
Packit 0848f5
dnl D*/
Packit 0848f5
AC_DEFUN([PAC_ARG_STRICT],[
Packit 0848f5
AC_ARG_ENABLE(strict,
Packit 0848f5
	AC_HELP_STRING([--enable-strict], [Turn on strict compilation testing]))
Packit 0848f5
PAC_CC_STRICT($enable_strict)
Packit 0848f5
CFLAGS="$CFLAGS $pac_cc_strict_flags"
Packit 0848f5
export CFLAGS
Packit 0848f5
])
Packit 0848f5
Packit 0848f5
dnl Return the integer structure alignment in pac_cv_c_max_integer_align
Packit 0848f5
dnl Possible values include
Packit 0848f5
dnl	packed
Packit 0848f5
dnl	two
Packit 0848f5
dnl	four
Packit 0848f5
dnl	eight
Packit 0848f5
dnl
Packit 0848f5
dnl In addition, a "Could not determine alignment" and a "error!"
Packit 0848f5
dnl return is possible.  
Packit 0848f5
AC_DEFUN([PAC_C_MAX_INTEGER_ALIGN],[
Packit 0848f5
AC_CACHE_CHECK([for max C struct integer alignment],
Packit 0848f5
pac_cv_c_max_integer_align,[
Packit 0848f5
AC_TRY_RUN([
Packit 0848f5
#include <stdio.h>
Packit 0848f5
#define DBG(a,b,c)
Packit 0848f5
int main( int argc, char *argv[] )
Packit 0848f5
{
Packit 0848f5
    FILE *cf;
Packit 0848f5
    int is_packed  = 1;
Packit 0848f5
    int is_two     = 1;
Packit 0848f5
    int is_four    = 1;
Packit 0848f5
    int is_eight   = 1;
Packit 0848f5
    struct { char a; int b; } char_int;
Packit 0848f5
    struct { char a; short b; } char_short;
Packit 0848f5
    struct { char a; long b; } char_long;
Packit 0848f5
    struct { char a; int b; char c; } char_int_char;
Packit 0848f5
    struct { char a; short b; char c; } char_short_char;
Packit 0848f5
#ifdef HAVE_LONG_LONG_INT
Packit 0848f5
    struct { long long int a; char b; } lli_c;
Packit 0848f5
    struct { char a; long long int b; } c_lli;
Packit 0848f5
#endif
Packit 0848f5
    int size, extent, extent2;
Packit 0848f5
Packit 0848f5
    /* assume max integer alignment isn't 8 if we don't have
Packit 0848f5
     * an eight-byte value :)
Packit 0848f5
     */
Packit 0848f5
#ifdef HAVE_LONG_LONG_INT
Packit 0848f5
    if (sizeof(int) < 8 && sizeof(long) < 8 && sizeof(long long int) < 8)
Packit 0848f5
	is_eight = 0;
Packit 0848f5
#else
Packit 0848f5
    if (sizeof(int) < 8 && sizeof(long) < 8) is_eight = 0;
Packit 0848f5
#endif
Packit 0848f5
Packit 0848f5
    size = sizeof(char) + sizeof(int);
Packit 0848f5
    extent = sizeof(char_int);
Packit 0848f5
    if (size != extent) is_packed = 0;
Packit 0848f5
    if ( (extent % 2) != 0) is_two = 0;
Packit 0848f5
    if ( (extent % 4) != 0) is_four = 0;
Packit 0848f5
    if (sizeof(int) == 8 && (extent % 8) != 0) is_eight = 0;
Packit 0848f5
    DBG("char_int",size,extent);
Packit 0848f5
Packit 0848f5
    size = sizeof(char) + sizeof(short);
Packit 0848f5
    extent = sizeof(char_short);
Packit 0848f5
    if (size != extent) is_packed = 0;
Packit 0848f5
    if ( (extent % 2) != 0) is_two = 0;
Packit 0848f5
    if (sizeof(short) == 4 && (extent % 4) != 0) is_four = 0;
Packit 0848f5
    if (sizeof(short) == 8 && (extent % 8) != 0) is_eight = 0;
Packit 0848f5
    DBG("char_short",size,extent);
Packit 0848f5
Packit 0848f5
    size = sizeof(char) + sizeof(long);
Packit 0848f5
    extent = sizeof(char_long);
Packit 0848f5
    if (size != extent) is_packed = 0;
Packit 0848f5
    if ( (extent % 2) != 0) is_two = 0;
Packit 0848f5
    if ( (extent % 4) != 0) is_four = 0;
Packit 0848f5
    if (sizeof(long) == 8 && (extent % 8) != 0) is_eight = 0;
Packit 0848f5
    DBG("char_long",size,extent);
Packit 0848f5
Packit 0848f5
#ifdef HAVE_LONG_LONG_INT
Packit 0848f5
    size = sizeof(char) + sizeof(long long int);
Packit 0848f5
    extent = sizeof(lli_c);
Packit 0848f5
    extent2 = sizeof(c_lli);
Packit 0848f5
    if (size != extent) is_packed = 0;
Packit 0848f5
    if ( (extent % 2) != 0 && (extent2 % 2) != 0) is_two = 0;
Packit 0848f5
    if ( (extent % 4) != 0 && (extent2 % 4) != 0) is_four = 0;
Packit 0848f5
    if (sizeof(long long int) >= 8 && (extent % 8) != 0 && (extent2 % 8) != 0)
Packit 0848f5
	is_eight = 0;
Packit 0848f5
#endif
Packit 0848f5
Packit 0848f5
    size = sizeof(char) + sizeof(int) + sizeof(char);
Packit 0848f5
    extent = sizeof(char_int_char);
Packit 0848f5
    if (size != extent) is_packed = 0;
Packit 0848f5
    if ( (extent % 2) != 0) is_two = 0;
Packit 0848f5
    if ( (extent % 4) != 0) is_four = 0;
Packit 0848f5
    if (sizeof(int) == 8 && (extent % 8) != 0) is_eight = 0;
Packit 0848f5
    DBG("char_int_char",size,extent);
Packit 0848f5
Packit 0848f5
    size = sizeof(char) + sizeof(short) + sizeof(char);
Packit 0848f5
    extent = sizeof(char_short_char);
Packit 0848f5
    if (size != extent) is_packed = 0;
Packit 0848f5
    if ( (extent % 2) != 0) is_two = 0;
Packit 0848f5
    if (sizeof(short) == 4 && (extent % 4) != 0) is_four = 0;
Packit 0848f5
    if (sizeof(short) == 8 && (extent % 8) != 0) is_eight = 0;
Packit 0848f5
    DBG("char_short_char",size,extent);
Packit 0848f5
Packit 0848f5
    /* If aligned mod 8, it will be aligned mod 4 */
Packit 0848f5
    if (is_eight) { is_four = 0; is_two = 0; }
Packit 0848f5
Packit 0848f5
    if (is_four) is_two = 0;
Packit 0848f5
Packit 0848f5
    /* Tabulate the results */
Packit 0848f5
    cf = fopen( "ctest.out", "w" );
Packit 0848f5
    if (is_packed + is_two + is_four + is_eight == 0) {
Packit 0848f5
	fprintf( cf, "Could not determine alignment\n" );
Packit 0848f5
    }
Packit 0848f5
    else {
Packit 0848f5
	if (is_packed + is_two + is_four + is_eight != 1) {
Packit 0848f5
	    fprintf( cf, "error!\n" );
Packit 0848f5
	}
Packit 0848f5
	else {
Packit 0848f5
	    if (is_packed) fprintf( cf, "packed\n" );
Packit 0848f5
	    if (is_two) fprintf( cf, "two\n" );
Packit 0848f5
	    if (is_four) fprintf( cf, "four\n" );
Packit 0848f5
	    if (is_eight) fprintf( cf, "eight\n" );
Packit 0848f5
	}
Packit 0848f5
    }
Packit 0848f5
    fclose( cf );
Packit 0848f5
    return 0;
Packit 0848f5
}],
Packit 0848f5
pac_cv_c_max_integer_align=`cat ctest.out`,
Packit 0848f5
pac_cv_c_max_integer_align="unknown",
Packit 0848f5
pac_cv_c_max_integer_align="$CROSS_ALIGN_STRUCT_INT")
Packit 0848f5
rm -f ctest.out
Packit 0848f5
])
Packit 0848f5
if test -z "$pac_cv_c_max_integer_align" ; then
Packit 0848f5
    pac_cv_c_max_integer_align="unknown"
Packit 0848f5
fi
Packit 0848f5
])
Packit 0848f5
Packit 0848f5
dnl Return the floating point structure alignment in
Packit 0848f5
dnl pac_cv_c_max_fp_align.
Packit 0848f5
dnl
Packit 0848f5
dnl Possible values include:
Packit 0848f5
dnl	packed
Packit 0848f5
dnl	two
Packit 0848f5
dnl	four
Packit 0848f5
dnl	eight
Packit 0848f5
dnl     sixteen
Packit 0848f5
dnl
Packit 0848f5
dnl In addition, a "Could not determine alignment" and a "error!"
Packit 0848f5
dnl return is possible.  
Packit 0848f5
AC_DEFUN([PAC_C_MAX_FP_ALIGN],[
Packit 0848f5
AC_CACHE_CHECK([for max C struct floating point alignment],
Packit 0848f5
pac_cv_c_max_fp_align,[
Packit 0848f5
AC_TRY_RUN([
Packit 0848f5
#include <stdio.h>
Packit 0848f5
#define DBG(a,b,c)
Packit 0848f5
int main( int argc, char *argv[] )
Packit 0848f5
{
Packit 0848f5
    FILE *cf;
Packit 0848f5
    int is_packed  = 1;
Packit 0848f5
    int is_two     = 1;
Packit 0848f5
    int is_four    = 1;
Packit 0848f5
    int is_eight   = 1;
Packit 0848f5
    int is_sixteen = 1;
Packit 0848f5
    struct { char a; float b; } char_float;
Packit 0848f5
    struct { float b; char a; } float_char;
Packit 0848f5
    struct { char a; double b; } char_double;
Packit 0848f5
    struct { double b; char a; } double_char;
Packit 0848f5
#ifdef HAVE_LONG_DOUBLE
Packit 0848f5
    struct { char a; long double b; } char_long_double;
Packit 0848f5
    struct { long double b; char a; } long_double_char;
Packit 0848f5
    struct { long double a; int b; char c; } long_double_int_char;
Packit 0848f5
#endif
Packit 0848f5
    int size, extent1, extent2;
Packit 0848f5
Packit 0848f5
    size = sizeof(char) + sizeof(float);
Packit 0848f5
    extent1 = sizeof(char_float);
Packit 0848f5
    extent2 = sizeof(float_char);
Packit 0848f5
    if (size != extent1) is_packed = 0;
Packit 0848f5
    if ( (extent1 % 2) != 0 && (extent2 % 2) != 0) is_two = 0;
Packit 0848f5
    if ( (extent1 % 4) != 0 && (extent2 % 4) != 0) is_four = 0;
Packit 0848f5
    if (sizeof(float) == 8 && (extent1 % 8) != 0 && (extent2 % 8) != 0)
Packit 0848f5
	is_eight = 0;
Packit 0848f5
    DBG("char_float",size,extent1);
Packit 0848f5
Packit 0848f5
    size = sizeof(char) + sizeof(double);
Packit 0848f5
    extent1 = sizeof(char_double);
Packit 0848f5
    extent2 = sizeof(double_char);
Packit 0848f5
    if (size != extent1) is_packed = 0;
Packit 0848f5
    if ( (extent1 % 2) != 0 && (extent2 % 2) != 0) is_two = 0;
Packit 0848f5
    if ( (extent1 % 4) != 0 && (extent2 % 4) != 0) is_four = 0;
Packit 0848f5
    if (sizeof(double) == 8 && (extent1 % 8) != 0 && (extent2 % 8) != 0)
Packit 0848f5
	is_eight = 0;
Packit 0848f5
    DBG("char_double",size,extent1);
Packit 0848f5
Packit 0848f5
#ifdef HAVE_LONG_DOUBLE
Packit 0848f5
    size = sizeof(char) + sizeof(long double);
Packit 0848f5
    extent1 = sizeof(char_long_double);
Packit 0848f5
    extent2 = sizeof(long_double_char);
Packit 0848f5
    if (size != extent1) is_packed = 0;
Packit 0848f5
    if ( (extent1 % 2) != 0 && (extent2 % 2) != 0) is_two = 0;
Packit 0848f5
    if ( (extent1 % 4) != 0 && (extent2 % 4) != 0) is_four = 0;
Packit 0848f5
    if (sizeof(long double) >= 8 && (extent1 % 8) != 0 && (extent2 % 8) != 0)
Packit 0848f5
	is_eight = 0;
Packit 0848f5
    if (sizeof(long double) > 8 && (extent1 % 16) != 0
Packit 0848f5
	&& (extent2 % 16) != 0) is_sixteen = 0;
Packit 0848f5
    DBG("char_long-double",size,extent1);
Packit 0848f5
Packit 0848f5
    extent1 = sizeof(long_double_int_char);
Packit 0848f5
    if ( (extent1 % 2) != 0) is_two = 0;
Packit 0848f5
    if ( (extent1 % 4) != 0) is_four = 0;
Packit 0848f5
    if (sizeof(long double) >= 8 && (extent1 % 8) != 0)	is_eight = 0;
Packit 0848f5
    if (sizeof(long double) > 8 && (extent1 % 16) != 0) is_sixteen = 0;
Packit 0848f5
#else
Packit 0848f5
    is_sixteen = 0;
Packit 0848f5
#endif
Packit 0848f5
Packit 0848f5
    if (is_sixteen) { is_eight = 0; is_four = 0; is_two = 0; }
Packit 0848f5
Packit 0848f5
    if (is_eight) { is_four = 0; is_two = 0; }
Packit 0848f5
Packit 0848f5
    if (is_four) is_two = 0;
Packit 0848f5
Packit 0848f5
    /* Tabulate the results */
Packit 0848f5
    cf = fopen( "ctest.out", "w" );
Packit 0848f5
    if (is_packed + is_two + is_four + is_eight + is_sixteen == 0) {
Packit 0848f5
	fprintf( cf, "Could not determine alignment\n" );
Packit 0848f5
    }
Packit 0848f5
    else {
Packit 0848f5
	if (is_packed + is_two + is_four + is_eight + is_sixteen != 1) {
Packit 0848f5
	    fprintf( cf, "error!\n" );
Packit 0848f5
	}
Packit 0848f5
	else {
Packit 0848f5
	    if (is_packed) fprintf( cf, "packed\n" );
Packit 0848f5
	    if (is_two) fprintf( cf, "two\n" );
Packit 0848f5
	    if (is_four) fprintf( cf, "four\n" );
Packit 0848f5
	    if (is_eight) fprintf( cf, "eight\n" );
Packit 0848f5
	    if (is_sixteen) fprintf( cf, "sixteen\n" );
Packit 0848f5
	}
Packit 0848f5
    }
Packit 0848f5
    fclose( cf );
Packit 0848f5
    return 0;
Packit 0848f5
}],
Packit 0848f5
pac_cv_c_max_fp_align=`cat ctest.out`,
Packit 0848f5
pac_cv_c_max_fp_align="unknown",
Packit 0848f5
pac_cv_c_max_fp_align="$CROSS_ALIGN_STRUCT_FP")
Packit 0848f5
rm -f ctest.out
Packit 0848f5
])
Packit 0848f5
if test -z "$pac_cv_c_max_fp_align" ; then
Packit 0848f5
    pac_cv_c_max_fp_align="unknown"
Packit 0848f5
fi
Packit 0848f5
])
Packit 0848f5
Packit 0848f5
dnl Return the floating point structure alignment in
Packit 0848f5
dnl pac_cv_c_max_double_fp_align.
Packit 0848f5
dnl
Packit 0848f5
dnl Possible values include:
Packit 0848f5
dnl	packed
Packit 0848f5
dnl	two
Packit 0848f5
dnl	four
Packit 0848f5
dnl	eight
Packit 0848f5
dnl
Packit 0848f5
dnl In addition, a "Could not determine alignment" and a "error!"
Packit 0848f5
dnl return is possible.  
Packit 0848f5
AC_DEFUN([PAC_C_MAX_DOUBLE_FP_ALIGN],[
Packit 0848f5
AC_CACHE_CHECK([for max C struct alignment of structs with doubles],
Packit 0848f5
pac_cv_c_max_double_fp_align,[
Packit 0848f5
AC_TRY_RUN([
Packit 0848f5
#include <stdio.h>
Packit 0848f5
#define DBG(a,b,c)
Packit 0848f5
int main( int argc, char *argv[] )
Packit 0848f5
{
Packit 0848f5
    FILE *cf;
Packit 0848f5
    int is_packed  = 1;
Packit 0848f5
    int is_two     = 1;
Packit 0848f5
    int is_four    = 1;
Packit 0848f5
    int is_eight   = 1;
Packit 0848f5
    struct { char a; float b; } char_float;
Packit 0848f5
    struct { float b; char a; } float_char;
Packit 0848f5
    struct { char a; double b; } char_double;
Packit 0848f5
    struct { double b; char a; } double_char;
Packit 0848f5
    int size, extent1, extent2;
Packit 0848f5
Packit 0848f5
    size = sizeof(char) + sizeof(float);
Packit 0848f5
    extent1 = sizeof(char_float);
Packit 0848f5
    extent2 = sizeof(float_char);
Packit 0848f5
    if (size != extent1) is_packed = 0;
Packit 0848f5
    if ( (extent1 % 2) != 0 && (extent2 % 2) != 0) is_two = 0;
Packit 0848f5
    if ( (extent1 % 4) != 0 && (extent2 % 4) != 0) is_four = 0;
Packit 0848f5
    if (sizeof(float) == 8 && (extent1 % 8) != 0 && (extent2 % 8) != 0)
Packit 0848f5
	is_eight = 0;
Packit 0848f5
    DBG("char_float",size,extent1);
Packit 0848f5
Packit 0848f5
    size = sizeof(char) + sizeof(double);
Packit 0848f5
    extent1 = sizeof(char_double);
Packit 0848f5
    extent2 = sizeof(double_char);
Packit 0848f5
    if (size != extent1) is_packed = 0;
Packit 0848f5
    if ( (extent1 % 2) != 0 && (extent2 % 2) != 0) is_two = 0;
Packit 0848f5
    if ( (extent1 % 4) != 0 && (extent2 % 4) != 0) is_four = 0;
Packit 0848f5
    if (sizeof(double) == 8 && (extent1 % 8) != 0 && (extent2 % 8) != 0)
Packit 0848f5
	is_eight = 0;
Packit 0848f5
    DBG("char_double",size,extent1);
Packit 0848f5
Packit 0848f5
    if (is_eight) { is_four = 0; is_two = 0; }
Packit 0848f5
Packit 0848f5
    if (is_four) is_two = 0;
Packit 0848f5
Packit 0848f5
    /* Tabulate the results */
Packit 0848f5
    cf = fopen( "ctest.out", "w" );
Packit 0848f5
    if (is_packed + is_two + is_four + is_eight == 0) {
Packit 0848f5
	fprintf( cf, "Could not determine alignment\n" );
Packit 0848f5
    }
Packit 0848f5
    else {
Packit 0848f5
	if (is_packed + is_two + is_four + is_eight != 1) {
Packit 0848f5
	    fprintf( cf, "error!\n" );
Packit 0848f5
	}
Packit 0848f5
	else {
Packit 0848f5
	    if (is_packed) fprintf( cf, "packed\n" );
Packit 0848f5
	    if (is_two) fprintf( cf, "two\n" );
Packit 0848f5
	    if (is_four) fprintf( cf, "four\n" );
Packit 0848f5
	    if (is_eight) fprintf( cf, "eight\n" );
Packit 0848f5
	}
Packit 0848f5
    }
Packit 0848f5
    fclose( cf );
Packit 0848f5
    return 0;
Packit 0848f5
}],
Packit 0848f5
pac_cv_c_max_double_fp_align=`cat ctest.out`,
Packit 0848f5
pac_cv_c_max_double_fp_align="unknown",
Packit 0848f5
pac_cv_c_max_double_fp_align="$CROSS_ALIGN_STRUCT_DOUBLE_FP")
Packit 0848f5
rm -f ctest.out
Packit 0848f5
])
Packit 0848f5
if test -z "$pac_cv_c_max_double_fp_align" ; then
Packit 0848f5
    pac_cv_c_max_double_fp_align="unknown"
Packit 0848f5
fi
Packit 0848f5
])
Packit 0848f5
AC_DEFUN([PAC_C_MAX_LONGDOUBLE_FP_ALIGN],[
Packit 0848f5
AC_CACHE_CHECK([for max C struct floating point alignment with long doubles],
Packit 0848f5
pac_cv_c_max_longdouble_fp_align,[
Packit 0848f5
AC_TRY_RUN([
Packit 0848f5
#include <stdio.h>
Packit 0848f5
#define DBG(a,b,c)
Packit 0848f5
int main( int argc, char *argv[] )
Packit 0848f5
{
Packit 0848f5
    FILE *cf;
Packit 0848f5
    int is_packed  = 1;
Packit 0848f5
    int is_two     = 1;
Packit 0848f5
    int is_four    = 1;
Packit 0848f5
    int is_eight   = 1;
Packit 0848f5
    int is_sixteen = 1;
Packit 0848f5
    struct { char a; long double b; } char_long_double;
Packit 0848f5
    struct { long double b; char a; } long_double_char;
Packit 0848f5
    struct { long double a; int b; char c; } long_double_int_char;
Packit 0848f5
    int size, extent1, extent2;
Packit 0848f5
Packit 0848f5
    size = sizeof(char) + sizeof(long double);
Packit 0848f5
    extent1 = sizeof(char_long_double);
Packit 0848f5
    extent2 = sizeof(long_double_char);
Packit 0848f5
    if (size != extent1) is_packed = 0;
Packit 0848f5
    if ( (extent1 % 2) != 0 && (extent2 % 2) != 0) is_two = 0;
Packit 0848f5
    if ( (extent1 % 4) != 0 && (extent2 % 4) != 0) is_four = 0;
Packit 0848f5
    if (sizeof(long double) >= 8 && (extent1 % 8) != 0 && (extent2 % 8) != 0)
Packit 0848f5
	is_eight = 0;
Packit 0848f5
    if (sizeof(long double) > 8 && (extent1 % 16) != 0
Packit 0848f5
	&& (extent2 % 16) != 0) is_sixteen = 0;
Packit 0848f5
    DBG("char_long-double",size,extent1);
Packit 0848f5
Packit 0848f5
    extent1 = sizeof(long_double_int_char);
Packit 0848f5
    if ( (extent1 % 2) != 0) is_two = 0;
Packit 0848f5
    if ( (extent1 % 4) != 0) is_four = 0;
Packit 0848f5
    if (sizeof(long double) >= 8 && (extent1 % 8) != 0)	is_eight = 0;
Packit 0848f5
    if (sizeof(long double) > 8 && (extent1 % 16) != 0) is_sixteen = 0;
Packit 0848f5
Packit 0848f5
    if (is_sixteen) { is_eight = 0; is_four = 0; is_two = 0; }
Packit 0848f5
Packit 0848f5
    if (is_eight) { is_four = 0; is_two = 0; }
Packit 0848f5
Packit 0848f5
    if (is_four) is_two = 0;
Packit 0848f5
Packit 0848f5
    /* Tabulate the results */
Packit 0848f5
    cf = fopen( "ctest.out", "w" );
Packit 0848f5
    if (is_packed + is_two + is_four + is_eight + is_sixteen == 0) {
Packit 0848f5
	fprintf( cf, "Could not determine alignment\n" );
Packit 0848f5
    }
Packit 0848f5
    else {
Packit 0848f5
	if (is_packed + is_two + is_four + is_eight + is_sixteen != 1) {
Packit 0848f5
	    fprintf( cf, "error!\n" );
Packit 0848f5
	}
Packit 0848f5
	else {
Packit 0848f5
	    if (is_packed) fprintf( cf, "packed\n" );
Packit 0848f5
	    if (is_two) fprintf( cf, "two\n" );
Packit 0848f5
	    if (is_four) fprintf( cf, "four\n" );
Packit 0848f5
	    if (is_eight) fprintf( cf, "eight\n" );
Packit 0848f5
	    if (is_sixteen) fprintf( cf, "sixteen\n" );
Packit 0848f5
	}
Packit 0848f5
    }
Packit 0848f5
    fclose( cf );
Packit 0848f5
    return 0;
Packit 0848f5
}],
Packit 0848f5
pac_cv_c_max_longdouble_fp_align=`cat ctest.out`,
Packit 0848f5
pac_cv_c_max_longdouble_fp_align="unknown",
Packit 0848f5
pac_cv_c_max_longdouble_fp_align="$CROSS_ALIGN_STRUCT_LONGDOUBLE_FP")
Packit 0848f5
rm -f ctest.out
Packit 0848f5
])
Packit 0848f5
if test -z "$pac_cv_c_max_longdouble_fp_align" ; then
Packit 0848f5
    pac_cv_c_max_longdouble_fp_align="unknown"
Packit 0848f5
fi
Packit 0848f5
])
Packit 0848f5
Packit 0848f5
dnl Other tests assume that there is potentially a maximum alignment
Packit 0848f5
dnl and that if there is no maximum alignment, or a type is smaller than
Packit 0848f5
dnl that value, then we align on the size of the value, with the exception
Packit 0848f5
dnl of the "position-based alignment" rules we test for separately.
Packit 0848f5
dnl
Packit 0848f5
dnl It turns out that these assumptions have fallen short in at least one
Packit 0848f5
dnl case, on MacBook Pros, where doubles are aligned on 4-byte boundaries
Packit 0848f5
dnl even when long doubles are aligned on 16-byte boundaries. So this test
Packit 0848f5
dnl is here specifically to handle this case.
Packit 0848f5
dnl
Packit 0848f5
dnl Puts result in pac_cv_c_double_alignment_exception.
Packit 0848f5
dnl
Packit 0848f5
dnl Possible values currently include no and four.
Packit 0848f5
dnl
Packit 0848f5
AC_DEFUN([PAC_C_DOUBLE_ALIGNMENT_EXCEPTION],[
Packit 0848f5
AC_CACHE_CHECK([if double alignment breaks rules, find actual alignment],
Packit 0848f5
pac_cv_c_double_alignment_exception,[
Packit 0848f5
AC_TRY_RUN([
Packit 0848f5
#include <stdio.h>
Packit 0848f5
#define DBG(a,b,c)
Packit 0848f5
int main( int argc, char *argv[] )
Packit 0848f5
{
Packit 0848f5
    FILE *cf;
Packit 0848f5
    struct { char a; double b; } char_double;
Packit 0848f5
    struct { double b; char a; } double_char;
Packit 0848f5
    int extent1, extent2, align_4 = 0;
Packit 0848f5
Packit 0848f5
    extent1 = sizeof(char_double);
Packit 0848f5
    extent2 = sizeof(double_char);
Packit 0848f5
Packit 0848f5
    /* we're interested in the largest value, will let separate test
Packit 0848f5
     * deal with position-based issues.
Packit 0848f5
     */
Packit 0848f5
    if (extent1 < extent2) extent1 = extent2;
Packit 0848f5
    if ((sizeof(double) == 8) && (extent1 % 8) != 0) {
Packit 0848f5
       if (extent1 % 4 == 0) {
Packit 0848f5
#ifdef HAVE_MAX_FP_ALIGNMENT
Packit 0848f5
          if (HAVE_MAX_FP_ALIGNMENT >= 8) align_4 = 1;
Packit 0848f5
#else
Packit 0848f5
          align_4 = 1;
Packit 0848f5
#endif
Packit 0848f5
       }
Packit 0848f5
    }
Packit 0848f5
Packit 0848f5
    cf = fopen( "ctest.out", "w" );
Packit 0848f5
Packit 0848f5
    if (align_4) fprintf( cf, "four\n" );
Packit 0848f5
    else fprintf( cf, "no\n" );
Packit 0848f5
Packit 0848f5
    fclose( cf );
Packit 0848f5
    return 0;
Packit 0848f5
}],
Packit 0848f5
pac_cv_c_double_alignment_exception=`cat ctest.out`,
Packit 0848f5
pac_cv_c_double_alignment_exception="unknown",
Packit 0848f5
pac_cv_c_double_alignment_exception="$CROSS_ALIGN_DOUBLE_EXCEPTION")
Packit 0848f5
rm -f ctest.out
Packit 0848f5
])
Packit 0848f5
if test -z "$pac_cv_c_double_alignment_exception" ; then
Packit 0848f5
    pac_cv_c_double_alignment_exception="unknown"
Packit 0848f5
fi
Packit 0848f5
])
Packit 0848f5
Packit 0848f5
dnl Test for odd struct alignment rule that only applies max.
Packit 0848f5
dnl padding when double value is at front of type.
Packit 0848f5
dnl Puts result in pac_cv_c_double_pos_align.
Packit 0848f5
dnl
Packit 0848f5
dnl Search for "Power alignment mode" for more details.
Packit 0848f5
dnl
Packit 0848f5
dnl Possible values include yes, no, and unknown.
Packit 0848f5
dnl
Packit 0848f5
AC_DEFUN([PAC_C_DOUBLE_POS_ALIGN],[
Packit 0848f5
AC_CACHE_CHECK([if alignment of structs with doubles is based on position],
Packit 0848f5
pac_cv_c_double_pos_align,[
Packit 0848f5
AC_TRY_RUN([
Packit 0848f5
#include <stdio.h>
Packit 0848f5
#define DBG(a,b,c)
Packit 0848f5
int main( int argc, char *argv[] )
Packit 0848f5
{
Packit 0848f5
    FILE *cf;
Packit 0848f5
    int padding_varies_by_pos = 0;
Packit 0848f5
    struct { char a; double b; } char_double;
Packit 0848f5
    struct { double b; char a; } double_char;
Packit 0848f5
    int extent1, extent2;
Packit 0848f5
Packit 0848f5
    extent1 = sizeof(char_double);
Packit 0848f5
    extent2 = sizeof(double_char);
Packit 0848f5
    if (extent1 != extent2) padding_varies_by_pos = 1;
Packit 0848f5
Packit 0848f5
    cf = fopen( "ctest.out", "w" );
Packit 0848f5
    if (padding_varies_by_pos) fprintf( cf, "yes\n" );
Packit 0848f5
    else fprintf( cf, "no\n" );
Packit 0848f5
Packit 0848f5
    fclose( cf );
Packit 0848f5
    return 0;
Packit 0848f5
}],
Packit 0848f5
pac_cv_c_double_pos_align=`cat ctest.out`,
Packit 0848f5
pac_cv_c_double_pos_align="unknown",
Packit 0848f5
pac_cv_c_double_pos_align="$CROSS_ALIGN_DOUBLE_POS")
Packit 0848f5
rm -f ctest.out
Packit 0848f5
])
Packit 0848f5
if test -z "$pac_cv_c_double_pos_align" ; then
Packit 0848f5
    pac_cv_c_double_pos_align="unknown"
Packit 0848f5
fi
Packit 0848f5
])
Packit 0848f5
Packit 0848f5
dnl Test for odd struct alignment rule that only applies max.
Packit 0848f5
dnl padding when long long int value is at front of type.
Packit 0848f5
dnl Puts result in pac_cv_c_llint_pos_align.
Packit 0848f5
dnl
Packit 0848f5
dnl Search for "Power alignment mode" for more details.
Packit 0848f5
dnl
Packit 0848f5
dnl Possible values include yes, no, and unknown.
Packit 0848f5
dnl
Packit 0848f5
AC_DEFUN([PAC_C_LLINT_POS_ALIGN],[
Packit 0848f5
AC_CACHE_CHECK([if alignment of structs with long long ints is based on position],
Packit 0848f5
pac_cv_c_llint_pos_align,[
Packit 0848f5
AC_TRY_RUN([
Packit 0848f5
#include <stdio.h>
Packit 0848f5
#define DBG(a,b,c)
Packit 0848f5
int main( int argc, char *argv[] )
Packit 0848f5
{
Packit 0848f5
    FILE *cf;
Packit 0848f5
    int padding_varies_by_pos = 0;
Packit 0848f5
#ifdef HAVE_LONG_LONG_INT
Packit 0848f5
    struct { char a; long long int b; } char_llint;
Packit 0848f5
    struct { long long int b; char a; } llint_char;
Packit 0848f5
    int extent1, extent2;
Packit 0848f5
Packit 0848f5
    extent1 = sizeof(char_llint);
Packit 0848f5
    extent2 = sizeof(llint_char);
Packit 0848f5
    if (extent1 != extent2) padding_varies_by_pos = 1;
Packit 0848f5
#endif
Packit 0848f5
Packit 0848f5
    cf = fopen( "ctest.out", "w" );
Packit 0848f5
    if (padding_varies_by_pos) fprintf( cf, "yes\n" );
Packit 0848f5
    else fprintf( cf, "no\n" );
Packit 0848f5
Packit 0848f5
    fclose( cf );
Packit 0848f5
    return 0;
Packit 0848f5
}],
Packit 0848f5
pac_cv_c_llint_pos_align=`cat ctest.out`,
Packit 0848f5
pac_cv_c_llint_pos_align="unknown",
Packit 0848f5
pac_cv_c_llint_pos_align="$CROSS_ALIGN_LLINT_POS")
Packit 0848f5
rm -f ctest.out
Packit 0848f5
])
Packit 0848f5
if test -z "$pac_cv_c_llint_pos_align" ; then
Packit 0848f5
    pac_cv_c_llint_pos_align="unknown"
Packit 0848f5
fi
Packit 0848f5
])
Packit 0848f5
Packit 0848f5
dnl/*D
Packit 0848f5
dnl PAC_FUNC_NEEDS_DECL - Set NEEDS_<funcname>_DECL if a declaration is needed
Packit 0848f5
dnl
Packit 0848f5
dnl Synopsis:
Packit 0848f5
dnl PAC_FUNC_NEEDS_DECL(headerfiles,funcname)
Packit 0848f5
dnl
Packit 0848f5
dnl Output Effect:
Packit 0848f5
dnl Sets 'NEEDS_<funcname>_DECL' if 'funcname' is not declared by the 
Packit 0848f5
dnl headerfiles.
Packit 0848f5
dnl
Packit 0848f5
dnl Approach:
Packit 0848f5
dnl Attempt to assign library function to function pointer.  If the function
Packit 0848f5
dnl is not declared in a header, this will fail.  Use a non-static global so
Packit 0848f5
dnl the compiler does not warn about an unused variable.
Packit 0848f5
dnl
Packit 0848f5
dnl Simply calling the function is not enough because C89 compilers allow
Packit 0848f5
dnl calls to implicitly-defined functions.  Re-declaring a library function
Packit 0848f5
dnl with an incompatible prototype is also not sufficient because some
Packit 0848f5
dnl compilers (notably clang-3.2) only produce a warning in this case.
Packit 0848f5
dnl
Packit 0848f5
dnl D*/
Packit 0848f5
AC_DEFUN([PAC_FUNC_NEEDS_DECL],[
Packit 0848f5
AC_CACHE_CHECK([whether $2 needs a declaration],
Packit 0848f5
pac_cv_func_decl_$2,[
Packit 0848f5
AC_TRY_COMPILE([$1
Packit 0848f5
void (*fptr)(void) = (void(*)(void))$2;],[],
Packit 0848f5
pac_cv_func_decl_$2=no,pac_cv_func_decl_$2=yes)])
Packit 0848f5
if test "$pac_cv_func_decl_$2" = "yes" ; then
Packit 0848f5
changequote(<<,>>)dnl
Packit 0848f5
define(<<PAC_FUNC_NAME>>, translit(NEEDS_$2_DECL, [a-z *], [A-Z__]))dnl
Packit 0848f5
changequote([, ])dnl
Packit 0848f5
    AC_DEFINE_UNQUOTED(PAC_FUNC_NAME,1,[Define if $2 needs a declaration])
Packit 0848f5
undefine([PAC_FUNC_NAME])
Packit 0848f5
fi
Packit 0848f5
])
Packit 0848f5
Packit 0848f5
dnl PAC_C_GNU_ATTRIBUTE - See if the GCC __attribute__ specifier is allow.
Packit 0848f5
dnl Use the following
Packit 0848f5
dnl #ifndef HAVE_GCC_ATTRIBUTE
Packit 0848f5
dnl #define __attribute__(a)
Packit 0848f5
dnl #endif
Packit 0848f5
dnl If *not*, define __attribute__(a) as null
Packit 0848f5
dnl
Packit 0848f5
dnl We start by requiring Gcc.  Some other compilers accept __attribute__
Packit 0848f5
dnl but generate warning messages, or have different interpretations 
Packit 0848f5
dnl (which seems to make __attribute__ just as bad as #pragma) 
Packit 0848f5
dnl For example, the Intel icc compiler accepts __attribute__ and
Packit 0848f5
dnl __attribute__((pure)) but generates warnings for __attribute__((format...))
Packit 0848f5
dnl
Packit 0848f5
AC_DEFUN([PAC_C_GNU_ATTRIBUTE],[
Packit 0848f5
AC_REQUIRE([AC_PROG_CC_GNU])
Packit 0848f5
if test "$ac_cv_prog_gcc" = "yes" ; then
Packit 0848f5
    AC_CACHE_CHECK([whether __attribute__ allowed],
Packit 0848f5
pac_cv_gnu_attr_pure,[
Packit 0848f5
AC_TRY_COMPILE([int foo(int) __attribute__ ((pure));],[int a;],
Packit 0848f5
pac_cv_gnu_attr_pure=yes,pac_cv_gnu_attr_pure=no)])
Packit 0848f5
AC_CACHE_CHECK([whether __attribute__((format)) allowed],
Packit 0848f5
pac_cv_gnu_attr_format,[
Packit 0848f5
AC_TRY_COMPILE([int foo(char *,...) __attribute__ ((format(printf,1,2)));],[int a;],
Packit 0848f5
pac_cv_gnu_attr_format=yes,pac_cv_gnu_attr_format=no)])
Packit 0848f5
    if test "$pac_cv_gnu_attr_pure" = "yes" -a "$pac_cv_gnu_attr_format" = "yes" ; then
Packit 0848f5
        AC_DEFINE(HAVE_GCC_ATTRIBUTE,1,[Define if GNU __attribute__ is supported])
Packit 0848f5
    fi
Packit 0848f5
fi
Packit 0848f5
])
Packit 0848f5
dnl
Packit 0848f5
dnl Check for a broken install (fails to preserve file modification times,
Packit 0848f5
dnl thus breaking libraries.
Packit 0848f5
dnl
Packit 0848f5
dnl Create a library, install it, and then try to link against it.
Packit 0848f5
AC_DEFUN([PAC_PROG_INSTALL_BREAKS_LIBS],[
Packit 0848f5
AC_CACHE_CHECK([whether install breaks libraries],
Packit 0848f5
ac_cv_prog_install_breaks_libs,[
Packit 0848f5
AC_REQUIRE([AC_PROG_RANLIB])
Packit 0848f5
AC_REQUIRE([AC_PROG_INSTALL])
Packit 0848f5
AC_REQUIRE([AC_PROG_CC])
Packit 0848f5
ac_cv_prog_install_breaks_libs=yes
Packit 0848f5
Packit 0848f5
AC_COMPILE_IFELSE([
Packit 0848f5
    AC_LANG_SOURCE([ int foo(int); int foo(int a){return a;} ])
Packit 0848f5
],[
Packit 0848f5
    if ${AR-ar} ${AR_FLAGS-cr} libconftest.a conftest.$OBJEXT >/dev/null 2>&1 ; then
Packit 0848f5
        if ${RANLIB-:} libconftest.a >/dev/null 2>&1 ; then
Packit 0848f5
            # Anything less than sleep 10, and Mac OS/X (Darwin) 
Packit 0848f5
            # will claim that install works because ranlib won't complain
Packit 0848f5
            sleep 10
Packit 0848f5
            libinstall="$INSTALL_DATA"
Packit 0848f5
            eval "libinstall=\"$libinstall\""
Packit 0848f5
            if ${libinstall} libconftest.a libconftest1.a >/dev/null 2>&1 ; then
Packit 0848f5
                saved_LIBS="$LIBS"
Packit 0848f5
                LIBS="libconftest1.a"
Packit 0848f5
                AC_LINK_IFELSE([
Packit 0848f5
                    AC_LANG_SOURCE([
Packit 0848f5
extern int foo(int);
Packit 0848f5
int main(int argc, char **argv){ return foo(0); }
Packit 0848f5
                    ])
Packit 0848f5
                ],[
Packit 0848f5
                    # Success!  Install works
Packit 0848f5
                    ac_cv_prog_install_breaks_libs=no
Packit 0848f5
                ],[
Packit 0848f5
                    # Failure!  Does install -p work?        
Packit 0848f5
                    rm -f libconftest1.a
Packit 0848f5
                    if ${libinstall} -p libconftest.a libconftest1.a >/dev/null 2>&1 ; then
Packit 0848f5
                        AC_LINK_IFELSE([],[
Packit 0848f5
                            # Success!  Install works
Packit 0848f5
                            ac_cv_prog_install_breaks_libs="no, with -p"
Packit 0848f5
                        ])
Packit 0848f5
                    fi
Packit 0848f5
                ])
Packit 0848f5
                LIBS="$saved_LIBS"
Packit 0848f5
            fi
Packit 0848f5
        fi
Packit 0848f5
    fi
Packit 0848f5
])
Packit 0848f5
rm -f libconftest*.a
Packit 0848f5
]) dnl Endof ac_cache_check
Packit 0848f5
Packit 0848f5
if test -z "$RANLIB_AFTER_INSTALL" ; then
Packit 0848f5
    RANLIB_AFTER_INSTALL=no
Packit 0848f5
fi
Packit 0848f5
case "$ac_cv_prog_install_breaks_libs" in
Packit 0848f5
    yes)
Packit 0848f5
        RANLIB_AFTER_INSTALL=yes
Packit 0848f5
    ;;
Packit 0848f5
    "no, with -p")
Packit 0848f5
        INSTALL_DATA="$INSTALL_DATA -p"
Packit 0848f5
    ;;
Packit 0848f5
    *)
Packit 0848f5
    # Do nothing
Packit 0848f5
    :
Packit 0848f5
    ;;
Packit 0848f5
esac
Packit 0848f5
AC_SUBST(RANLIB_AFTER_INSTALL)
Packit 0848f5
])
Packit 0848f5
Packit 0848f5
#
Packit 0848f5
# determine if the compiler defines a symbol containing the function name
Packit 0848f5
#
Packit 0848f5
# These tests check not only that the compiler defines some symbol, such
Packit 0848f5
# as __FUNCTION__, but that the symbol correctly names the function.
Packit 0848f5
#
Packit 0848f5
# Defines 
Packit 0848f5
#   HAVE__FUNC__      (if __func__ defined)
Packit 0848f5
#   HAVE_CAP__FUNC__  (if __FUNC__ defined)
Packit 0848f5
#   HAVE__FUNCTION__  (if __FUNCTION__ defined)
Packit 0848f5
#
Packit 0848f5
AC_DEFUN([PAC_CC_FUNCTION_NAME_SYMBOL],[
Packit 0848f5
AC_CACHE_CHECK([whether the compiler defines __func__],
Packit 0848f5
pac_cv_have__func__,[
Packit 0848f5
tmp_am_cross=no
Packit 0848f5
AC_RUN_IFELSE([
Packit 0848f5
AC_LANG_SOURCE([
Packit 0848f5
#include <string.h>
Packit 0848f5
int foo(void);
Packit 0848f5
int foo(void)
Packit 0848f5
{
Packit 0848f5
    return (strcmp(__func__, "foo") == 0);
Packit 0848f5
}
Packit 0848f5
int main(int argc, char ** argv)
Packit 0848f5
{
Packit 0848f5
    return (foo() ? 0 : 1);
Packit 0848f5
}
Packit 0848f5
])
Packit 0848f5
], pac_cv_have__func__=yes, pac_cv_have__func__=no,tmp_am_cross=yes)
Packit 0848f5
if test "$tmp_am_cross" = yes ; then
Packit 0848f5
    AC_LINK_IFELSE([
Packit 0848f5
    AC_LANG_SOURCE([
Packit 0848f5
#include <string.h>
Packit 0848f5
int foo(void);
Packit 0848f5
int foo(void)
Packit 0848f5
{
Packit 0848f5
    return (strcmp(__func__, "foo") == 0);
Packit 0848f5
}
Packit 0848f5
int main(int argc, char ** argv)
Packit 0848f5
{
Packit 0848f5
    return (foo() ? 0 : 1);
Packit 0848f5
}
Packit 0848f5
    ])
Packit 0848f5
], pac_cv_have__func__=yes, pac_cv_have__func__=no)
Packit 0848f5
fi
Packit 0848f5
])
Packit 0848f5
Packit 0848f5
if test "$pac_cv_have__func__" = "yes" ; then
Packit 0848f5
    AC_DEFINE(HAVE__FUNC__,,[define if the compiler defines __func__])
Packit 0848f5
fi
Packit 0848f5
Packit 0848f5
AC_CACHE_CHECK([whether the compiler defines __FUNC__],
Packit 0848f5
pac_cv_have_cap__func__,[
Packit 0848f5
tmp_am_cross=no
Packit 0848f5
AC_RUN_IFELSE([
Packit 0848f5
AC_LANG_SOURCE([
Packit 0848f5
#include <string.h>
Packit 0848f5
int foo(void);
Packit 0848f5
int foo(void)
Packit 0848f5
{
Packit 0848f5
    return (strcmp(__FUNC__, "foo") == 0);
Packit 0848f5
}
Packit 0848f5
int main(int argc, char ** argv)
Packit 0848f5
{
Packit 0848f5
    return (foo() ? 0 : 1);
Packit 0848f5
}
Packit 0848f5
])
Packit 0848f5
], pac_cv_have_cap__func__=yes, pac_cv_have_cap__func__=no,tmp_am_cross=yes)
Packit 0848f5
if test "$tmp_am_cross" = yes ; then
Packit 0848f5
    AC_LINK_IFELSE([
Packit 0848f5
    AC_LANG_SOURCE([
Packit 0848f5
#include <string.h>
Packit 0848f5
int foo(void);
Packit 0848f5
int foo(void)
Packit 0848f5
{
Packit 0848f5
    return (strcmp(__FUNC__, "foo") == 0);
Packit 0848f5
}
Packit 0848f5
int main(int argc, char ** argv)
Packit 0848f5
{
Packit 0848f5
    return (foo() ? 0 : 1);
Packit 0848f5
}
Packit 0848f5
    ])
Packit 0848f5
], pac_cv_have__func__=yes, pac_cv_have__func__=no)
Packit 0848f5
fi
Packit 0848f5
])
Packit 0848f5
Packit 0848f5
if test "$pac_cv_have_cap__func__" = "yes" ; then
Packit 0848f5
    AC_DEFINE(HAVE_CAP__FUNC__,,[define if the compiler defines __FUNC__])
Packit 0848f5
fi
Packit 0848f5
Packit 0848f5
AC_CACHE_CHECK([whether the compiler sets __FUNCTION__],
Packit 0848f5
pac_cv_have__function__,[
Packit 0848f5
tmp_am_cross=no
Packit 0848f5
AC_RUN_IFELSE([
Packit 0848f5
AC_LANG_SOURCE([
Packit 0848f5
#include <string.h>
Packit 0848f5
int foo(void);
Packit 0848f5
int foo(void)
Packit 0848f5
{
Packit 0848f5
    return (strcmp(__FUNCTION__, "foo") == 0);
Packit 0848f5
}
Packit 0848f5
int main(int argc, char ** argv)
Packit 0848f5
{
Packit 0848f5
    return (foo() ? 0 : 1);
Packit 0848f5
}
Packit 0848f5
])
Packit 0848f5
], pac_cv_have__function__=yes, pac_cv_have__function__=no,tmp_am_cross=yes)
Packit 0848f5
if test "$tmp_am_cross" = yes ; then
Packit 0848f5
    AC_LINK_IFELSE([
Packit 0848f5
    AC_LANG_SOURCE([
Packit 0848f5
#include <string.h>
Packit 0848f5
int foo(void);
Packit 0848f5
int foo(void)
Packit 0848f5
{
Packit 0848f5
    return (strcmp(__FUNCTION__, "foo") == 0);
Packit 0848f5
}
Packit 0848f5
int main(int argc, char ** argv)
Packit 0848f5
{
Packit 0848f5
    return (foo() ? 0 : 1);
Packit 0848f5
}
Packit 0848f5
    ])
Packit 0848f5
], pac_cv_have__func__=yes, pac_cv_have__func__=no)
Packit 0848f5
fi
Packit 0848f5
])
Packit 0848f5
Packit 0848f5
if test "$pac_cv_have__function__" = "yes" ; then
Packit 0848f5
    AC_DEFINE(HAVE__FUNCTION__,,[define if the compiler defines __FUNCTION__])
Packit 0848f5
fi
Packit 0848f5
Packit 0848f5
])
Packit 0848f5
Packit 0848f5
Packit 0848f5
dnl Check structure alignment
Packit 0848f5
AC_DEFUN([PAC_STRUCT_ALIGNMENT],[
Packit 0848f5
	# Initialize alignment checks
Packit 0848f5
	is_packed=1
Packit 0848f5
	is_two=1
Packit 0848f5
	is_four=1
Packit 0848f5
	is_eight=1
Packit 0848f5
	is_largest=1
Packit 0848f5
Packit 0848f5
	# See if long double exists
Packit 0848f5
	AC_TRY_COMPILE(,[long double a;],have_long_double=yes,have_long_double=no)
Packit 0848f5
Packit 0848f5
	# Get sizes of regular types
Packit 0848f5
	AC_CHECK_SIZEOF(char)
Packit 0848f5
	AC_CHECK_SIZEOF(int)
Packit 0848f5
	AC_CHECK_SIZEOF(short)
Packit 0848f5
	AC_CHECK_SIZEOF(long)
Packit 0848f5
	AC_CHECK_SIZEOF(float)
Packit 0848f5
	AC_CHECK_SIZEOF(double)
Packit 0848f5
	AC_CHECK_SIZEOF(long double)
Packit 0848f5
Packit 0848f5
	# char_int comparison
Packit 0848f5
	AC_CHECK_SIZEOF(char_int, 0, [typedef struct { char a; int b; } char_int; ])
Packit 0848f5
	size=`expr $ac_cv_sizeof_char + $ac_cv_sizeof_int`
Packit 0848f5
	extent=$ac_cv_sizeof_char_int
Packit 0848f5
	if test "$size" != "$extent" ; then is_packed=0 ; fi
Packit 0848f5
	if test "`expr $extent % $ac_cv_sizeof_int`" != "0" ; then is_largest=0 ; fi
Packit 0848f5
	if test "`expr $extent % 2`" != "0" ; then is_two=0 ; fi
Packit 0848f5
	if test "`expr $extent % 4`" != "0" ; then is_four=0 ; fi
Packit 0848f5
	if test "$ac_cv_sizeof_int" = "8" -a "`expr $extent % 8`" != "0" ; then
Packit 0848f5
	   is_eight=0
Packit 0848f5
	fi
Packit 0848f5
Packit 0848f5
	# char_short comparison
Packit 0848f5
	AC_CHECK_SIZEOF(char_short, 0, [typedef struct { char a; short b; } char_short; ])
Packit 0848f5
	size=`expr $ac_cv_sizeof_char + $ac_cv_sizeof_short`
Packit 0848f5
	extent=$ac_cv_sizeof_char_short
Packit 0848f5
	if test "$size" != "$extent" ; then is_packed=0 ; fi
Packit 0848f5
	if test "`expr $extent % $ac_cv_sizeof_short`" != "0" ; then is_largest=0 ; fi
Packit 0848f5
	if test "`expr $extent % 2`" != "0" ; then is_two=0 ; fi
Packit 0848f5
	if test "$ac_cv_sizeof_short" = "4" -a "`expr $extent % 4`" != "0" ; then
Packit 0848f5
	   is_four=0
Packit 0848f5
	fi
Packit 0848f5
	if test "$ac_cv_sizeof_short" = "8" -a "`expr $extent % 8`" != "0" ; then
Packit 0848f5
	   is_eight=0
Packit 0848f5
	fi
Packit 0848f5
Packit 0848f5
	# char_long comparison
Packit 0848f5
	AC_CHECK_SIZEOF(char_long, 0, [typedef struct { char a; long b; } char_long; ])
Packit 0848f5
	size=`expr $ac_cv_sizeof_char + $ac_cv_sizeof_long`
Packit 0848f5
	extent=$ac_cv_sizeof_char_long
Packit 0848f5
	if test "$size" != "$extent" ; then is_packed=0 ; fi
Packit 0848f5
	if test "`expr $extent % $ac_cv_sizeof_long`" != "0" ; then is_largest=0 ; fi
Packit 0848f5
	if test "`expr $extent % 2`" != "0" ; then is_two=0 ; fi
Packit 0848f5
	if test "`expr $extent % 4`" != "0" ; then is_four=0 ; fi
Packit 0848f5
	if test "$ac_cv_sizeof_long" = "8" -a "`expr $extent % 8`" != "0" ; then
Packit 0848f5
	   is_eight=0
Packit 0848f5
	fi
Packit 0848f5
Packit 0848f5
	# char_float comparison
Packit 0848f5
	AC_CHECK_SIZEOF(char_float, 0, [typedef struct { char a; float b; } char_float; ])
Packit 0848f5
	size=`expr $ac_cv_sizeof_char + $ac_cv_sizeof_float`
Packit 0848f5
	extent=$ac_cv_sizeof_char_float
Packit 0848f5
	if test "$size" != "$extent" ; then is_packed=0 ; fi
Packit 0848f5
	if test "`expr $extent % $ac_cv_sizeof_float`" != "0" ; then is_largest=0 ; fi
Packit 0848f5
	if test "`expr $extent % 2`" != "0" ; then is_two=0 ; fi
Packit 0848f5
	if test "`expr $extent % 4`" != "0" ; then is_four=0 ; fi
Packit 0848f5
	if test "$ac_cv_sizeof_float" = "8" -a "`expr $extent % 8`" != "0" ; then
Packit 0848f5
	   is_eight=0
Packit 0848f5
	fi
Packit 0848f5
Packit 0848f5
	# char_double comparison
Packit 0848f5
	AC_CHECK_SIZEOF(char_double, 0, [typedef struct { char a; double b; } char_double; ])
Packit 0848f5
	size=`expr $ac_cv_sizeof_char + $ac_cv_sizeof_double`
Packit 0848f5
	extent=$ac_cv_sizeof_char_double
Packit 0848f5
	if test "$size" != "$extent" ; then is_packed=0 ; fi
Packit 0848f5
	if test "`expr $extent % $ac_cv_sizeof_double`" != "0" ; then is_largest=0 ; fi
Packit 0848f5
	if test "`expr $extent % 2`" != "0" ; then is_two=0 ; fi
Packit 0848f5
	if test "`expr $extent % 4`" != "0" ; then is_four=0 ; fi
Packit 0848f5
	if test "$ac_cv_sizeof_double" = "8" -a "`expr $extent % 8`" != "0" ; then
Packit 0848f5
	   is_eight=0
Packit 0848f5
	fi
Packit 0848f5
Packit 0848f5
	# char_long_double comparison
Packit 0848f5
	if test "$have_long_double" = "yes"; then
Packit 0848f5
	AC_CHECK_SIZEOF(char_long_double, 0, [
Packit 0848f5
				       typedef struct {
Packit 0848f5
				       	       char a;
Packit 0848f5
					       long double b;
Packit 0848f5
				       } char_long_double;
Packit 0848f5
				       ])
Packit 0848f5
	size=`expr $ac_cv_sizeof_char + $ac_cv_sizeof_long_double`
Packit 0848f5
	extent=$ac_cv_sizeof_char_long_double
Packit 0848f5
	if test "$size" != "$extent" ; then is_packed=0 ; fi
Packit 0848f5
	if test "`expr $extent % $ac_cv_sizeof_long_double`" != "0" ; then is_largest=0 ; fi
Packit 0848f5
	if test "`expr $extent % 2`" != "0" ; then is_two=0 ; fi
Packit 0848f5
	if test "`expr $extent % 4`" != "0" ; then is_four=0 ; fi
Packit 0848f5
	if test "$ac_cv_sizeof_long_double" = "8" -a "`expr $extent % 8`" != "0" ; then
Packit 0848f5
	   is_eight=0
Packit 0848f5
	fi
Packit 0848f5
	fi
Packit 0848f5
Packit 0848f5
	# char_int_char comparison
Packit 0848f5
	AC_CHECK_SIZEOF(char_int_char, 0, [
Packit 0848f5
				       typedef struct {
Packit 0848f5
				       	       char a;
Packit 0848f5
					       int b;
Packit 0848f5
					       char c;
Packit 0848f5
				       } char_int_char;
Packit 0848f5
				       ])
Packit 0848f5
	size=`expr $ac_cv_sizeof_char + $ac_cv_sizeof_int + $ac_cv_sizeof_char`
Packit 0848f5
	extent=$ac_cv_sizeof_char_int_char
Packit 0848f5
	if test "$size" != "$extent" ; then is_packed=0 ; fi
Packit 0848f5
	if test "`expr $extent % $ac_cv_sizeof_int`" != "0" ; then is_largest=0 ; fi
Packit 0848f5
	if test "`expr $extent % 2`" != "0" ; then is_two=0 ; fi
Packit 0848f5
	if test "`expr $extent % 4`" != "0" ; then is_four=0 ; fi
Packit 0848f5
	if test "$ac_cv_sizeof_int" = "8" -a "`expr $extent % 8`" != "0" ; then
Packit 0848f5
	   is_eight=0
Packit 0848f5
	fi
Packit 0848f5
Packit 0848f5
	# char_short_char comparison
Packit 0848f5
	AC_CHECK_SIZEOF(char_short_char, 0, [
Packit 0848f5
				       typedef struct {
Packit 0848f5
				       	       char a;
Packit 0848f5
					       short b;
Packit 0848f5
					       char c;
Packit 0848f5
				       } char_short_char;
Packit 0848f5
				       ])
Packit 0848f5
	size=`expr $ac_cv_sizeof_char + $ac_cv_sizeof_short + $ac_cv_sizeof_char`
Packit 0848f5
	extent=$ac_cv_sizeof_char_short_char
Packit 0848f5
	if test "$size" != "$extent" ; then is_packed=0 ; fi
Packit 0848f5
	if test "`expr $extent % $ac_cv_sizeof_short`" != "0" ; then is_largest=0 ; fi
Packit 0848f5
	if test "`expr $extent % 2`" != "0" ; then is_two=0 ; fi
Packit 0848f5
	if test "$ac_cv_sizeof_short" = "4" -a "`expr $extent % 4`" != "0" ; then
Packit 0848f5
	   is_four=0
Packit 0848f5
	fi
Packit 0848f5
	if test "$ac_cv_sizeof_short" = "8" -a "`expr $extent % 8`" != "0" ; then
Packit 0848f5
	   is_eight=0
Packit 0848f5
	fi
Packit 0848f5
Packit 0848f5
	# If aligned mod 8, it will be aligned mod 4
Packit 0848f5
	if test $is_eight = 1 ; then is_four=0 ; is_two=0 ; fi
Packit 0848f5
	if test $is_four = 1 ; then is_two=0 ; fi
Packit 0848f5
Packit 0848f5
	# Largest supersedes 8
Packit 0848f5
	if test $is_largest = 1 ; then is_eight=0 ; fi
Packit 0848f5
Packit 0848f5
	# Find the alignment
Packit 0848f5
	if test "`expr $is_packed + $is_largest + $is_two + $is_four + $is_eight`" = "0" ; then
Packit 0848f5
	   pac_cv_struct_alignment="unknown"
Packit 0848f5
	elif test "`expr $is_packed + $is_largest + $is_two + $is_four + $is_eight`" != "1" ; then
Packit 0848f5
	   pac_cv_struct_alignment="unknown"
Packit 0848f5
	elif test $is_packed = 1 ; then
Packit 0848f5
	   pac_cv_struct_alignment="packed"
Packit 0848f5
	elif test $is_largest = 1 ; then
Packit 0848f5
	   pac_cv_struct_alignment="largest"
Packit 0848f5
	elif test $is_two = 1 ; then
Packit 0848f5
	   pac_cv_struct_alignment="two"
Packit 0848f5
	elif test $is_four = 1 ; then
Packit 0848f5
	   pac_cv_struct_alignment="four"
Packit 0848f5
	elif test $is_eight = 1 ; then
Packit 0848f5
	   pac_cv_struct_alignment="eight"
Packit 0848f5
	fi
Packit 0848f5
])
Packit 0848f5
dnl
Packit 0848f5
dnl PAC_C_MACRO_VA_ARGS
Packit 0848f5
dnl
Packit 0848f5
dnl will AC_DEFINE([HAVE_MACRO_VA_ARGS]) if the compiler supports C99 variable
Packit 0848f5
dnl length argument lists in macros (#define foo(...) bar(__VA_ARGS__))
Packit 0848f5
AC_DEFUN([PAC_C_MACRO_VA_ARGS],[
Packit 0848f5
    AC_MSG_CHECKING([for variable argument list macro functionality])
Packit 0848f5
    AC_LINK_IFELSE([AC_LANG_PROGRAM([
Packit 0848f5
        #include <stdio.h>
Packit 0848f5
        #define conftest_va_arg_macro(...) printf(__VA_ARGS__)
Packit 0848f5
    ],
Packit 0848f5
    [conftest_va_arg_macro("a test %d", 3);])],
Packit 0848f5
    [AC_DEFINE([HAVE_MACRO_VA_ARGS],[1],[Define if C99-style variable argument list macro functionality])
Packit 0848f5
     AC_MSG_RESULT([yes])],
Packit 0848f5
    [AC_MSG_RESULT([no])])
Packit 0848f5
])dnl
Packit 0848f5
Packit 0848f5
# Will AC_DEFINE([HAVE_BUILTIN_EXPECT]) if the compiler supports __builtin_expect.
Packit 0848f5
AC_DEFUN([PAC_C_BUILTIN_EXPECT],[
Packit 0848f5
AC_MSG_CHECKING([if C compiler supports __builtin_expect])
Packit 0848f5
Packit 0848f5
AC_TRY_LINK(, [
Packit 0848f5
    return __builtin_expect(1, 1) ? 1 : 0
Packit 0848f5
], [
Packit 0848f5
    have_builtin_expect=yes
Packit 0848f5
    AC_MSG_RESULT([yes])
Packit 0848f5
], [
Packit 0848f5
    have_builtin_expect=no
Packit 0848f5
    AC_MSG_RESULT([no])
Packit 0848f5
])
Packit 0848f5
if test x$have_builtin_expect = xyes ; then
Packit 0848f5
    AC_DEFINE([HAVE_BUILTIN_EXPECT], [1], [Define to 1 if the compiler supports __builtin_expect.])
Packit 0848f5
fi
Packit 0848f5
])