"Fossies" - the Fresh Open Source Software Archive

Member "hydra-3.3.2/mpl/confdb/aclocal_cc.m4" (12 Nov 2019, 56254 Bytes) of package /linux/misc/hydra-3.3.2.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "aclocal_cc.m4": 3.3.1_vs_3.3.2.

    1 dnl AC_PROG_CC_GNU
    2 ifdef([AC_PROG_CC_GNU],,[AC_DEFUN([AC_PROG_CC_GNU],)])
    3 
    4 dnl PAC_PROG_CC - reprioritize the C compiler search order
    5 AC_DEFUN([PAC_PROG_CC],[
    6         dnl Many standard autoconf/automake/libtool macros, such as LT_INIT,
    7         dnl perform an AC_REQUIRE([AC_PROG_CC]).  If this macro (PAC_PROG_CC)
    8         dnl comes after LT_INIT (or similar) then the default compiler search
    9         dnl path will be used instead.  This AC_BEFORE macro ensures that a
   10         dnl warning will be emitted at autoconf-time (autogen.sh-time) to help
   11         dnl developers notice this case.
   12         AC_BEFORE([$0],[AC_PROG_CC])
   13 	PAC_PUSH_FLAG([CFLAGS])
   14 	AC_PROG_CC([icc pgcc xlc xlC pathcc gcc clang cc])
   15 	PAC_POP_FLAG([CFLAGS])
   16 ])
   17 dnl
   18 dnl/*D
   19 dnl PAC_C_CHECK_COMPILER_OPTION - Check that a compiler option is accepted
   20 dnl without warning messages
   21 dnl
   22 dnl Synopsis:
   23 dnl PAC_C_CHECK_COMPILER_OPTION(optionname,action-if-ok,action-if-fail)
   24 dnl
   25 dnl Output Effects:
   26 dnl
   27 dnl If no actions are specified, a working value is added to 'COPTIONS'
   28 dnl
   29 dnl Notes:
   30 dnl This is now careful to check that the output is different, since 
   31 dnl some compilers are noisy.
   32 dnl 
   33 dnl We are extra careful to prototype the functions in case compiler options
   34 dnl that complain about poor code are in effect.
   35 dnl
   36 dnl Because this is a long script, we have ensured that you can pass a 
   37 dnl variable containing the option name as the first argument.
   38 dnl
   39 dnl D*/
   40 AC_DEFUN([PAC_C_CHECK_COMPILER_OPTION],[
   41 AC_MSG_CHECKING([whether C compiler accepts option $1])
   42 pac_opt="$1"
   43 AC_LANG_PUSH([C])
   44 CFLAGS_orig="$CFLAGS"
   45 CFLAGS_opt="$pac_opt $CFLAGS"
   46 pac_result="unknown"
   47 
   48 AC_LANG_CONFTEST([
   49 	AC_LANG_PROGRAM([[#include <stdio.h>
   50                           const char hw[] = "Hello, World\n";]],
   51 		[[fputs (hw, stdout);]])
   52 ])
   53 CFLAGS="$CFLAGS_orig"
   54 rm -f pac_test1.log
   55 PAC_LINK_IFELSE_LOG([pac_test1.log], [], [
   56     CFLAGS="$CFLAGS_opt"
   57     rm -f pac_test2.log
   58     PAC_LINK_IFELSE_LOG([pac_test2.log], [], [
   59         PAC_RUNLOG_IFELSE([diff -b pac_test1.log pac_test2.log],
   60                           [pac_result=yes],[pac_result=no])
   61     ],[
   62         pac_result=no
   63     ])
   64 ], [
   65     pac_result=no
   66 ])
   67 AC_MSG_RESULT([$pac_result])
   68 dnl Delete the conftest created by AC_LANG_CONFTEST.
   69 rm -f conftest.$ac_ext
   70 
   71 # gcc 4.2.4 on 32-bit does not complain about the -Wno-type-limits option 
   72 # even though it doesn't support it.  However, when another warning is 
   73 # triggered, it gives an error that the option is not recognized.  So we 
   74 # need to test with a conftest file that will generate warnings.
   75 # 
   76 # add an extra switch, pac_c_check_compiler_option_prototest, to
   77 # disable this test just in case some new compiler does not like it.
   78 #
   79 # Linking with a program with an invalid prototype to ensure a compiler warning.
   80 
   81 if test "$pac_result" = "yes" \
   82      -a "$pac_c_check_compiler_option_prototest" != "no" ; then
   83     AC_MSG_CHECKING([whether C compiler option $1 works with an invalid prototype program])
   84     AC_LINK_IFELSE([
   85         dnl We want a warning, but we don't want to inadvertently disable
   86         dnl special warnings like -Werror-implicit-function-declaration (e.g.,
   87         dnl in PAC_CC_STRICT) by compiling something that might actually be
   88         dnl treated as an error by the compiler.  So we try to elicit an
   89         dnl "unused variable" warning and/or an "uninitialized" warning with the
   90         dnl test program below.
   91         dnl
   92         dnl The old sanity program was:
   93         dnl   void main() {return 0;}
   94         dnl which clang (but not GCC) would treat as an *error*, invalidating
   95         dnl the test for any given parameter.
   96         AC_LANG_SOURCE([int main(int argc, char **argv){ int foo, bar = 0; foo += 1; return foo; }])
   97     ],[pac_result=yes],[pac_result=no])
   98     AC_MSG_RESULT([$pac_result])
   99 fi
  100 #
  101 if test "$pac_result" = "yes" ; then
  102     AC_MSG_CHECKING([whether routines compiled with $pac_opt can be linked with ones compiled without $pac_opt])
  103     pac_result=unknown
  104     CFLAGS="$CFLAGS_orig"
  105     rm -f pac_test3.log
  106     PAC_COMPILE_IFELSE_LOG([pac_test3.log], [
  107         AC_LANG_SOURCE([
  108             int foo(void);
  109             int foo(void){return 0;}
  110         ])
  111     ],[
  112         PAC_RUNLOG([mv conftest.$OBJEXT pac_conftest.$OBJEXT])
  113         saved_LIBS="$LIBS"
  114         LIBS="pac_conftest.$OBJEXT $LIBS"
  115 
  116         rm -f pac_test4.log
  117         PAC_LINK_IFELSE_LOG([pac_test4.log], [AC_LANG_PROGRAM()], [
  118             CFLAGS="$CFLAGS_opt"
  119             rm -f pac_test5.log
  120             PAC_LINK_IFELSE_LOG([pac_test5.log], [AC_LANG_PROGRAM()], [
  121                 PAC_RUNLOG_IFELSE([diff -b pac_test4.log pac_test5.log],
  122                                   [pac_result=yes], [pac_result=no])
  123             ],[
  124                 pac_result=no
  125             ])
  126         ],[
  127             pac_result=no
  128         ])
  129         LIBS="$saved_LIBS"
  130         rm -f pac_conftest.$OBJEXT
  131     ],[
  132         pac_result=no
  133     ])
  134     AC_MSG_RESULT([$pac_result])
  135     rm -f pac_test3.log pac_test4.log pac_test5.log
  136 fi
  137 rm -f pac_test1.log pac_test2.log
  138 
  139 dnl Restore CFLAGS before 2nd/3rd argument commands are executed,
  140 dnl as 2nd/3rd argument command could be modifying CFLAGS.
  141 CFLAGS="$CFLAGS_orig"
  142 if test "$pac_result" = "yes" ; then
  143      ifelse([$2],[],[COPTIONS="$COPTIONS $1"],[$2])
  144 else
  145      ifelse([$3],[],[:],[$3])
  146 fi
  147 AC_LANG_POP([C])
  148 ])
  149 dnl
  150 dnl/*D
  151 dnl PAC_C_OPTIMIZATION - Determine C options for producing optimized code
  152 dnl
  153 dnl Synopsis
  154 dnl PAC_C_OPTIMIZATION([action if found])
  155 dnl
  156 dnl Output Effect:
  157 dnl Adds options to 'COPTIONS' if no other action is specified
  158 dnl 
  159 dnl Notes:
  160 dnl This is a temporary standin for compiler optimization.
  161 dnl It should try to match known systems to known compilers (checking, of
  162 dnl course), and then falling back to some common defaults.
  163 dnl Note that many compilers will complain about -g and aggressive
  164 dnl optimization.  
  165 dnl D*/
  166 AC_DEFUN([PAC_C_OPTIMIZATION],[
  167     for copt in "-O4 -Ofast" "-Ofast" "-fast" "-O3" "-xO3" "-O" ; do
  168         PAC_C_CHECK_COMPILER_OPTION($copt,found_opt=yes,found_opt=no)
  169         if test "$found_opt" = "yes" ; then
  170 	    ifelse($1,,COPTIONS="$COPTIONS $copt",$1)
  171 	    break
  172         fi
  173     done
  174     if test "$ac_cv_prog_gcc" = "yes" ; then
  175 	for copt in "-fomit-frame-pointer" "-finline-functions" \
  176 		 "-funroll-loops" ; do
  177 	    PAC_C_CHECK_COMPILER_OPTION($copt,found_opt=yes,found_opt=no)
  178 	    if test "$found_opt" = "yes" ; then
  179 	        ifelse($1,,COPTIONS="$COPTIONS $copt",$1)
  180 	        # no break because we're trying to add them all
  181 	    fi
  182 	done
  183 	# We could also look for architecture-specific gcc options
  184     fi
  185 
  186 ])
  187 
  188 dnl/*D
  189 dnl PAC_PROG_C_UNALIGNED_DOUBLES - Check that the C compiler allows unaligned
  190 dnl doubles
  191 dnl
  192 dnl Synopsis:
  193 dnl   PAC_PROG_C_UNALIGNED_DOUBLES(action-if-true,action-if-false,
  194 dnl       action-if-unknown)
  195 dnl
  196 dnl Notes:
  197 dnl 'action-if-unknown' is used in the case of cross-compilation.
  198 dnl D*/
  199 AC_DEFUN([PAC_PROG_C_UNALIGNED_DOUBLES],[
  200 AC_CACHE_CHECK([whether C compiler allows unaligned doubles],
  201 pac_cv_prog_c_unaligned_doubles,[
  202 AC_TRY_RUN([
  203 void fetch_double( v )
  204 double *v;
  205 {
  206 *v = 1.0;
  207 }
  208 int main( argc, argv )
  209 int argc;
  210 char **argv;
  211 {
  212 int p[4];
  213 double *p_val;
  214 fetch_double( (double *)&(p[0]) );
  215 p_val = (double *)&(p[0]);
  216 if (*p_val != 1.0) return 1;
  217 fetch_double( (double *)&(p[1]) );
  218 p_val = (double *)&(p[1]);
  219 if (*p_val != 1.0) return 1;
  220 return 0;
  221 }
  222 ],pac_cv_prog_c_unaligned_doubles="yes",pac_cv_prog_c_unaligned_doubles="no",
  223 pac_cv_prog_c_unaligned_doubles="unknown")])
  224 ifelse($1,,,if test "X$pac_cv_prog_c_unaligned_doubles" = "yes" ; then 
  225 $1
  226 fi)
  227 ifelse($2,,,if test "X$pac_cv_prog_c_unaligned_doubles" = "no" ; then 
  228 $2
  229 fi)
  230 ifelse($3,,,if test "X$pac_cv_prog_c_unaligned_doubles" = "unknown" ; then 
  231 $3
  232 fi)
  233 ])
  234 
  235 dnl/*D 
  236 dnl PAC_PROG_C_WEAK_SYMBOLS - Test whether C supports weak alias symbols.
  237 dnl
  238 dnl Synopsis
  239 dnl PAC_PROG_C_WEAK_SYMBOLS(action-if-true,action-if-false)
  240 dnl
  241 dnl Output Effect:
  242 dnl Defines one of the following if a weak symbol pragma is found:
  243 dnl.vb
  244 dnl    HAVE_PRAGMA_WEAK - #pragma weak
  245 dnl    HAVE_PRAGMA_HP_SEC_DEF - #pragma _HP_SECONDARY_DEF
  246 dnl    HAVE_PRAGMA_CRI_DUP  - #pragma _CRI duplicate x as y
  247 dnl.ve
  248 dnl May also define
  249 dnl.vb
  250 dnl    HAVE_WEAK_ATTRIBUTE
  251 dnl.ve
  252 dnl if functions can be declared as 'int foo(...) __attribute__ ((weak));'
  253 dnl sets the shell variable pac_cv_attr_weak to yes.
  254 dnl Also checks for __attribute__((weak_import)) which is supported by
  255 dnl Apple in Mac OSX (at least in Darwin).  Note that this provides only
  256 dnl weak symbols, not weak aliases
  257 dnl 
  258 dnl D*/
  259 AC_DEFUN([PAC_PROG_C_WEAK_SYMBOLS],[
  260 pragma_extra_message=""
  261 AC_CACHE_CHECK([for type of weak symbol alias support],
  262 pac_cv_prog_c_weak_symbols,[
  263 # Test for weak symbol support...
  264 # We can't put # in the message because it causes autoconf to generate
  265 # incorrect code
  266 AC_TRY_LINK([
  267 extern int PFoo(int);
  268 #pragma weak PFoo = Foo
  269 int Foo(int a) { return a; }
  270 ],[return PFoo(1);],has_pragma_weak=yes)
  271 #
  272 # Some systems (Linux ia64 and ecc, for example), support weak symbols
  273 # only within a single object file!  This tests that case.
  274 # Note that there is an extern int PFoo declaration before the
  275 # pragma.  Some compilers require this in order to make the weak symbol
  276 # externally visible.  
  277 if test "$has_pragma_weak" = yes ; then
  278     PAC_COMPLINK_IFELSE([
  279         AC_LANG_SOURCE([
  280 extern int PFoo(int);
  281 #pragma weak PFoo = Foo
  282 int Foo(int);
  283 int Foo(int a) { return a; }
  284         ])
  285     ],[
  286         AC_LANG_SOURCE([
  287 extern int PFoo(int);
  288 int main(int argc, char **argv) {
  289 return PFoo(0);}
  290         ])
  291     ],[
  292         PAC_COMPLINK_IFELSE([
  293             AC_LANG_SOURCE([
  294 extern int PFoo(int);
  295 #pragma weak PFoo = Foo
  296 int Foo(int);
  297 int Foo(int a) { return a; }
  298             ])
  299         ],[
  300             AC_LANG_SOURCE([
  301 extern int Foo(int);
  302 int PFoo(int a) { return a+1;}
  303 int main(int argc, char **argv) {
  304 return Foo(0);}
  305             ])
  306         ],[
  307             pac_cv_prog_c_weak_symbols="pragma weak"
  308         ],[
  309             has_pragma_weak=0
  310             pragma_extra_message="pragma weak accepted but does not work (probably creates two non-weak entries)"
  311         ])
  312     ],[
  313         has_pragma_weak=0
  314         pragma_extra_message="pragma weak accepted but does not work (probably creates two non-weak entries)"
  315     ])
  316 fi
  317 dnl
  318 if test -z "$pac_cv_prog_c_weak_symbols" ; then 
  319     AC_TRY_LINK([
  320 extern int PFoo(int);
  321 #pragma _HP_SECONDARY_DEF Foo  PFoo
  322 int Foo(int a) { return a; }
  323 ],[return PFoo(1);],pac_cv_prog_c_weak_symbols="pragma _HP_SECONDARY_DEF")
  324 fi
  325 dnl
  326 if test -z "$pac_cv_prog_c_weak_symbols" ; then
  327     AC_TRY_LINK([
  328 extern int PFoo(int);
  329 #pragma _CRI duplicate PFoo as Foo
  330 int Foo(int a) { return a; }
  331 ],[return PFoo(1);],pac_cv_prog_c_weak_symbols="pragma _CRI duplicate x as y")
  332 fi
  333 dnl
  334 if test -z "$pac_cv_prog_c_weak_symbols" ; then
  335     pac_cv_prog_c_weak_symbols="no"
  336 fi
  337 dnl
  338 dnl If there is an extra explanatory message, echo it now so that it
  339 dnl doesn't interfere with the cache result value
  340 if test -n "$pragma_extra_message" ; then
  341     echo $pragma_extra_message
  342 fi
  343 dnl
  344 ])
  345 if test "$pac_cv_prog_c_weak_symbols" != "no" ; then
  346     case "$pac_cv_prog_c_weak_symbols" in
  347         "pragma weak") AC_DEFINE(HAVE_PRAGMA_WEAK,1,[Supports weak pragma])
  348         ;;
  349         "pragma _HP")  AC_DEFINE(HAVE_PRAGMA_HP_SEC_DEF,1,[HP style weak pragma])
  350         ;;
  351         "pragma _CRI") AC_DEFINE(HAVE_PRAGMA_CRI_DUP,1,[Cray style weak pragma])
  352         ;;
  353     esac
  354 fi
  355 AC_CACHE_CHECK([whether __attribute__ ((weak)) allowed],
  356 pac_cv_attr_weak,[
  357 AC_TRY_COMPILE([int foo(int) __attribute__ ((weak));],[int a;],
  358 pac_cv_attr_weak=yes,pac_cv_attr_weak=no)])
  359 # Note that being able to compile with weak_import doesn't mean that
  360 # it works.
  361 AC_CACHE_CHECK([whether __attribute__ ((weak_import)) allowed],
  362 pac_cv_attr_weak_import,[
  363 AC_TRY_COMPILE([int foo(int) __attribute__ ((weak_import));],[int a;],
  364 pac_cv_attr_weak_import=yes,pac_cv_attr_weak_import=no)])
  365 # Check if the alias option for weak attributes is allowed
  366 AC_CACHE_CHECK([whether __attribute__((weak,alias(...))) allowed],
  367 pac_cv_attr_weak_alias,[
  368 PAC_PUSH_FLAG([CFLAGS])
  369 # force an error exit if the weak attribute isn't understood
  370 CFLAGS=-Werror
  371 AC_TRY_COMPILE([int __foo(int a){return 0;} int foo(int) __attribute__((weak,alias("__foo")));],[int a;],
  372 pac_cv_attr_weak_alias=yes,pac_cv_attr_weak_alias=no)
  373 # Restore original CFLAGS
  374 PAC_POP_FLAG([CFLAGS])])
  375 if test "$pac_cv_attr_weak_alias" = "yes" ; then
  376     AC_DEFINE(HAVE_WEAK_ATTRIBUTE,1,[Attribute style weak pragma])
  377 fi
  378 if test "$pac_cv_prog_c_weak_symbols" = "no" -a "$pac_cv_attr_weak_alias" = "no" ; then
  379     ifelse([$2],,:,[$2])
  380 else
  381     ifelse([$1],,:,[$1])
  382 fi
  383 ])
  384 
  385 #
  386 # This is a replacement that checks that FAILURES are signaled as well
  387 # (later configure macros look for the .o file, not just success from the
  388 # compiler, but they should not HAVE to
  389 #
  390 dnl --- insert 2.52 compatibility here ---
  391 dnl 2.52 does not have AC_PROG_CC_WORKS
  392 ifdef([AC_PROG_CC_WORKS],,[AC_DEFUN([AC_PROG_CC_WORKS],)])
  393 dnl
  394 AC_DEFUN([PAC_PROG_CC_WORKS],
  395 [AC_PROG_CC_WORKS
  396 AC_MSG_CHECKING([whether the C compiler sets its return status correctly])
  397 AC_LANG_SAVE
  398 AC_LANG_C
  399 AC_TRY_COMPILE(,[int a = bzzzt;],notbroken=no,notbroken=yes)
  400 AC_MSG_RESULT($notbroken)
  401 if test "$notbroken" = "no" ; then
  402     AC_MSG_ERROR([installation or configuration problem: C compiler does not
  403 correctly set error code when a fatal error occurs])
  404 fi
  405 ])
  406 
  407 dnl/*D 
  408 dnl PAC_PROG_C_MULTIPLE_WEAK_SYMBOLS - Test whether C and the
  409 dnl linker allow multiple weak symbols.
  410 dnl
  411 dnl Synopsis
  412 dnl PAC_PROG_C_MULTIPLE_WEAK_SYMBOLS(action-if-true,action-if-false)
  413 dnl
  414 dnl 
  415 dnl D*/
  416 AC_DEFUN([PAC_PROG_C_MULTIPLE_WEAK_SYMBOLS],[
  417 AC_CACHE_CHECK([for multiple weak symbol support],
  418 pac_cv_prog_c_multiple_weak_symbols,[
  419 # Test for multiple weak symbol support...
  420 PAC_COMPLINK_IFELSE([
  421     AC_LANG_SOURCE([
  422 extern int PFoo(int);
  423 extern int PFoo_(int);
  424 extern int pfoo_(int);
  425 #pragma weak PFoo = Foo
  426 #pragma weak PFoo_ = Foo
  427 #pragma weak pfoo_ = Foo
  428 int Foo(int);
  429 int Foo(a) { return a; }
  430     ])
  431 ],[
  432     AC_LANG_SOURCE([
  433 extern int PFoo(int), PFoo_(int), pfoo_(int);
  434 int main() {
  435 return PFoo(0) + PFoo_(1) + pfoo_(2);}
  436     ])
  437 ],[
  438     pac_cv_prog_c_multiple_weak_symbols="yes"
  439 ])
  440 dnl
  441 ])
  442 if test "$pac_cv_prog_c_multiple_weak_symbols" = "yes" ; then
  443     ifelse([$1],,:,[$1])
  444 else
  445     ifelse([$2],,:,[$2])
  446 fi
  447 ])
  448 
  449 dnl Use the value of enable-strict to update CFLAGS
  450 dnl pac_cc_strict_flags contains the strict flags.
  451 dnl
  452 dnl -std=c89 is used to select the C89 version of the ANSI/ISO C standard.
  453 dnl As of this writing, many C compilers still accepted only this version,
  454 dnl not the later C99 version. When all compilers accept C99, this 
  455 dnl should be changed to the appropriate standard level.  Note that we've
  456 dnl had trouble with gcc 2.95.3 accepting -std=c89 but then trying to 
  457 dnl compile program with a invalid set of options 
  458 dnl (-D __STRICT_ANSI__-trigraphs)
  459 AC_DEFUN([PAC_CC_STRICT],[
  460 export enable_strict_done
  461 if test "$enable_strict_done" != "yes" ; then
  462 
  463     # Some comments on strict warning options.
  464     # These were added to improve portability
  465     #   -Wstack-usage=262144 -- 32 bit FreeBSD did not like the mprobe test
  466     #       allocating a big variable on the stack. (See tt#2160).  The "right"
  467     #       value requires further investigation; 1 MiB would have at least
  468     #       caught #2160 at compile-time, and only two other tests show a
  469     #       warning at 256k.
  470     #
  471     # These were added to reduce warnings:
  472     #   -Wno-missing-field-initializers  -- We want to allow a struct to be 
  473     #       initialized to zero using "struct x y = {0};" and not require 
  474     #       each field to be initialized individually.
  475     #   -Wno-unused-parameter -- For portability, some parameters go unused
  476     #	    when we have different implementations of functions for 
  477     #	    different platforms
  478     #   -Wno-unused-label -- We add fn_exit: and fn_fail: on all functions, 
  479     #	    but fn_fail may not be used if the function doesn't return an 
  480     #	    error.
  481     #   -Wno-sign-compare -- read() and write() return bytes read/written
  482     #       as a signed value, but we often compare this to size_t (or
  483     #	    msg_sz_t) variables.
  484     #   -Wno-format-zero-length -- this warning is irritating and useless, since
  485     #                              a zero-length format string is very well defined
  486     # These were removed to reduce warnings:
  487     #   -Wcast-qual -- Sometimes we need to cast "volatile char*" to 
  488     #	    "char*", e.g., for memcpy.
  489     #   -Wpadded -- We catch struct padding with asserts when we need to
  490     #   -Wredundant-decls -- Having redundant declarations is benign and the 
  491     #	    code already has some.
  492     #   -Waggregate-return -- This seems to be a performance-related warning
  493     #       aggregate return values are legal in ANSI C, but they may be returned
  494     #	    in memory rather than through a register.  We do use aggregate return
  495     #	    values, but they are structs of a single basic type (used to enforce
  496     #	    type checking for relative vs. absolute ptrs), and with optimization
  497     #	    the aggregate value is converted to a scalar.
  498     #   -Wdeclaration-after-statement -- This is a C89
  499     #       requirement. When compiling with C99, this should be
  500     #       disabled.
  501     #   -Wfloat-equal -- There are places in hwloc that set a float var to 0, then 
  502     #       compare it to 0 later to see if it was updated.  Also when using strtod()
  503     #       one needs to compare the return value with 0 to see whether a conversion
  504     #       was performed.
  505     #   -Werror-implicit-function-declaration -- implicit function declarations
  506     #       should never be tolerated.  This also ensures that we get quick
  507     #       compilation failures rather than later link failures that usually
  508     #       come from a function name typo.
  509     #   -Wcast-align -- Casting alignment warnings.  This is an
  510     #       important check, but is temporarily disabled, since it is
  511     #       throwing too many (correct) warnings currently, causing us
  512     #       to miss other warnings.
  513     #   -Wshorten-64-to-32 -- Bad type-casting warnings.  This is an
  514     #       important check, but is temporarily disabled, since it is
  515     #       throwing too many (correct) warnings currently, causing us
  516     #       to miss other warnings.
  517     #
  518     # This was removed because it masks important failures (see ticket #2094).
  519     # However, since Intel compiler currently does not include -Wtype-limits
  520     # in -Wextra, -Wtype-limits was added to handle warnings with the Intel
  521     # compiler.
  522     #   -Wno-type-limits -- There are places where we compare an unsigned to 
  523     #	    a constant that happens to be zero e.g., if x is unsigned and 
  524     #	    MIN_VAL is zero, we'd like to do "MPIR_Assert(x >= MIN_VAL);".
  525     #       Note this option is not supported by gcc 4.2.  This needs to be added 
  526     #	    after most other warning flags, so that we catch a gcc bug on 32-bit 
  527     #	    that doesn't give a warning that this is unsupported, unless another
  528     #	    warning is triggered, and then if gives an error.
  529     # the embedded newlines in this string are safe because we evaluate each
  530     # argument in the for-loop below and append them to the CFLAGS with a space
  531     # as the separator instead
  532     pac_common_strict_flags="
  533         -Wall
  534         -Wextra
  535         -Wno-missing-field-initializers
  536         -Wstrict-prototypes
  537         -Wmissing-prototypes
  538         -DGCC_WALL
  539         -Wno-unused-parameter
  540         -Wno-unused-label
  541         -Wshadow
  542         -Wmissing-declarations
  543         -Wno-long-long
  544         -Wundef
  545         -Wno-endif-labels
  546         -Wpointer-arith
  547         -Wbad-function-cast
  548         -Wwrite-strings
  549         -Wno-sign-compare
  550         -Wold-style-definition
  551         -Wno-multichar
  552         -Wno-deprecated-declarations
  553         -Wnested-externs
  554         -Winvalid-pch
  555         -Wno-pointer-sign
  556         -Wvariadic-macros
  557         -Wno-format-zero-length
  558         -Wtype-limits
  559         -Werror-implicit-function-declaration
  560         -Wstack-usage=262144
  561     "
  562 
  563     enable_c89=no
  564     enable_c99=yes
  565     enable_posix=2001
  566     enable_opt=yes
  567     flags="`echo $1 | sed -e 's/:/ /g' -e 's/,/ /g'`"
  568     for flag in ${flags}; do
  569         case "$flag" in
  570 	     c89)
  571 		enable_strict_done="yes"
  572 		enable_c89=yes
  573                 enable_c99=no
  574 		;;
  575 	     c99)
  576 		enable_strict_done="yes"
  577                 enable_c89=no
  578 		enable_c99=yes
  579 		;;
  580 	     posix1995)
  581 		enable_strict_done="yes"
  582 		enable_posix=1995
  583 		;;
  584 	     posix|posix2001)
  585 		enable_strict_done="yes"
  586 		enable_posix=2001
  587 		;;
  588 	     posix2008)
  589 		enable_strict_done="yes"
  590 		enable_posix=2008
  591 		;;
  592 	     noposix)
  593 		enable_strict_done="yes"
  594 		enable_posix=no
  595 		;;
  596 	     opt)
  597 		enable_strict_done="yes"
  598 		enable_opt=yes
  599 		;;
  600 	     noopt)
  601 		enable_strict_done="yes"
  602 		enable_opt=no
  603 		;;
  604 	     all|yes)
  605 		enable_strict_done="yes"
  606 		enable_c99=yes
  607 		enable_posix=2001
  608 		enable_opt=yes
  609 	        ;;
  610 	     no)
  611 		# Accept and ignore this value
  612 		:
  613 		;;
  614 	     *)
  615 		if test -n "$flag" ; then
  616 		   AC_MSG_WARN([Unrecognized value for enable-strict:$flag])
  617 		fi
  618 		;;
  619 	esac
  620     done
  621 
  622     pac_cc_strict_flags=""
  623     if test "${enable_strict_done}" = "yes" ; then
  624        if test "${enable_opt}" = "yes" ; then
  625        	  pac_cc_strict_flags="-O2"
  626        fi
  627        pac_cc_strict_flags="$pac_cc_strict_flags $pac_common_strict_flags"
  628        # We only allow one of strict-C99 or strict-C89 to be
  629        # enabled. If C99 is enabled, we automatically disable C89.
  630        if test "${enable_c99}" = "yes" ; then
  631        	  PAC_APPEND_FLAG([-std=c99],[pac_cc_strict_flags])
  632           # Use -D_STDC_C99= for Solaris compilers. See
  633           # http://lists.gnu.org/archive/html/autoconf/2010-12/msg00059.html
  634           # for discussion on why not to use -xc99
  635           PAC_APPEND_FLAG([-D_STDC_C99=],[pac_cc_strict_flags])
  636        elif test "${enable_c89}" = "yes" ; then
  637        	  PAC_APPEND_FLAG([-std=c89],[pac_cc_strict_flags])
  638        	  PAC_APPEND_FLAG([-Wdeclaration-after-statement],[pac_cc_strict_flags])
  639        fi
  640        # POSIX 2001 should be used with C99. But the default standard for some
  641        # compilers are not C99. We must test the support of POSIX 2001 after
  642        # testing C99.
  643        case "$enable_posix" in
  644             no)   : ;;
  645             1995) PAC_APPEND_FLAG([-D_POSIX_C_SOURCE=199506L],[pac_cc_strict_flags]) ;;
  646             2001) PAC_APPEND_FLAG([-D_POSIX_C_SOURCE=200112L],[pac_cc_strict_flags]) ;;
  647             2008) PAC_APPEND_FLAG([-D_POSIX_C_SOURCE=200809L],[pac_cc_strict_flags]) ;;
  648             *)    AC_MSG_ERROR([internal error, unexpected POSIX version: '$enable_posix']) ;;
  649        esac
  650        if test "$enable_posix" != "no" ; then
  651            AS_CASE([$host],[*-*-darwin*], [PAC_APPEND_FLAG([-D_DARWIN_C_SOURCE],[pac_cc_strict_flags])])
  652        fi
  653     fi
  654 
  655     # See if the above options work with the compiler
  656     accepted_flags=""
  657     for flag in $pac_cc_strict_flags ; do
  658         PAC_PUSH_FLAG([CFLAGS])
  659 	CFLAGS="$CFLAGS $accepted_flags"
  660         PAC_C_CHECK_COMPILER_OPTION([$flag],[accepted_flags="$accepted_flags $flag"],)
  661         PAC_POP_FLAG([CFLAGS])
  662     done
  663     pac_cc_strict_flags=$accepted_flags
  664 fi
  665 ])
  666 
  667 dnl/*D
  668 dnl PAC_ARG_STRICT - Add --enable-strict to configure.  
  669 dnl
  670 dnl Synopsis:
  671 dnl PAC_ARG_STRICT
  672 dnl 
  673 dnl Output effects:
  674 dnl Adds '--enable-strict' to the command line.
  675 dnl
  676 dnl D*/
  677 AC_DEFUN([PAC_ARG_STRICT],[
  678 AC_ARG_ENABLE(strict,
  679 	AC_HELP_STRING([--enable-strict], [Turn on strict compilation testing]))
  680 PAC_CC_STRICT($enable_strict)
  681 CFLAGS="$CFLAGS $pac_cc_strict_flags"
  682 export CFLAGS
  683 ])
  684 
  685 dnl Return the integer structure alignment in pac_cv_c_max_integer_align
  686 dnl Possible values include
  687 dnl	packed
  688 dnl	two
  689 dnl	four
  690 dnl	eight
  691 dnl
  692 dnl In addition, a "Could not determine alignment" and a "error!"
  693 dnl return is possible.  
  694 AC_DEFUN([PAC_C_MAX_INTEGER_ALIGN],[
  695 AC_CACHE_CHECK([for max C struct integer alignment],
  696 pac_cv_c_max_integer_align,[
  697 AC_TRY_RUN([
  698 #include <stdio.h>
  699 #define DBG(a,b,c)
  700 int main( int argc, char *argv[] )
  701 {
  702     FILE *cf;
  703     int is_packed  = 1;
  704     int is_two     = 1;
  705     int is_four    = 1;
  706     int is_eight   = 1;
  707     struct { char a; int b; } char_int;
  708     struct { char a; short b; } char_short;
  709     struct { char a; long b; } char_long;
  710     struct { char a; int b; char c; } char_int_char;
  711     struct { char a; short b; char c; } char_short_char;
  712 #ifdef HAVE_LONG_LONG_INT
  713     struct { long long int a; char b; } lli_c;
  714     struct { char a; long long int b; } c_lli;
  715 #endif
  716     int size, extent, extent2;
  717 
  718     /* assume max integer alignment isn't 8 if we don't have
  719      * an eight-byte value :)
  720      */
  721 #ifdef HAVE_LONG_LONG_INT
  722     if (sizeof(int) < 8 && sizeof(long) < 8 && sizeof(long long int) < 8)
  723 	is_eight = 0;
  724 #else
  725     if (sizeof(int) < 8 && sizeof(long) < 8) is_eight = 0;
  726 #endif
  727 
  728     size = sizeof(char) + sizeof(int);
  729     extent = sizeof(char_int);
  730     if (size != extent) is_packed = 0;
  731     if ( (extent % 2) != 0) is_two = 0;
  732     if ( (extent % 4) != 0) is_four = 0;
  733     if (sizeof(int) == 8 && (extent % 8) != 0) is_eight = 0;
  734     DBG("char_int",size,extent);
  735 
  736     size = sizeof(char) + sizeof(short);
  737     extent = sizeof(char_short);
  738     if (size != extent) is_packed = 0;
  739     if ( (extent % 2) != 0) is_two = 0;
  740     if (sizeof(short) == 4 && (extent % 4) != 0) is_four = 0;
  741     if (sizeof(short) == 8 && (extent % 8) != 0) is_eight = 0;
  742     DBG("char_short",size,extent);
  743 
  744     size = sizeof(char) + sizeof(long);
  745     extent = sizeof(char_long);
  746     if (size != extent) is_packed = 0;
  747     if ( (extent % 2) != 0) is_two = 0;
  748     if ( (extent % 4) != 0) is_four = 0;
  749     if (sizeof(long) == 8 && (extent % 8) != 0) is_eight = 0;
  750     DBG("char_long",size,extent);
  751 
  752 #ifdef HAVE_LONG_LONG_INT
  753     size = sizeof(char) + sizeof(long long int);
  754     extent = sizeof(lli_c);
  755     extent2 = sizeof(c_lli);
  756     if (size != extent) is_packed = 0;
  757     if ( (extent % 2) != 0 && (extent2 % 2) != 0) is_two = 0;
  758     if ( (extent % 4) != 0 && (extent2 % 4) != 0) is_four = 0;
  759     if (sizeof(long long int) >= 8 && (extent % 8) != 0 && (extent2 % 8) != 0)
  760 	is_eight = 0;
  761 #endif
  762 
  763     size = sizeof(char) + sizeof(int) + sizeof(char);
  764     extent = sizeof(char_int_char);
  765     if (size != extent) is_packed = 0;
  766     if ( (extent % 2) != 0) is_two = 0;
  767     if ( (extent % 4) != 0) is_four = 0;
  768     if (sizeof(int) == 8 && (extent % 8) != 0) is_eight = 0;
  769     DBG("char_int_char",size,extent);
  770 
  771     size = sizeof(char) + sizeof(short) + sizeof(char);
  772     extent = sizeof(char_short_char);
  773     if (size != extent) is_packed = 0;
  774     if ( (extent % 2) != 0) is_two = 0;
  775     if (sizeof(short) == 4 && (extent % 4) != 0) is_four = 0;
  776     if (sizeof(short) == 8 && (extent % 8) != 0) is_eight = 0;
  777     DBG("char_short_char",size,extent);
  778 
  779     /* If aligned mod 8, it will be aligned mod 4 */
  780     if (is_eight) { is_four = 0; is_two = 0; }
  781 
  782     if (is_four) is_two = 0;
  783 
  784     /* Tabulate the results */
  785     cf = fopen( "ctest.out", "w" );
  786     if (is_packed + is_two + is_four + is_eight == 0) {
  787 	fprintf( cf, "Could not determine alignment\n" );
  788     }
  789     else {
  790 	if (is_packed + is_two + is_four + is_eight != 1) {
  791 	    fprintf( cf, "error!\n" );
  792 	}
  793 	else {
  794 	    if (is_packed) fprintf( cf, "packed\n" );
  795 	    if (is_two) fprintf( cf, "two\n" );
  796 	    if (is_four) fprintf( cf, "four\n" );
  797 	    if (is_eight) fprintf( cf, "eight\n" );
  798 	}
  799     }
  800     fclose( cf );
  801     return 0;
  802 }],
  803 pac_cv_c_max_integer_align=`cat ctest.out`,
  804 pac_cv_c_max_integer_align="unknown",
  805 pac_cv_c_max_integer_align="$CROSS_ALIGN_STRUCT_INT")
  806 rm -f ctest.out
  807 ])
  808 if test -z "$pac_cv_c_max_integer_align" ; then
  809     pac_cv_c_max_integer_align="unknown"
  810 fi
  811 ])
  812 
  813 dnl Return the floating point structure alignment in
  814 dnl pac_cv_c_max_fp_align.
  815 dnl
  816 dnl Possible values include:
  817 dnl	packed
  818 dnl	two
  819 dnl	four
  820 dnl	eight
  821 dnl     sixteen
  822 dnl
  823 dnl In addition, a "Could not determine alignment" and a "error!"
  824 dnl return is possible.  
  825 AC_DEFUN([PAC_C_MAX_FP_ALIGN],[
  826 AC_CACHE_CHECK([for max C struct floating point alignment],
  827 pac_cv_c_max_fp_align,[
  828 AC_TRY_RUN([
  829 #include <stdio.h>
  830 #define DBG(a,b,c)
  831 int main( int argc, char *argv[] )
  832 {
  833     FILE *cf;
  834     int is_packed  = 1;
  835     int is_two     = 1;
  836     int is_four    = 1;
  837     int is_eight   = 1;
  838     int is_sixteen = 1;
  839     struct { char a; float b; } char_float;
  840     struct { float b; char a; } float_char;
  841     struct { char a; double b; } char_double;
  842     struct { double b; char a; } double_char;
  843 #ifdef HAVE_LONG_DOUBLE
  844     struct { char a; long double b; } char_long_double;
  845     struct { long double b; char a; } long_double_char;
  846     struct { long double a; int b; char c; } long_double_int_char;
  847 #endif
  848     int size, extent1, extent2;
  849 
  850     size = sizeof(char) + sizeof(float);
  851     extent1 = sizeof(char_float);
  852     extent2 = sizeof(float_char);
  853     if (size != extent1) is_packed = 0;
  854     if ( (extent1 % 2) != 0 && (extent2 % 2) != 0) is_two = 0;
  855     if ( (extent1 % 4) != 0 && (extent2 % 4) != 0) is_four = 0;
  856     if (sizeof(float) == 8 && (extent1 % 8) != 0 && (extent2 % 8) != 0)
  857 	is_eight = 0;
  858     DBG("char_float",size,extent1);
  859 
  860     size = sizeof(char) + sizeof(double);
  861     extent1 = sizeof(char_double);
  862     extent2 = sizeof(double_char);
  863     if (size != extent1) is_packed = 0;
  864     if ( (extent1 % 2) != 0 && (extent2 % 2) != 0) is_two = 0;
  865     if ( (extent1 % 4) != 0 && (extent2 % 4) != 0) is_four = 0;
  866     if (sizeof(double) == 8 && (extent1 % 8) != 0 && (extent2 % 8) != 0)
  867 	is_eight = 0;
  868     DBG("char_double",size,extent1);
  869 
  870 #ifdef HAVE_LONG_DOUBLE
  871     size = sizeof(char) + sizeof(long double);
  872     extent1 = sizeof(char_long_double);
  873     extent2 = sizeof(long_double_char);
  874     if (size != extent1) is_packed = 0;
  875     if ( (extent1 % 2) != 0 && (extent2 % 2) != 0) is_two = 0;
  876     if ( (extent1 % 4) != 0 && (extent2 % 4) != 0) is_four = 0;
  877     if (sizeof(long double) >= 8 && (extent1 % 8) != 0 && (extent2 % 8) != 0)
  878 	is_eight = 0;
  879     if (sizeof(long double) > 8 && (extent1 % 16) != 0
  880 	&& (extent2 % 16) != 0) is_sixteen = 0;
  881     DBG("char_long-double",size,extent1);
  882 
  883     extent1 = sizeof(long_double_int_char);
  884     if ( (extent1 % 2) != 0) is_two = 0;
  885     if ( (extent1 % 4) != 0) is_four = 0;
  886     if (sizeof(long double) >= 8 && (extent1 % 8) != 0)	is_eight = 0;
  887     if (sizeof(long double) > 8 && (extent1 % 16) != 0) is_sixteen = 0;
  888 #else
  889     is_sixteen = 0;
  890 #endif
  891 
  892     if (is_sixteen) { is_eight = 0; is_four = 0; is_two = 0; }
  893 
  894     if (is_eight) { is_four = 0; is_two = 0; }
  895 
  896     if (is_four) is_two = 0;
  897 
  898     /* Tabulate the results */
  899     cf = fopen( "ctest.out", "w" );
  900     if (is_packed + is_two + is_four + is_eight + is_sixteen == 0) {
  901 	fprintf( cf, "Could not determine alignment\n" );
  902     }
  903     else {
  904 	if (is_packed + is_two + is_four + is_eight + is_sixteen != 1) {
  905 	    fprintf( cf, "error!\n" );
  906 	}
  907 	else {
  908 	    if (is_packed) fprintf( cf, "packed\n" );
  909 	    if (is_two) fprintf( cf, "two\n" );
  910 	    if (is_four) fprintf( cf, "four\n" );
  911 	    if (is_eight) fprintf( cf, "eight\n" );
  912 	    if (is_sixteen) fprintf( cf, "sixteen\n" );
  913 	}
  914     }
  915     fclose( cf );
  916     return 0;
  917 }],
  918 pac_cv_c_max_fp_align=`cat ctest.out`,
  919 pac_cv_c_max_fp_align="unknown",
  920 pac_cv_c_max_fp_align="$CROSS_ALIGN_STRUCT_FP")
  921 rm -f ctest.out
  922 ])
  923 if test -z "$pac_cv_c_max_fp_align" ; then
  924     pac_cv_c_max_fp_align="unknown"
  925 fi
  926 ])
  927 
  928 dnl Return the floating point structure alignment in
  929 dnl pac_cv_c_max_double_fp_align.
  930 dnl
  931 dnl Possible values include:
  932 dnl	packed
  933 dnl	two
  934 dnl	four
  935 dnl	eight
  936 dnl
  937 dnl In addition, a "Could not determine alignment" and a "error!"
  938 dnl return is possible.  
  939 AC_DEFUN([PAC_C_MAX_DOUBLE_FP_ALIGN],[
  940 AC_CACHE_CHECK([for max C struct alignment of structs with doubles],
  941 pac_cv_c_max_double_fp_align,[
  942 AC_TRY_RUN([
  943 #include <stdio.h>
  944 #define DBG(a,b,c)
  945 int main( int argc, char *argv[] )
  946 {
  947     FILE *cf;
  948     int is_packed  = 1;
  949     int is_two     = 1;
  950     int is_four    = 1;
  951     int is_eight   = 1;
  952     struct { char a; float b; } char_float;
  953     struct { float b; char a; } float_char;
  954     struct { char a; double b; } char_double;
  955     struct { double b; char a; } double_char;
  956     int size, extent1, extent2;
  957 
  958     size = sizeof(char) + sizeof(float);
  959     extent1 = sizeof(char_float);
  960     extent2 = sizeof(float_char);
  961     if (size != extent1) is_packed = 0;
  962     if ( (extent1 % 2) != 0 && (extent2 % 2) != 0) is_two = 0;
  963     if ( (extent1 % 4) != 0 && (extent2 % 4) != 0) is_four = 0;
  964     if (sizeof(float) == 8 && (extent1 % 8) != 0 && (extent2 % 8) != 0)
  965 	is_eight = 0;
  966     DBG("char_float",size,extent1);
  967 
  968     size = sizeof(char) + sizeof(double);
  969     extent1 = sizeof(char_double);
  970     extent2 = sizeof(double_char);
  971     if (size != extent1) is_packed = 0;
  972     if ( (extent1 % 2) != 0 && (extent2 % 2) != 0) is_two = 0;
  973     if ( (extent1 % 4) != 0 && (extent2 % 4) != 0) is_four = 0;
  974     if (sizeof(double) == 8 && (extent1 % 8) != 0 && (extent2 % 8) != 0)
  975 	is_eight = 0;
  976     DBG("char_double",size,extent1);
  977 
  978     if (is_eight) { is_four = 0; is_two = 0; }
  979 
  980     if (is_four) is_two = 0;
  981 
  982     /* Tabulate the results */
  983     cf = fopen( "ctest.out", "w" );
  984     if (is_packed + is_two + is_four + is_eight == 0) {
  985 	fprintf( cf, "Could not determine alignment\n" );
  986     }
  987     else {
  988 	if (is_packed + is_two + is_four + is_eight != 1) {
  989 	    fprintf( cf, "error!\n" );
  990 	}
  991 	else {
  992 	    if (is_packed) fprintf( cf, "packed\n" );
  993 	    if (is_two) fprintf( cf, "two\n" );
  994 	    if (is_four) fprintf( cf, "four\n" );
  995 	    if (is_eight) fprintf( cf, "eight\n" );
  996 	}
  997     }
  998     fclose( cf );
  999     return 0;
 1000 }],
 1001 pac_cv_c_max_double_fp_align=`cat ctest.out`,
 1002 pac_cv_c_max_double_fp_align="unknown",
 1003 pac_cv_c_max_double_fp_align="$CROSS_ALIGN_STRUCT_DOUBLE_FP")
 1004 rm -f ctest.out
 1005 ])
 1006 if test -z "$pac_cv_c_max_double_fp_align" ; then
 1007     pac_cv_c_max_double_fp_align="unknown"
 1008 fi
 1009 ])
 1010 AC_DEFUN([PAC_C_MAX_LONGDOUBLE_FP_ALIGN],[
 1011 AC_CACHE_CHECK([for max C struct floating point alignment with long doubles],
 1012 pac_cv_c_max_longdouble_fp_align,[
 1013 AC_TRY_RUN([
 1014 #include <stdio.h>
 1015 #define DBG(a,b,c)
 1016 int main( int argc, char *argv[] )
 1017 {
 1018     FILE *cf;
 1019     int is_packed  = 1;
 1020     int is_two     = 1;
 1021     int is_four    = 1;
 1022     int is_eight   = 1;
 1023     int is_sixteen = 1;
 1024     struct { char a; long double b; } char_long_double;
 1025     struct { long double b; char a; } long_double_char;
 1026     struct { long double a; int b; char c; } long_double_int_char;
 1027     int size, extent1, extent2;
 1028 
 1029     size = sizeof(char) + sizeof(long double);
 1030     extent1 = sizeof(char_long_double);
 1031     extent2 = sizeof(long_double_char);
 1032     if (size != extent1) is_packed = 0;
 1033     if ( (extent1 % 2) != 0 && (extent2 % 2) != 0) is_two = 0;
 1034     if ( (extent1 % 4) != 0 && (extent2 % 4) != 0) is_four = 0;
 1035     if (sizeof(long double) >= 8 && (extent1 % 8) != 0 && (extent2 % 8) != 0)
 1036 	is_eight = 0;
 1037     if (sizeof(long double) > 8 && (extent1 % 16) != 0
 1038 	&& (extent2 % 16) != 0) is_sixteen = 0;
 1039     DBG("char_long-double",size,extent1);
 1040 
 1041     extent1 = sizeof(long_double_int_char);
 1042     if ( (extent1 % 2) != 0) is_two = 0;
 1043     if ( (extent1 % 4) != 0) is_four = 0;
 1044     if (sizeof(long double) >= 8 && (extent1 % 8) != 0)	is_eight = 0;
 1045     if (sizeof(long double) > 8 && (extent1 % 16) != 0) is_sixteen = 0;
 1046 
 1047     if (is_sixteen) { is_eight = 0; is_four = 0; is_two = 0; }
 1048 
 1049     if (is_eight) { is_four = 0; is_two = 0; }
 1050 
 1051     if (is_four) is_two = 0;
 1052 
 1053     /* Tabulate the results */
 1054     cf = fopen( "ctest.out", "w" );
 1055     if (is_packed + is_two + is_four + is_eight + is_sixteen == 0) {
 1056 	fprintf( cf, "Could not determine alignment\n" );
 1057     }
 1058     else {
 1059 	if (is_packed + is_two + is_four + is_eight + is_sixteen != 1) {
 1060 	    fprintf( cf, "error!\n" );
 1061 	}
 1062 	else {
 1063 	    if (is_packed) fprintf( cf, "packed\n" );
 1064 	    if (is_two) fprintf( cf, "two\n" );
 1065 	    if (is_four) fprintf( cf, "four\n" );
 1066 	    if (is_eight) fprintf( cf, "eight\n" );
 1067 	    if (is_sixteen) fprintf( cf, "sixteen\n" );
 1068 	}
 1069     }
 1070     fclose( cf );
 1071     return 0;
 1072 }],
 1073 pac_cv_c_max_longdouble_fp_align=`cat ctest.out`,
 1074 pac_cv_c_max_longdouble_fp_align="unknown",
 1075 pac_cv_c_max_longdouble_fp_align="$CROSS_ALIGN_STRUCT_LONGDOUBLE_FP")
 1076 rm -f ctest.out
 1077 ])
 1078 if test -z "$pac_cv_c_max_longdouble_fp_align" ; then
 1079     pac_cv_c_max_longdouble_fp_align="unknown"
 1080 fi
 1081 ])
 1082 
 1083 dnl Other tests assume that there is potentially a maximum alignment
 1084 dnl and that if there is no maximum alignment, or a type is smaller than
 1085 dnl that value, then we align on the size of the value, with the exception
 1086 dnl of the "position-based alignment" rules we test for separately.
 1087 dnl
 1088 dnl It turns out that these assumptions have fallen short in at least one
 1089 dnl case, on MacBook Pros, where doubles are aligned on 4-byte boundaries
 1090 dnl even when long doubles are aligned on 16-byte boundaries. So this test
 1091 dnl is here specifically to handle this case.
 1092 dnl
 1093 dnl Puts result in pac_cv_c_double_alignment_exception.
 1094 dnl
 1095 dnl Possible values currently include no and four.
 1096 dnl
 1097 AC_DEFUN([PAC_C_DOUBLE_ALIGNMENT_EXCEPTION],[
 1098 AC_CACHE_CHECK([if double alignment breaks rules, find actual alignment],
 1099 pac_cv_c_double_alignment_exception,[
 1100 AC_TRY_RUN([
 1101 #include <stdio.h>
 1102 #define DBG(a,b,c)
 1103 int main( int argc, char *argv[] )
 1104 {
 1105     FILE *cf;
 1106     struct { char a; double b; } char_double;
 1107     struct { double b; char a; } double_char;
 1108     int extent1, extent2, align_4 = 0;
 1109 
 1110     extent1 = sizeof(char_double);
 1111     extent2 = sizeof(double_char);
 1112 
 1113     /* we're interested in the largest value, will let separate test
 1114      * deal with position-based issues.
 1115      */
 1116     if (extent1 < extent2) extent1 = extent2;
 1117     if ((sizeof(double) == 8) && (extent1 % 8) != 0) {
 1118        if (extent1 % 4 == 0) {
 1119 #ifdef HAVE_MAX_FP_ALIGNMENT
 1120           if (HAVE_MAX_FP_ALIGNMENT >= 8) align_4 = 1;
 1121 #else
 1122           align_4 = 1;
 1123 #endif
 1124        }
 1125     }
 1126 
 1127     cf = fopen( "ctest.out", "w" );
 1128 
 1129     if (align_4) fprintf( cf, "four\n" );
 1130     else fprintf( cf, "no\n" );
 1131 
 1132     fclose( cf );
 1133     return 0;
 1134 }],
 1135 pac_cv_c_double_alignment_exception=`cat ctest.out`,
 1136 pac_cv_c_double_alignment_exception="unknown",
 1137 pac_cv_c_double_alignment_exception="$CROSS_ALIGN_DOUBLE_EXCEPTION")
 1138 rm -f ctest.out
 1139 ])
 1140 if test -z "$pac_cv_c_double_alignment_exception" ; then
 1141     pac_cv_c_double_alignment_exception="unknown"
 1142 fi
 1143 ])
 1144 
 1145 dnl Test for odd struct alignment rule that only applies max.
 1146 dnl padding when double value is at front of type.
 1147 dnl Puts result in pac_cv_c_double_pos_align.
 1148 dnl
 1149 dnl Search for "Power alignment mode" for more details.
 1150 dnl
 1151 dnl Possible values include yes, no, and unknown.
 1152 dnl
 1153 AC_DEFUN([PAC_C_DOUBLE_POS_ALIGN],[
 1154 AC_CACHE_CHECK([if alignment of structs with doubles is based on position],
 1155 pac_cv_c_double_pos_align,[
 1156 AC_TRY_RUN([
 1157 #include <stdio.h>
 1158 #define DBG(a,b,c)
 1159 int main( int argc, char *argv[] )
 1160 {
 1161     FILE *cf;
 1162     int padding_varies_by_pos = 0;
 1163     struct { char a; double b; } char_double;
 1164     struct { double b; char a; } double_char;
 1165     int extent1, extent2;
 1166 
 1167     extent1 = sizeof(char_double);
 1168     extent2 = sizeof(double_char);
 1169     if (extent1 != extent2) padding_varies_by_pos = 1;
 1170 
 1171     cf = fopen( "ctest.out", "w" );
 1172     if (padding_varies_by_pos) fprintf( cf, "yes\n" );
 1173     else fprintf( cf, "no\n" );
 1174 
 1175     fclose( cf );
 1176     return 0;
 1177 }],
 1178 pac_cv_c_double_pos_align=`cat ctest.out`,
 1179 pac_cv_c_double_pos_align="unknown",
 1180 pac_cv_c_double_pos_align="$CROSS_ALIGN_DOUBLE_POS")
 1181 rm -f ctest.out
 1182 ])
 1183 if test -z "$pac_cv_c_double_pos_align" ; then
 1184     pac_cv_c_double_pos_align="unknown"
 1185 fi
 1186 ])
 1187 
 1188 dnl Test for odd struct alignment rule that only applies max.
 1189 dnl padding when long long int value is at front of type.
 1190 dnl Puts result in pac_cv_c_llint_pos_align.
 1191 dnl
 1192 dnl Search for "Power alignment mode" for more details.
 1193 dnl
 1194 dnl Possible values include yes, no, and unknown.
 1195 dnl
 1196 AC_DEFUN([PAC_C_LLINT_POS_ALIGN],[
 1197 AC_CACHE_CHECK([if alignment of structs with long long ints is based on position],
 1198 pac_cv_c_llint_pos_align,[
 1199 AC_TRY_RUN([
 1200 #include <stdio.h>
 1201 #define DBG(a,b,c)
 1202 int main( int argc, char *argv[] )
 1203 {
 1204     FILE *cf;
 1205     int padding_varies_by_pos = 0;
 1206 #ifdef HAVE_LONG_LONG_INT
 1207     struct { char a; long long int b; } char_llint;
 1208     struct { long long int b; char a; } llint_char;
 1209     int extent1, extent2;
 1210 
 1211     extent1 = sizeof(char_llint);
 1212     extent2 = sizeof(llint_char);
 1213     if (extent1 != extent2) padding_varies_by_pos = 1;
 1214 #endif
 1215 
 1216     cf = fopen( "ctest.out", "w" );
 1217     if (padding_varies_by_pos) fprintf( cf, "yes\n" );
 1218     else fprintf( cf, "no\n" );
 1219 
 1220     fclose( cf );
 1221     return 0;
 1222 }],
 1223 pac_cv_c_llint_pos_align=`cat ctest.out`,
 1224 pac_cv_c_llint_pos_align="unknown",
 1225 pac_cv_c_llint_pos_align="$CROSS_ALIGN_LLINT_POS")
 1226 rm -f ctest.out
 1227 ])
 1228 if test -z "$pac_cv_c_llint_pos_align" ; then
 1229     pac_cv_c_llint_pos_align="unknown"
 1230 fi
 1231 ])
 1232 
 1233 dnl/*D
 1234 dnl PAC_FUNC_NEEDS_DECL - Set NEEDS_<funcname>_DECL if a declaration is needed
 1235 dnl
 1236 dnl Synopsis:
 1237 dnl PAC_FUNC_NEEDS_DECL(headerfiles,funcname)
 1238 dnl
 1239 dnl Output Effect:
 1240 dnl Sets 'NEEDS_<funcname>_DECL' if 'funcname' is not declared by the 
 1241 dnl headerfiles.
 1242 dnl
 1243 dnl Approach:
 1244 dnl Attempt to assign library function to function pointer.  If the function
 1245 dnl is not declared in a header, this will fail.  Use a non-static global so
 1246 dnl the compiler does not warn about an unused variable.
 1247 dnl
 1248 dnl Simply calling the function is not enough because C89 compilers allow
 1249 dnl calls to implicitly-defined functions.  Re-declaring a library function
 1250 dnl with an incompatible prototype is also not sufficient because some
 1251 dnl compilers (notably clang-3.2) only produce a warning in this case.
 1252 dnl
 1253 dnl D*/
 1254 AC_DEFUN([PAC_FUNC_NEEDS_DECL],[
 1255 AC_CACHE_CHECK([whether $2 needs a declaration],
 1256 pac_cv_func_decl_$2,[
 1257 AC_TRY_COMPILE([$1
 1258 void (*fptr)(void) = (void(*)(void))$2;],[],
 1259 pac_cv_func_decl_$2=no,pac_cv_func_decl_$2=yes)])
 1260 if test "$pac_cv_func_decl_$2" = "yes" ; then
 1261 changequote(<<,>>)dnl
 1262 define(<<PAC_FUNC_NAME>>, translit(NEEDS_$2_DECL, [a-z *], [A-Z__]))dnl
 1263 changequote([, ])dnl
 1264     AC_DEFINE_UNQUOTED(PAC_FUNC_NAME,1,[Define if $2 needs a declaration])
 1265 undefine([PAC_FUNC_NAME])
 1266 fi
 1267 ])
 1268 
 1269 dnl PAC_C_GNU_ATTRIBUTE - See if the GCC __attribute__ specifier is allow.
 1270 dnl Use the following
 1271 dnl #ifndef HAVE_GCC_ATTRIBUTE
 1272 dnl #define __attribute__(a)
 1273 dnl #endif
 1274 dnl If *not*, define __attribute__(a) as null
 1275 dnl
 1276 dnl We start by requiring Gcc.  Some other compilers accept __attribute__
 1277 dnl but generate warning messages, or have different interpretations 
 1278 dnl (which seems to make __attribute__ just as bad as #pragma) 
 1279 dnl For example, the Intel icc compiler accepts __attribute__ and
 1280 dnl __attribute__((pure)) but generates warnings for __attribute__((format...))
 1281 dnl
 1282 AC_DEFUN([PAC_C_GNU_ATTRIBUTE],[
 1283 AC_REQUIRE([AC_PROG_CC_GNU])
 1284 if test "$ac_cv_prog_gcc" = "yes" ; then
 1285     AC_CACHE_CHECK([whether __attribute__ allowed],
 1286 pac_cv_gnu_attr_pure,[
 1287 AC_TRY_COMPILE([int foo(int) __attribute__ ((pure));],[int a;],
 1288 pac_cv_gnu_attr_pure=yes,pac_cv_gnu_attr_pure=no)])
 1289 AC_CACHE_CHECK([whether __attribute__((format)) allowed],
 1290 pac_cv_gnu_attr_format,[
 1291 AC_TRY_COMPILE([int foo(char *,...) __attribute__ ((format(printf,1,2)));],[int a;],
 1292 pac_cv_gnu_attr_format=yes,pac_cv_gnu_attr_format=no)])
 1293     if test "$pac_cv_gnu_attr_pure" = "yes" -a "$pac_cv_gnu_attr_format" = "yes" ; then
 1294         AC_DEFINE(HAVE_GCC_ATTRIBUTE,1,[Define if GNU __attribute__ is supported])
 1295     fi
 1296 fi
 1297 ])
 1298 dnl
 1299 dnl Check for a broken install (fails to preserve file modification times,
 1300 dnl thus breaking libraries.
 1301 dnl
 1302 dnl Create a library, install it, and then try to link against it.
 1303 AC_DEFUN([PAC_PROG_INSTALL_BREAKS_LIBS],[
 1304 AC_CACHE_CHECK([whether install breaks libraries],
 1305 ac_cv_prog_install_breaks_libs,[
 1306 AC_REQUIRE([AC_PROG_RANLIB])
 1307 AC_REQUIRE([AC_PROG_INSTALL])
 1308 AC_REQUIRE([AC_PROG_CC])
 1309 ac_cv_prog_install_breaks_libs=yes
 1310 
 1311 AC_COMPILE_IFELSE([
 1312     AC_LANG_SOURCE([ int foo(int); int foo(int a){return a;} ])
 1313 ],[
 1314     if ${AR-ar} ${AR_FLAGS-cr} libconftest.a conftest.$OBJEXT >/dev/null 2>&1 ; then
 1315         if ${RANLIB-:} libconftest.a >/dev/null 2>&1 ; then
 1316             # Anything less than sleep 10, and Mac OS/X (Darwin) 
 1317             # will claim that install works because ranlib won't complain
 1318             sleep 10
 1319             libinstall="$INSTALL_DATA"
 1320             eval "libinstall=\"$libinstall\""
 1321             if ${libinstall} libconftest.a libconftest1.a >/dev/null 2>&1 ; then
 1322                 saved_LIBS="$LIBS"
 1323                 LIBS="libconftest1.a"
 1324                 AC_LINK_IFELSE([
 1325                     AC_LANG_SOURCE([
 1326 extern int foo(int);
 1327 int main(int argc, char **argv){ return foo(0); }
 1328                     ])
 1329                 ],[
 1330                     # Success!  Install works
 1331                     ac_cv_prog_install_breaks_libs=no
 1332                 ],[
 1333                     # Failure!  Does install -p work?        
 1334                     rm -f libconftest1.a
 1335                     if ${libinstall} -p libconftest.a libconftest1.a >/dev/null 2>&1 ; then
 1336                         AC_LINK_IFELSE([],[
 1337                             # Success!  Install works
 1338                             ac_cv_prog_install_breaks_libs="no, with -p"
 1339                         ])
 1340                     fi
 1341                 ])
 1342                 LIBS="$saved_LIBS"
 1343             fi
 1344         fi
 1345     fi
 1346 ])
 1347 rm -f libconftest*.a
 1348 ]) dnl Endof ac_cache_check
 1349 
 1350 if test -z "$RANLIB_AFTER_INSTALL" ; then
 1351     RANLIB_AFTER_INSTALL=no
 1352 fi
 1353 case "$ac_cv_prog_install_breaks_libs" in
 1354     yes)
 1355         RANLIB_AFTER_INSTALL=yes
 1356     ;;
 1357     "no, with -p")
 1358         INSTALL_DATA="$INSTALL_DATA -p"
 1359     ;;
 1360     *)
 1361     # Do nothing
 1362     :
 1363     ;;
 1364 esac
 1365 AC_SUBST(RANLIB_AFTER_INSTALL)
 1366 ])
 1367 
 1368 #
 1369 # determine if the compiler defines a symbol containing the function name
 1370 #
 1371 # These tests check not only that the compiler defines some symbol, such
 1372 # as __FUNCTION__, but that the symbol correctly names the function.
 1373 #
 1374 # Defines 
 1375 #   HAVE__FUNC__      (if __func__ defined)
 1376 #   HAVE_CAP__FUNC__  (if __FUNC__ defined)
 1377 #   HAVE__FUNCTION__  (if __FUNCTION__ defined)
 1378 #
 1379 AC_DEFUN([PAC_CC_FUNCTION_NAME_SYMBOL],[
 1380 AC_CACHE_CHECK([whether the compiler defines __func__],
 1381 pac_cv_have__func__,[
 1382 tmp_am_cross=no
 1383 AC_RUN_IFELSE([
 1384 AC_LANG_SOURCE([
 1385 #include <string.h>
 1386 int foo(void);
 1387 int foo(void)
 1388 {
 1389     return (strcmp(__func__, "foo") == 0);
 1390 }
 1391 int main(int argc, char ** argv)
 1392 {
 1393     return (foo() ? 0 : 1);
 1394 }
 1395 ])
 1396 ], pac_cv_have__func__=yes, pac_cv_have__func__=no,tmp_am_cross=yes)
 1397 if test "$tmp_am_cross" = yes ; then
 1398     AC_LINK_IFELSE([
 1399     AC_LANG_SOURCE([
 1400 #include <string.h>
 1401 int foo(void);
 1402 int foo(void)
 1403 {
 1404     return (strcmp(__func__, "foo") == 0);
 1405 }
 1406 int main(int argc, char ** argv)
 1407 {
 1408     return (foo() ? 0 : 1);
 1409 }
 1410     ])
 1411 ], pac_cv_have__func__=yes, pac_cv_have__func__=no)
 1412 fi
 1413 ])
 1414 
 1415 if test "$pac_cv_have__func__" = "yes" ; then
 1416     AC_DEFINE(HAVE__FUNC__,,[define if the compiler defines __func__])
 1417 fi
 1418 
 1419 AC_CACHE_CHECK([whether the compiler defines __FUNC__],
 1420 pac_cv_have_cap__func__,[
 1421 tmp_am_cross=no
 1422 AC_RUN_IFELSE([
 1423 AC_LANG_SOURCE([
 1424 #include <string.h>
 1425 int foo(void);
 1426 int foo(void)
 1427 {
 1428     return (strcmp(__FUNC__, "foo") == 0);
 1429 }
 1430 int main(int argc, char ** argv)
 1431 {
 1432     return (foo() ? 0 : 1);
 1433 }
 1434 ])
 1435 ], pac_cv_have_cap__func__=yes, pac_cv_have_cap__func__=no,tmp_am_cross=yes)
 1436 if test "$tmp_am_cross" = yes ; then
 1437     AC_LINK_IFELSE([
 1438     AC_LANG_SOURCE([
 1439 #include <string.h>
 1440 int foo(void);
 1441 int foo(void)
 1442 {
 1443     return (strcmp(__FUNC__, "foo") == 0);
 1444 }
 1445 int main(int argc, char ** argv)
 1446 {
 1447     return (foo() ? 0 : 1);
 1448 }
 1449     ])
 1450 ], pac_cv_have__func__=yes, pac_cv_have__func__=no)
 1451 fi
 1452 ])
 1453 
 1454 if test "$pac_cv_have_cap__func__" = "yes" ; then
 1455     AC_DEFINE(HAVE_CAP__FUNC__,,[define if the compiler defines __FUNC__])
 1456 fi
 1457 
 1458 AC_CACHE_CHECK([whether the compiler sets __FUNCTION__],
 1459 pac_cv_have__function__,[
 1460 tmp_am_cross=no
 1461 AC_RUN_IFELSE([
 1462 AC_LANG_SOURCE([
 1463 #include <string.h>
 1464 int foo(void);
 1465 int foo(void)
 1466 {
 1467     return (strcmp(__FUNCTION__, "foo") == 0);
 1468 }
 1469 int main(int argc, char ** argv)
 1470 {
 1471     return (foo() ? 0 : 1);
 1472 }
 1473 ])
 1474 ], pac_cv_have__function__=yes, pac_cv_have__function__=no,tmp_am_cross=yes)
 1475 if test "$tmp_am_cross" = yes ; then
 1476     AC_LINK_IFELSE([
 1477     AC_LANG_SOURCE([
 1478 #include <string.h>
 1479 int foo(void);
 1480 int foo(void)
 1481 {
 1482     return (strcmp(__FUNCTION__, "foo") == 0);
 1483 }
 1484 int main(int argc, char ** argv)
 1485 {
 1486     return (foo() ? 0 : 1);
 1487 }
 1488     ])
 1489 ], pac_cv_have__func__=yes, pac_cv_have__func__=no)
 1490 fi
 1491 ])
 1492 
 1493 if test "$pac_cv_have__function__" = "yes" ; then
 1494     AC_DEFINE(HAVE__FUNCTION__,,[define if the compiler defines __FUNCTION__])
 1495 fi
 1496 
 1497 ])
 1498 
 1499 
 1500 dnl Check structure alignment
 1501 AC_DEFUN([PAC_STRUCT_ALIGNMENT],[
 1502 	# Initialize alignment checks
 1503 	is_packed=1
 1504 	is_two=1
 1505 	is_four=1
 1506 	is_eight=1
 1507 	is_largest=1
 1508 
 1509 	# See if long double exists
 1510 	AC_TRY_COMPILE(,[long double a;],have_long_double=yes,have_long_double=no)
 1511 
 1512 	# Get sizes of regular types
 1513 	AC_CHECK_SIZEOF(char)
 1514 	AC_CHECK_SIZEOF(int)
 1515 	AC_CHECK_SIZEOF(short)
 1516 	AC_CHECK_SIZEOF(long)
 1517 	AC_CHECK_SIZEOF(float)
 1518 	AC_CHECK_SIZEOF(double)
 1519 	AC_CHECK_SIZEOF(long double)
 1520 
 1521 	# char_int comparison
 1522 	AC_CHECK_SIZEOF(char_int, 0, [typedef struct { char a; int b; } char_int; ])
 1523 	size=`expr $ac_cv_sizeof_char + $ac_cv_sizeof_int`
 1524 	extent=$ac_cv_sizeof_char_int
 1525 	if test "$size" != "$extent" ; then is_packed=0 ; fi
 1526 	if test "`expr $extent % $ac_cv_sizeof_int`" != "0" ; then is_largest=0 ; fi
 1527 	if test "`expr $extent % 2`" != "0" ; then is_two=0 ; fi
 1528 	if test "`expr $extent % 4`" != "0" ; then is_four=0 ; fi
 1529 	if test "$ac_cv_sizeof_int" = "8" -a "`expr $extent % 8`" != "0" ; then
 1530 	   is_eight=0
 1531 	fi
 1532 
 1533 	# char_short comparison
 1534 	AC_CHECK_SIZEOF(char_short, 0, [typedef struct { char a; short b; } char_short; ])
 1535 	size=`expr $ac_cv_sizeof_char + $ac_cv_sizeof_short`
 1536 	extent=$ac_cv_sizeof_char_short
 1537 	if test "$size" != "$extent" ; then is_packed=0 ; fi
 1538 	if test "`expr $extent % $ac_cv_sizeof_short`" != "0" ; then is_largest=0 ; fi
 1539 	if test "`expr $extent % 2`" != "0" ; then is_two=0 ; fi
 1540 	if test "$ac_cv_sizeof_short" = "4" -a "`expr $extent % 4`" != "0" ; then
 1541 	   is_four=0
 1542 	fi
 1543 	if test "$ac_cv_sizeof_short" = "8" -a "`expr $extent % 8`" != "0" ; then
 1544 	   is_eight=0
 1545 	fi
 1546 
 1547 	# char_long comparison
 1548 	AC_CHECK_SIZEOF(char_long, 0, [typedef struct { char a; long b; } char_long; ])
 1549 	size=`expr $ac_cv_sizeof_char + $ac_cv_sizeof_long`
 1550 	extent=$ac_cv_sizeof_char_long
 1551 	if test "$size" != "$extent" ; then is_packed=0 ; fi
 1552 	if test "`expr $extent % $ac_cv_sizeof_long`" != "0" ; then is_largest=0 ; fi
 1553 	if test "`expr $extent % 2`" != "0" ; then is_two=0 ; fi
 1554 	if test "`expr $extent % 4`" != "0" ; then is_four=0 ; fi
 1555 	if test "$ac_cv_sizeof_long" = "8" -a "`expr $extent % 8`" != "0" ; then
 1556 	   is_eight=0
 1557 	fi
 1558 
 1559 	# char_float comparison
 1560 	AC_CHECK_SIZEOF(char_float, 0, [typedef struct { char a; float b; } char_float; ])
 1561 	size=`expr $ac_cv_sizeof_char + $ac_cv_sizeof_float`
 1562 	extent=$ac_cv_sizeof_char_float
 1563 	if test "$size" != "$extent" ; then is_packed=0 ; fi
 1564 	if test "`expr $extent % $ac_cv_sizeof_float`" != "0" ; then is_largest=0 ; fi
 1565 	if test "`expr $extent % 2`" != "0" ; then is_two=0 ; fi
 1566 	if test "`expr $extent % 4`" != "0" ; then is_four=0 ; fi
 1567 	if test "$ac_cv_sizeof_float" = "8" -a "`expr $extent % 8`" != "0" ; then
 1568 	   is_eight=0
 1569 	fi
 1570 
 1571 	# char_double comparison
 1572 	AC_CHECK_SIZEOF(char_double, 0, [typedef struct { char a; double b; } char_double; ])
 1573 	size=`expr $ac_cv_sizeof_char + $ac_cv_sizeof_double`
 1574 	extent=$ac_cv_sizeof_char_double
 1575 	if test "$size" != "$extent" ; then is_packed=0 ; fi
 1576 	if test "`expr $extent % $ac_cv_sizeof_double`" != "0" ; then is_largest=0 ; fi
 1577 	if test "`expr $extent % 2`" != "0" ; then is_two=0 ; fi
 1578 	if test "`expr $extent % 4`" != "0" ; then is_four=0 ; fi
 1579 	if test "$ac_cv_sizeof_double" = "8" -a "`expr $extent % 8`" != "0" ; then
 1580 	   is_eight=0
 1581 	fi
 1582 
 1583 	# char_long_double comparison
 1584 	if test "$have_long_double" = "yes"; then
 1585 	AC_CHECK_SIZEOF(char_long_double, 0, [
 1586 				       typedef struct {
 1587 				       	       char a;
 1588 					       long double b;
 1589 				       } char_long_double;
 1590 				       ])
 1591 	size=`expr $ac_cv_sizeof_char + $ac_cv_sizeof_long_double`
 1592 	extent=$ac_cv_sizeof_char_long_double
 1593 	if test "$size" != "$extent" ; then is_packed=0 ; fi
 1594 	if test "`expr $extent % $ac_cv_sizeof_long_double`" != "0" ; then is_largest=0 ; fi
 1595 	if test "`expr $extent % 2`" != "0" ; then is_two=0 ; fi
 1596 	if test "`expr $extent % 4`" != "0" ; then is_four=0 ; fi
 1597 	if test "$ac_cv_sizeof_long_double" = "8" -a "`expr $extent % 8`" != "0" ; then
 1598 	   is_eight=0
 1599 	fi
 1600 	fi
 1601 
 1602 	# char_int_char comparison
 1603 	AC_CHECK_SIZEOF(char_int_char, 0, [
 1604 				       typedef struct {
 1605 				       	       char a;
 1606 					       int b;
 1607 					       char c;
 1608 				       } char_int_char;
 1609 				       ])
 1610 	size=`expr $ac_cv_sizeof_char + $ac_cv_sizeof_int + $ac_cv_sizeof_char`
 1611 	extent=$ac_cv_sizeof_char_int_char
 1612 	if test "$size" != "$extent" ; then is_packed=0 ; fi
 1613 	if test "`expr $extent % $ac_cv_sizeof_int`" != "0" ; then is_largest=0 ; fi
 1614 	if test "`expr $extent % 2`" != "0" ; then is_two=0 ; fi
 1615 	if test "`expr $extent % 4`" != "0" ; then is_four=0 ; fi
 1616 	if test "$ac_cv_sizeof_int" = "8" -a "`expr $extent % 8`" != "0" ; then
 1617 	   is_eight=0
 1618 	fi
 1619 
 1620 	# char_short_char comparison
 1621 	AC_CHECK_SIZEOF(char_short_char, 0, [
 1622 				       typedef struct {
 1623 				       	       char a;
 1624 					       short b;
 1625 					       char c;
 1626 				       } char_short_char;
 1627 				       ])
 1628 	size=`expr $ac_cv_sizeof_char + $ac_cv_sizeof_short + $ac_cv_sizeof_char`
 1629 	extent=$ac_cv_sizeof_char_short_char
 1630 	if test "$size" != "$extent" ; then is_packed=0 ; fi
 1631 	if test "`expr $extent % $ac_cv_sizeof_short`" != "0" ; then is_largest=0 ; fi
 1632 	if test "`expr $extent % 2`" != "0" ; then is_two=0 ; fi
 1633 	if test "$ac_cv_sizeof_short" = "4" -a "`expr $extent % 4`" != "0" ; then
 1634 	   is_four=0
 1635 	fi
 1636 	if test "$ac_cv_sizeof_short" = "8" -a "`expr $extent % 8`" != "0" ; then
 1637 	   is_eight=0
 1638 	fi
 1639 
 1640 	# If aligned mod 8, it will be aligned mod 4
 1641 	if test $is_eight = 1 ; then is_four=0 ; is_two=0 ; fi
 1642 	if test $is_four = 1 ; then is_two=0 ; fi
 1643 
 1644 	# Largest supersedes 8
 1645 	if test $is_largest = 1 ; then is_eight=0 ; fi
 1646 
 1647 	# Find the alignment
 1648 	if test "`expr $is_packed + $is_largest + $is_two + $is_four + $is_eight`" = "0" ; then
 1649 	   pac_cv_struct_alignment="unknown"
 1650 	elif test "`expr $is_packed + $is_largest + $is_two + $is_four + $is_eight`" != "1" ; then
 1651 	   pac_cv_struct_alignment="unknown"
 1652 	elif test $is_packed = 1 ; then
 1653 	   pac_cv_struct_alignment="packed"
 1654 	elif test $is_largest = 1 ; then
 1655 	   pac_cv_struct_alignment="largest"
 1656 	elif test $is_two = 1 ; then
 1657 	   pac_cv_struct_alignment="two"
 1658 	elif test $is_four = 1 ; then
 1659 	   pac_cv_struct_alignment="four"
 1660 	elif test $is_eight = 1 ; then
 1661 	   pac_cv_struct_alignment="eight"
 1662 	fi
 1663 ])
 1664 dnl
 1665 dnl PAC_C_MACRO_VA_ARGS
 1666 dnl
 1667 dnl will AC_DEFINE([HAVE_MACRO_VA_ARGS]) if the compiler supports C99 variable
 1668 dnl length argument lists in macros (#define foo(...) bar(__VA_ARGS__))
 1669 AC_DEFUN([PAC_C_MACRO_VA_ARGS],[
 1670     AC_MSG_CHECKING([for variable argument list macro functionality])
 1671     AC_LINK_IFELSE([AC_LANG_PROGRAM([
 1672         #include <stdio.h>
 1673         #define conftest_va_arg_macro(...) printf(__VA_ARGS__)
 1674     ],
 1675     [conftest_va_arg_macro("a test %d", 3);])],
 1676     [AC_DEFINE([HAVE_MACRO_VA_ARGS],[1],[Define if C99-style variable argument list macro functionality])
 1677      AC_MSG_RESULT([yes])],
 1678     [AC_MSG_RESULT([no])])
 1679 ])dnl
 1680 
 1681 # Will AC_DEFINE([HAVE_BUILTIN_EXPECT]) if the compiler supports __builtin_expect.
 1682 AC_DEFUN([PAC_C_BUILTIN_EXPECT],[
 1683 AC_MSG_CHECKING([if C compiler supports __builtin_expect])
 1684 
 1685 AC_TRY_LINK(, [
 1686     return __builtin_expect(1, 1) ? 1 : 0
 1687 ], [
 1688     have_builtin_expect=yes
 1689     AC_MSG_RESULT([yes])
 1690 ], [
 1691     have_builtin_expect=no
 1692     AC_MSG_RESULT([no])
 1693 ])
 1694 if test x$have_builtin_expect = xyes ; then
 1695     AC_DEFINE([HAVE_BUILTIN_EXPECT], [1], [Define to 1 if the compiler supports __builtin_expect.])
 1696 fi
 1697 ])
 1698 
 1699 dnl
 1700 dnl PAC_CC_CHECK_TLS - Test for thread local storage support
 1701 dnl
 1702 dnl will AC_DEFINE([TLS]) to a compiler supported TLS keyword
 1703 dnl
 1704 AC_DEFUN([PAC_CC_CHECK_TLS], [
 1705     AC_CACHE_CHECK([for thread local storage], [pac_cv_tls], [
 1706     if test -z $pac_cv_tls ; then
 1707         AC_LINK_IFELSE([AC_LANG_PROGRAM([_Thread_local int foo=0;],[foo=1])],
 1708             [pac_cv_tls=_Thread_local])
 1709     fi
 1710     if test -z $pac_cv_tls ; then
 1711         AC_LINK_IFELSE( [AC_LANG_PROGRAM([__thread int foo=0;],[foo=1])],
 1712             [pac_cv_tls=__thread])
 1713     fi
 1714     if test -z $pac_cv_tls ; then
 1715         AC_LINK_IFELSE( [AC_LANG_PROGRAM([__declspec(thread) int foo=0;],[foo=1])],
 1716             [pac_cv_tls="__declspec(thread)"])
 1717     fi])
 1718     if test -z $pac_cv_tls ; then
 1719         AC_MSG_WARN([Compiler does not support thread local storage])
 1720     else
 1721         AC_DEFINE_UNQUOTED([TLS], [$pac_cv_tls], [Defined the keyword for thread-local storage.])
 1722     fi
 1723 ])