2 ifdef([AC_PROG_CC_GNU],,[AC_DEFUN([AC_PROG_CC_GNU],)])
4 dnl PAC_PROG_CC - reprioritize the C compiler search order
5 AC_DEFUN([PAC_PROG_CC],[
6 PAC_PUSH_FLAG([CFLAGS])
7 AC_PROG_CC([gcc icc pgcc xlc xlC pathcc cc])
12 dnl PAC_C_CHECK_COMPILER_OPTION - Check that a compiler option is accepted
13 dnl without warning messages
16 dnl PAC_C_CHECK_COMPILER_OPTION(optionname,action-if-ok,action-if-fail)
20 dnl If no actions are specified, a working value is added to 'COPTIONS'
23 dnl This is now careful to check that the output is different, since
24 dnl some compilers are noisy.
26 dnl We are extra careful to prototype the functions in case compiler options
27 dnl that complain about poor code are in effect.
29 dnl Because this is a long script, we have ensured that you can pass a
30 dnl variable containing the option name as the first argument.
33 AC_DEFUN([PAC_C_CHECK_COMPILER_OPTION],[
34 AC_MSG_CHECKING([whether C compiler accepts option $1])
38 CFLAGS_opt="$pac_opt $CFLAGS"
41 AC_LANG_CONFTEST([AC_LANG_PROGRAM()])
44 PAC_LINK_IFELSE_LOG([pac_test1.log], [], [
47 PAC_LINK_IFELSE_LOG([pac_test2.log], [], [
48 PAC_RUNLOG_IFELSE([diff -b pac_test1.log pac_test2.log],
49 [pac_result=yes],[pac_result=no])
56 AC_MSG_RESULT([$pac_result])
57 dnl Delete the conftest created by AC_LANG_CONFTEST.
58 rm -f conftest.$ac_ext
60 # gcc 4.2.4 on 32-bit does not complain about the -Wno-type-limits option
61 # even though it doesn't support it. However, when another warning is
62 # triggered, it gives an error that the option is not recognized. So we
63 # need to test with a conftest file that will generate warnings.
65 # add an extra switch, pac_c_check_compiler_option_invalidprototest, to
66 # disable this test just in case some new compiler does not like it.
68 # Linking with a program with an invalid prototype to ensure a compiler warning.
70 if test "$pac_result" = "yes" \
71 -a "$pac_c_check_compiler_option_prototest" != "no" ; then
72 AC_MSG_CHECKING([whether C compiler option $1 works with an invalid prototype program])
74 AC_LANG_SOURCE([void main(){ return 0; }])
75 ],[pac_result=yes],[pac_result=no])
76 AC_MSG_RESULT([$pac_result])
79 if test "$pac_result" = "yes" ; then
80 AC_MSG_CHECKING([whether routines compiled with $pac_opt can be linked with ones compiled without $pac_opt])
84 PAC_COMPILE_IFELSE_LOG([pac_test3.log], [
87 int foo(void){return 0;}
90 PAC_RUNLOG([mv conftest.$OBJEXT pac_conftest.$OBJEXT])
92 LIBS="pac_conftest.$OBJEXT $LIBS"
95 PAC_LINK_IFELSE_LOG([pac_test4.log], [AC_LANG_PROGRAM()], [
98 PAC_LINK_IFELSE_LOG([pac_test5.log], [AC_LANG_PROGRAM()], [
99 PAC_RUNLOG_IFELSE([diff -b pac_test4.log pac_test5.log],
100 [pac_result=yes], [pac_result=no])
108 rm -f pac_conftest.$OBJEXT
112 AC_MSG_RESULT([$pac_result])
113 rm -f pac_test3.log pac_test4.log pac_test5.log
115 rm -f pac_test1.log pac_test2.log
117 dnl Restore CFLAGS before 2nd/3rd argument commands are executed,
118 dnl as 2nd/3rd argument command could be modifying CFLAGS.
119 CFLAGS="$CFLAGS_orig"
120 if test "$pac_result" = "yes" ; then
121 ifelse([$2],[],[COPTIONS="$COPTIONS $1"],[$2])
123 ifelse([$3],[],[:],[$3])
129 dnl PAC_C_OPTIMIZATION - Determine C options for producing optimized code
132 dnl PAC_C_OPTIMIZATION([action if found])
135 dnl Adds options to 'COPTIONS' if no other action is specified
138 dnl This is a temporary standin for compiler optimization.
139 dnl It should try to match known systems to known compilers (checking, of
140 dnl course), and then falling back to some common defaults.
141 dnl Note that many compilers will complain about -g and aggressive
144 AC_DEFUN([PAC_C_OPTIMIZATION],[
145 for copt in "-O4 -Ofast" "-Ofast" "-fast" "-O3" "-xO3" "-O" ; do
146 PAC_C_CHECK_COMPILER_OPTION($copt,found_opt=yes,found_opt=no)
147 if test "$found_opt" = "yes" ; then
148 ifelse($1,,COPTIONS="$COPTIONS $copt",$1)
152 if test "$ac_cv_prog_gcc" = "yes" ; then
153 for copt in "-fomit-frame-pointer" "-finline-functions" \
154 "-funroll-loops" ; do
155 PAC_C_CHECK_COMPILER_OPTION($copt,found_opt=yes,found_opt=no)
156 if test "$found_opt" = "yes" ; then
157 ifelse($1,,COPTIONS="$COPTIONS $copt",$1)
158 # no break because we're trying to add them all
161 # We could also look for architecture-specific gcc options
167 dnl PAC_PROG_C_UNALIGNED_DOUBLES - Check that the C compiler allows unaligned
171 dnl PAC_PROG_C_UNALIGNED_DOUBLES(action-if-true,action-if-false,
172 dnl action-if-unknown)
175 dnl 'action-if-unknown' is used in the case of cross-compilation.
177 AC_DEFUN([PAC_PROG_C_UNALIGNED_DOUBLES],[
178 AC_CACHE_CHECK([whether C compiler allows unaligned doubles],
179 pac_cv_prog_c_unaligned_doubles,[
181 void fetch_double( v )
186 int main( argc, argv )
192 fetch_double( (double *)&(p[0]) );
193 p_val = (double *)&(p[0]);
194 if (*p_val != 1.0) return 1;
195 fetch_double( (double *)&(p[1]) );
196 p_val = (double *)&(p[1]);
197 if (*p_val != 1.0) return 1;
200 ],pac_cv_prog_c_unaligned_doubles="yes",pac_cv_prog_c_unaligned_doubles="no",
201 pac_cv_prog_c_unaligned_doubles="unknown")])
202 ifelse($1,,,if test "X$pac_cv_prog_c_unaligned_doubles" = "yes" ; then
205 ifelse($2,,,if test "X$pac_cv_prog_c_unaligned_doubles" = "no" ; then
208 ifelse($3,,,if test "X$pac_cv_prog_c_unaligned_doubles" = "unknown" ; then
214 dnl PAC_PROG_C_WEAK_SYMBOLS - Test whether C supports weak alias symbols.
217 dnl PAC_PROG_C_WEAK_SYMBOLS(action-if-true,action-if-false)
220 dnl Defines one of the following if a weak symbol pragma is found:
222 dnl HAVE_PRAGMA_WEAK - #pragma weak
223 dnl HAVE_PRAGMA_HP_SEC_DEF - #pragma _HP_SECONDARY_DEF
224 dnl HAVE_PRAGMA_CRI_DUP - #pragma _CRI duplicate x as y
228 dnl HAVE_WEAK_ATTRIBUTE
230 dnl if functions can be declared as 'int foo(...) __attribute__ ((weak));'
231 dnl sets the shell variable pac_cv_attr_weak to yes.
232 dnl Also checks for __attribute__((weak_import)) which is supported by
233 dnl Apple in Mac OSX (at least in Darwin). Note that this provides only
234 dnl weak symbols, not weak aliases
237 AC_DEFUN([PAC_PROG_C_WEAK_SYMBOLS],[
238 pragma_extra_message=""
239 AC_CACHE_CHECK([for type of weak symbol alias support],
240 pac_cv_prog_c_weak_symbols,[
241 # Test for weak symbol support...
242 # We can't put # in the message because it causes autoconf to generate
245 extern int PFoo(int);
246 #pragma weak PFoo = Foo
247 int Foo(int a) { return a; }
248 ],[return PFoo(1);],has_pragma_weak=yes)
250 # Some systems (Linux ia64 and ecc, for example), support weak symbols
251 # only within a single object file! This tests that case.
252 # Note that there is an extern int PFoo declaration before the
253 # pragma. Some compilers require this in order to make the weak symbol
255 if test "$has_pragma_weak" = yes ; then
256 PAC_COMPLINK_IFELSE([
258 extern int PFoo(int);
259 #pragma weak PFoo = Foo
261 int Foo(int a) { return a; }
265 extern int PFoo(int);
266 int main(int argc, char **argv) {
270 PAC_COMPLINK_IFELSE([
272 extern int PFoo(int);
273 #pragma weak PFoo = Foo
275 int Foo(int a) { return a; }
280 int PFoo(int a) { return a+1;}
281 int main(int argc, char **argv) {
285 pac_cv_prog_c_weak_symbols="pragma weak"
288 pragma_extra_message="pragma weak accepted but does not work (probably creates two non-weak entries)"
292 pragma_extra_message="pragma weak accepted but does not work (probably creates two non-weak entries)"
296 if test -z "$pac_cv_prog_c_weak_symbols" ; then
298 extern int PFoo(int);
299 #pragma _HP_SECONDARY_DEF Foo PFoo
300 int Foo(int a) { return a; }
301 ],[return PFoo(1);],pac_cv_prog_c_weak_symbols="pragma _HP_SECONDARY_DEF")
304 if test -z "$pac_cv_prog_c_weak_symbols" ; then
306 extern int PFoo(int);
307 #pragma _CRI duplicate PFoo as Foo
308 int Foo(int a) { return a; }
309 ],[return PFoo(1);],pac_cv_prog_c_weak_symbols="pragma _CRI duplicate x as y")
312 if test -z "$pac_cv_prog_c_weak_symbols" ; then
313 pac_cv_prog_c_weak_symbols="no"
316 dnl If there is an extra explanatory message, echo it now so that it
317 dnl doesn't interfere with the cache result value
318 if test -n "$pragma_extra_message" ; then
319 echo $pragma_extra_message
323 if test "$pac_cv_prog_c_weak_symbols" = "no" ; then
326 case "$pac_cv_prog_c_weak_symbols" in
327 "pragma weak") AC_DEFINE(HAVE_PRAGMA_WEAK,1,[Supports weak pragma])
329 "pragma _HP") AC_DEFINE(HAVE_PRAGMA_HP_SEC_DEF,1,[HP style weak pragma])
331 "pragma _CRI") AC_DEFINE(HAVE_PRAGMA_CRI_DUP,1,[Cray style weak pragma])
336 AC_CACHE_CHECK([whether __attribute__ ((weak)) allowed],
338 AC_TRY_COMPILE([int foo(int) __attribute__ ((weak));],[int a;],
339 pac_cv_attr_weak=yes,pac_cv_attr_weak=no)])
340 # Note that being able to compile with weak_import doesn't mean that
342 AC_CACHE_CHECK([whether __attribute__ ((weak_import)) allowed],
343 pac_cv_attr_weak_import,[
344 AC_TRY_COMPILE([int foo(int) __attribute__ ((weak_import));],[int a;],
345 pac_cv_attr_weak_import=yes,pac_cv_attr_weak_import=no)])
346 # Check if the alias option for weak attributes is allowed
347 AC_CACHE_CHECK([whether __attribute__((weak,alias(...))) allowed],
348 pac_cv_attr_weak_alias,[
349 AC_TRY_COMPILE([int foo(int) __attribute__((weak,alias("__foo")));],[int a;],
350 pac_cv_attr_weak_alias=yes,pac_cv_attr_weak_alias=no)])
354 # This is a replacement that checks that FAILURES are signaled as well
355 # (later configure macros look for the .o file, not just success from the
356 # compiler, but they should not HAVE to
358 dnl --- insert 2.52 compatibility here ---
359 dnl 2.52 does not have AC_PROG_CC_WORKS
360 ifdef([AC_PROG_CC_WORKS],,[AC_DEFUN([AC_PROG_CC_WORKS],)])
362 AC_DEFUN([PAC_PROG_CC_WORKS],
364 AC_MSG_CHECKING([whether the C compiler sets its return status correctly])
367 AC_TRY_COMPILE(,[int a = bzzzt;],notbroken=no,notbroken=yes)
368 AC_MSG_RESULT($notbroken)
369 if test "$notbroken" = "no" ; then
370 AC_MSG_ERROR([installation or configuration problem: C compiler does not
371 correctly set error code when a fatal error occurs])
376 dnl PAC_PROG_C_MULTIPLE_WEAK_SYMBOLS - Test whether C and the
377 dnl linker allow multiple weak symbols.
380 dnl PAC_PROG_C_MULTIPLE_WEAK_SYMBOLS(action-if-true,action-if-false)
384 AC_DEFUN([PAC_PROG_C_MULTIPLE_WEAK_SYMBOLS],[
385 AC_CACHE_CHECK([for multiple weak symbol support],
386 pac_cv_prog_c_multiple_weak_symbols,[
387 # Test for multiple weak symbol support...
388 PAC_COMPLINK_IFELSE([
390 extern int PFoo(int);
391 extern int PFoo_(int);
392 extern int pfoo_(int);
393 #pragma weak PFoo = Foo
394 #pragma weak PFoo_ = Foo
395 #pragma weak pfoo_ = Foo
397 int Foo(a) { return a; }
401 extern int PFoo(int), PFoo_(int), pfoo_(int);
403 return PFoo(0) + PFoo_(1) + pfoo_(2);}
406 pac_cv_prog_c_multiple_weak_symbols="yes"
410 if test "$pac_cv_prog_c_multiple_weak_symbols" = "yes" ; then
417 dnl Use the value of enable-strict to update CFLAGS
418 dnl pac_cc_strict_flags contains the strict flags.
420 dnl -std=c89 is used to select the C89 version of the ANSI/ISO C standard.
421 dnl As of this writing, many C compilers still accepted only this version,
422 dnl not the later C99 version. When all compilers accept C99, this
423 dnl should be changed to the appropriate standard level. Note that we've
424 dnl had trouble with gcc 2.95.3 accepting -std=c89 but then trying to
425 dnl compile program with a invalid set of options
426 dnl (-D __STRICT_ANSI__-trigraphs)
427 AC_DEFUN([PAC_CC_STRICT],[
428 export enable_strict_done
429 if test "$enable_strict_done" != "yes" ; then
431 # Some comments on strict warning options.
432 # These were added to reduce warnings:
433 # -Wno-missing-field-initializers -- We want to allow a struct to be
434 # initialized to zero using "struct x y = {0};" and not require
435 # each field to be initialized individually.
436 # -Wno-unused-parameter -- For portability, some parameters go unused
437 # when we have different implementations of functions for
438 # different platforms
439 # -Wno-unused-label -- We add fn_exit: and fn_fail: on all functions,
440 # but fn_fail may not be used if the function doesn't return an
442 # -Wno-sign-compare -- read() and write() return bytes read/written
443 # as a signed value, but we often compare this to size_t (or
444 # msg_sz_t) variables.
445 # -Wno-format-zero-length -- this warning is irritating and useless, since
446 # a zero-length format string is very well defined
447 # -Wno-type-limits -- There are places where we compare an unsigned to
448 # a constant that happens to be zero e.g., if x is unsigned and
449 # MIN_VAL is zero, we'd like to do "MPIU_Assert(x >= MIN_VAL);".
450 # Note this option is not supported by gcc 4.2. This needs to be added
451 # after most other warning flags, so that we catch a gcc bug on 32-bit
452 # that doesn't give a warning that this is unsupported, unless another
453 # warning is triggered, and then if gives an error.
454 # These were removed to reduce warnings:
455 # -Wcast-qual -- Sometimes we need to cast "volatile char*" to
456 # "char*", e.g., for memcpy.
457 # -Wpadded -- We catch struct padding with asserts when we need to
458 # -Wredundant-decls -- Having redundant declarations is benign and the
459 # code already has some.
460 # -Waggregate-return -- This seems to be a performance-related warning
461 # aggregate return values are legal in ANSI C, but they may be returned
462 # in memory rather than through a register. We do use aggregate return
463 # values, but they are structs of a single basic type (used to enforce
464 # type checking for relative vs. absolute ptrs), and with optimization
465 # the aggregate value is converted to a scalar.
466 # -Wdeclaration-after-statement -- This is a C89
467 # requirement. When compiling with C99, this should be
469 # the embedded newlines in this string are safe because we evaluate each
470 # argument in the for-loop below and append them to the CFLAGS with a space
471 # as the separator instead
472 pac_common_strict_flags="
475 -Wno-missing-field-initializers
479 -Wno-unused-parameter
482 -Wmissing-declarations
492 -Wold-style-definition
494 -Wno-deprecated-declarations
500 -Wno-format-zero-length
508 flags="`echo $1 | sed -e 's/:/ /g' -e 's/,/ /g'`"
509 for flag in ${flags}; do
512 enable_strict_done="yes"
516 enable_strict_done="yes"
520 enable_strict_done="yes"
524 enable_strict_done="yes"
528 enable_strict_done="yes"
532 enable_strict_done="yes"
536 enable_strict_done="yes"
542 # Accept and ignore this value
546 if test -n "$flag" ; then
547 AC_MSG_WARN([Unrecognized value for enable-strict:$flag])
553 pac_cc_strict_flags=""
554 if test "${enable_strict_done}" = "yes" ; then
555 if test "${enable_opt}" = "yes" ; then
556 pac_cc_strict_flags="-O2"
558 pac_cc_strict_flags="$pac_cc_strict_flags $pac_common_strict_flags"
559 if test "${enable_posix}" = "yes" ; then
560 PAC_APPEND_FLAG([-D_POSIX_C_SOURCE=199506L],[pac_cc_strict_flags])
562 # We only allow one of strict-C99 or strict-C89 to be
563 # enabled. If C99 is enabled, we automatically disable C89.
564 if test "${enable_c99}" = "yes" ; then
565 PAC_APPEND_FLAG([-std=c99],[pac_cc_strict_flags])
566 elif test "${enable_c89}" = "yes" ; then
567 PAC_APPEND_FLAG([-std=c89],[pac_cc_strict_flags])
568 PAC_APPEND_FLAG([-Wdeclaration-after-statement],[pac_cc_strict_flags])
572 # See if the above options work with the compiler
574 for flag in $pac_cc_strict_flags ; do
575 PAC_PUSH_FLAG([CFLAGS])
576 CFLAGS="$CFLAGS $accepted_flags"
577 PAC_C_CHECK_COMPILER_OPTION([$flag],[accepted_flags="$accepted_flags $flag"],)
578 PAC_POP_FLAG([CFLAGS])
580 pac_cc_strict_flags=$accepted_flags
585 dnl PAC_ARG_STRICT - Add --enable-strict to configure.
591 dnl Adds '--enable-strict' to the command line.
594 AC_DEFUN([PAC_ARG_STRICT],[
595 AC_ARG_ENABLE(strict,
596 AC_HELP_STRING([--enable-strict], [Turn on strict compilation testing]))
597 PAC_CC_STRICT($enable_strict)
598 CFLAGS="$CFLAGS $pac_cc_strict_flags"
602 dnl Return the integer structure alignment in pac_cv_c_max_integer_align
603 dnl Possible values include
609 dnl In addition, a "Could not determine alignment" and a "error!"
610 dnl return is possible.
611 AC_DEFUN([PAC_C_MAX_INTEGER_ALIGN],[
612 AC_CACHE_CHECK([for max C struct integer alignment],
613 pac_cv_c_max_integer_align,[
617 int main( int argc, char *argv[] )
624 struct { char a; int b; } char_int;
625 struct { char a; short b; } char_short;
626 struct { char a; long b; } char_long;
627 struct { char a; int b; char c; } char_int_char;
628 struct { char a; short b; char c; } char_short_char;
629 #ifdef HAVE_LONG_LONG_INT
630 struct { long long int a; char b; } lli_c;
631 struct { char a; long long int b; } c_lli;
633 int size, extent, extent2;
635 /* assume max integer alignment isn't 8 if we don't have
636 * an eight-byte value :)
638 #ifdef HAVE_LONG_LONG_INT
639 if (sizeof(int) < 8 && sizeof(long) < 8 && sizeof(long long int) < 8)
642 if (sizeof(int) < 8 && sizeof(long) < 8) is_eight = 0;
645 size = sizeof(char) + sizeof(int);
646 extent = sizeof(char_int);
647 if (size != extent) is_packed = 0;
648 if ( (extent % 2) != 0) is_two = 0;
649 if ( (extent % 4) != 0) is_four = 0;
650 if (sizeof(int) == 8 && (extent % 8) != 0) is_eight = 0;
651 DBG("char_int",size,extent);
653 size = sizeof(char) + sizeof(short);
654 extent = sizeof(char_short);
655 if (size != extent) is_packed = 0;
656 if ( (extent % 2) != 0) is_two = 0;
657 if (sizeof(short) == 4 && (extent % 4) != 0) is_four = 0;
658 if (sizeof(short) == 8 && (extent % 8) != 0) is_eight = 0;
659 DBG("char_short",size,extent);
661 size = sizeof(char) + sizeof(long);
662 extent = sizeof(char_long);
663 if (size != extent) is_packed = 0;
664 if ( (extent % 2) != 0) is_two = 0;
665 if ( (extent % 4) != 0) is_four = 0;
666 if (sizeof(long) == 8 && (extent % 8) != 0) is_eight = 0;
667 DBG("char_long",size,extent);
669 #ifdef HAVE_LONG_LONG_INT
670 size = sizeof(char) + sizeof(long long int);
671 extent = sizeof(lli_c);
672 extent2 = sizeof(c_lli);
673 if (size != extent) is_packed = 0;
674 if ( (extent % 2) != 0 && (extent2 % 2) != 0) is_two = 0;
675 if ( (extent % 4) != 0 && (extent2 % 4) != 0) is_four = 0;
676 if (sizeof(long long int) >= 8 && (extent % 8) != 0 && (extent2 % 8) != 0)
680 size = sizeof(char) + sizeof(int) + sizeof(char);
681 extent = sizeof(char_int_char);
682 if (size != extent) is_packed = 0;
683 if ( (extent % 2) != 0) is_two = 0;
684 if ( (extent % 4) != 0) is_four = 0;
685 if (sizeof(int) == 8 && (extent % 8) != 0) is_eight = 0;
686 DBG("char_int_char",size,extent);
688 size = sizeof(char) + sizeof(short) + sizeof(char);
689 extent = sizeof(char_short_char);
690 if (size != extent) is_packed = 0;
691 if ( (extent % 2) != 0) is_two = 0;
692 if (sizeof(short) == 4 && (extent % 4) != 0) is_four = 0;
693 if (sizeof(short) == 8 && (extent % 8) != 0) is_eight = 0;
694 DBG("char_short_char",size,extent);
696 /* If aligned mod 8, it will be aligned mod 4 */
697 if (is_eight) { is_four = 0; is_two = 0; }
699 if (is_four) is_two = 0;
701 /* Tabulate the results */
702 cf = fopen( "ctest.out", "w" );
703 if (is_packed + is_two + is_four + is_eight == 0) {
704 fprintf( cf, "Could not determine alignment\n" );
707 if (is_packed + is_two + is_four + is_eight != 1) {
708 fprintf( cf, "error!\n" );
711 if (is_packed) fprintf( cf, "packed\n" );
712 if (is_two) fprintf( cf, "two\n" );
713 if (is_four) fprintf( cf, "four\n" );
714 if (is_eight) fprintf( cf, "eight\n" );
720 pac_cv_c_max_integer_align=`cat ctest.out`,
721 pac_cv_c_max_integer_align="unknown",
722 pac_cv_c_max_integer_align="$CROSS_ALIGN_STRUCT_INT")
725 if test -z "$pac_cv_c_max_integer_align" ; then
726 pac_cv_c_max_integer_align="unknown"
730 dnl Return the floating point structure alignment in
731 dnl pac_cv_c_max_fp_align.
733 dnl Possible values include:
740 dnl In addition, a "Could not determine alignment" and a "error!"
741 dnl return is possible.
742 AC_DEFUN([PAC_C_MAX_FP_ALIGN],[
743 AC_CACHE_CHECK([for max C struct floating point alignment],
744 pac_cv_c_max_fp_align,[
748 int main( int argc, char *argv[] )
756 struct { char a; float b; } char_float;
757 struct { float b; char a; } float_char;
758 struct { char a; double b; } char_double;
759 struct { double b; char a; } double_char;
760 #ifdef HAVE_LONG_DOUBLE
761 struct { char a; long double b; } char_long_double;
762 struct { long double b; char a; } long_double_char;
763 struct { long double a; int b; char c; } long_double_int_char;
765 int size, extent1, extent2;
767 size = sizeof(char) + sizeof(float);
768 extent1 = sizeof(char_float);
769 extent2 = sizeof(float_char);
770 if (size != extent1) is_packed = 0;
771 if ( (extent1 % 2) != 0 && (extent2 % 2) != 0) is_two = 0;
772 if ( (extent1 % 4) != 0 && (extent2 % 4) != 0) is_four = 0;
773 if (sizeof(float) == 8 && (extent1 % 8) != 0 && (extent2 % 8) != 0)
775 DBG("char_float",size,extent1);
777 size = sizeof(char) + sizeof(double);
778 extent1 = sizeof(char_double);
779 extent2 = sizeof(double_char);
780 if (size != extent1) is_packed = 0;
781 if ( (extent1 % 2) != 0 && (extent2 % 2) != 0) is_two = 0;
782 if ( (extent1 % 4) != 0 && (extent2 % 4) != 0) is_four = 0;
783 if (sizeof(double) == 8 && (extent1 % 8) != 0 && (extent2 % 8) != 0)
785 DBG("char_double",size,extent1);
787 #ifdef HAVE_LONG_DOUBLE
788 size = sizeof(char) + sizeof(long double);
789 extent1 = sizeof(char_long_double);
790 extent2 = sizeof(long_double_char);
791 if (size != extent1) is_packed = 0;
792 if ( (extent1 % 2) != 0 && (extent2 % 2) != 0) is_two = 0;
793 if ( (extent1 % 4) != 0 && (extent2 % 4) != 0) is_four = 0;
794 if (sizeof(long double) >= 8 && (extent1 % 8) != 0 && (extent2 % 8) != 0)
796 if (sizeof(long double) > 8 && (extent1 % 16) != 0
797 && (extent2 % 16) != 0) is_sixteen = 0;
798 DBG("char_long-double",size,extent1);
800 extent1 = sizeof(long_double_int_char);
801 if ( (extent1 % 2) != 0) is_two = 0;
802 if ( (extent1 % 4) != 0) is_four = 0;
803 if (sizeof(long double) >= 8 && (extent1 % 8) != 0) is_eight = 0;
804 if (sizeof(long double) > 8 && (extent1 % 16) != 0) is_sixteen = 0;
809 if (is_sixteen) { is_eight = 0; is_four = 0; is_two = 0; }
811 if (is_eight) { is_four = 0; is_two = 0; }
813 if (is_four) is_two = 0;
815 /* Tabulate the results */
816 cf = fopen( "ctest.out", "w" );
817 if (is_packed + is_two + is_four + is_eight + is_sixteen == 0) {
818 fprintf( cf, "Could not determine alignment\n" );
821 if (is_packed + is_two + is_four + is_eight + is_sixteen != 1) {
822 fprintf( cf, "error!\n" );
825 if (is_packed) fprintf( cf, "packed\n" );
826 if (is_two) fprintf( cf, "two\n" );
827 if (is_four) fprintf( cf, "four\n" );
828 if (is_eight) fprintf( cf, "eight\n" );
829 if (is_sixteen) fprintf( cf, "sixteen\n" );
835 pac_cv_c_max_fp_align=`cat ctest.out`,
836 pac_cv_c_max_fp_align="unknown",
837 pac_cv_c_max_fp_align="$CROSS_ALIGN_STRUCT_FP")
840 if test -z "$pac_cv_c_max_fp_align" ; then
841 pac_cv_c_max_fp_align="unknown"
845 dnl Return the floating point structure alignment in
846 dnl pac_cv_c_max_double_fp_align.
848 dnl Possible values include:
854 dnl In addition, a "Could not determine alignment" and a "error!"
855 dnl return is possible.
856 AC_DEFUN([PAC_C_MAX_DOUBLE_FP_ALIGN],[
857 AC_CACHE_CHECK([for max C struct alignment of structs with doubles],
858 pac_cv_c_max_double_fp_align,[
862 int main( int argc, char *argv[] )
869 struct { char a; float b; } char_float;
870 struct { float b; char a; } float_char;
871 struct { char a; double b; } char_double;
872 struct { double b; char a; } double_char;
873 int size, extent1, extent2;
875 size = sizeof(char) + sizeof(float);
876 extent1 = sizeof(char_float);
877 extent2 = sizeof(float_char);
878 if (size != extent1) is_packed = 0;
879 if ( (extent1 % 2) != 0 && (extent2 % 2) != 0) is_two = 0;
880 if ( (extent1 % 4) != 0 && (extent2 % 4) != 0) is_four = 0;
881 if (sizeof(float) == 8 && (extent1 % 8) != 0 && (extent2 % 8) != 0)
883 DBG("char_float",size,extent1);
885 size = sizeof(char) + sizeof(double);
886 extent1 = sizeof(char_double);
887 extent2 = sizeof(double_char);
888 if (size != extent1) is_packed = 0;
889 if ( (extent1 % 2) != 0 && (extent2 % 2) != 0) is_two = 0;
890 if ( (extent1 % 4) != 0 && (extent2 % 4) != 0) is_four = 0;
891 if (sizeof(double) == 8 && (extent1 % 8) != 0 && (extent2 % 8) != 0)
893 DBG("char_double",size,extent1);
895 if (is_eight) { is_four = 0; is_two = 0; }
897 if (is_four) is_two = 0;
899 /* Tabulate the results */
900 cf = fopen( "ctest.out", "w" );
901 if (is_packed + is_two + is_four + is_eight == 0) {
902 fprintf( cf, "Could not determine alignment\n" );
905 if (is_packed + is_two + is_four + is_eight != 1) {
906 fprintf( cf, "error!\n" );
909 if (is_packed) fprintf( cf, "packed\n" );
910 if (is_two) fprintf( cf, "two\n" );
911 if (is_four) fprintf( cf, "four\n" );
912 if (is_eight) fprintf( cf, "eight\n" );
918 pac_cv_c_max_double_fp_align=`cat ctest.out`,
919 pac_cv_c_max_double_fp_align="unknown",
920 pac_cv_c_max_double_fp_align="$CROSS_ALIGN_STRUCT_DOUBLE_FP")
923 if test -z "$pac_cv_c_max_double_fp_align" ; then
924 pac_cv_c_max_double_fp_align="unknown"
927 AC_DEFUN([PAC_C_MAX_LONGDOUBLE_FP_ALIGN],[
928 AC_CACHE_CHECK([for max C struct floating point alignment with long doubles],
929 pac_cv_c_max_longdouble_fp_align,[
933 int main( int argc, char *argv[] )
941 struct { char a; long double b; } char_long_double;
942 struct { long double b; char a; } long_double_char;
943 struct { long double a; int b; char c; } long_double_int_char;
944 int size, extent1, extent2;
946 size = sizeof(char) + sizeof(long double);
947 extent1 = sizeof(char_long_double);
948 extent2 = sizeof(long_double_char);
949 if (size != extent1) is_packed = 0;
950 if ( (extent1 % 2) != 0 && (extent2 % 2) != 0) is_two = 0;
951 if ( (extent1 % 4) != 0 && (extent2 % 4) != 0) is_four = 0;
952 if (sizeof(long double) >= 8 && (extent1 % 8) != 0 && (extent2 % 8) != 0)
954 if (sizeof(long double) > 8 && (extent1 % 16) != 0
955 && (extent2 % 16) != 0) is_sixteen = 0;
956 DBG("char_long-double",size,extent1);
958 extent1 = sizeof(long_double_int_char);
959 if ( (extent1 % 2) != 0) is_two = 0;
960 if ( (extent1 % 4) != 0) is_four = 0;
961 if (sizeof(long double) >= 8 && (extent1 % 8) != 0) is_eight = 0;
962 if (sizeof(long double) > 8 && (extent1 % 16) != 0) is_sixteen = 0;
964 if (is_sixteen) { is_eight = 0; is_four = 0; is_two = 0; }
966 if (is_eight) { is_four = 0; is_two = 0; }
968 if (is_four) is_two = 0;
970 /* Tabulate the results */
971 cf = fopen( "ctest.out", "w" );
972 if (is_packed + is_two + is_four + is_eight + is_sixteen == 0) {
973 fprintf( cf, "Could not determine alignment\n" );
976 if (is_packed + is_two + is_four + is_eight + is_sixteen != 1) {
977 fprintf( cf, "error!\n" );
980 if (is_packed) fprintf( cf, "packed\n" );
981 if (is_two) fprintf( cf, "two\n" );
982 if (is_four) fprintf( cf, "four\n" );
983 if (is_eight) fprintf( cf, "eight\n" );
984 if (is_sixteen) fprintf( cf, "sixteen\n" );
990 pac_cv_c_max_longdouble_fp_align=`cat ctest.out`,
991 pac_cv_c_max_longdouble_fp_align="unknown",
992 pac_cv_c_max_longdouble_fp_align="$CROSS_ALIGN_STRUCT_LONGDOUBLE_FP")
995 if test -z "$pac_cv_c_max_longdouble_fp_align" ; then
996 pac_cv_c_max_longdouble_fp_align="unknown"
1000 dnl Other tests assume that there is potentially a maximum alignment
1001 dnl and that if there is no maximum alignment, or a type is smaller than
1002 dnl that value, then we align on the size of the value, with the exception
1003 dnl of the "position-based alignment" rules we test for separately.
1005 dnl It turns out that these assumptions have fallen short in at least one
1006 dnl case, on MacBook Pros, where doubles are aligned on 4-byte boundaries
1007 dnl even when long doubles are aligned on 16-byte boundaries. So this test
1008 dnl is here specifically to handle this case.
1010 dnl Puts result in pac_cv_c_double_alignment_exception.
1012 dnl Possible values currently include no and four.
1014 AC_DEFUN([PAC_C_DOUBLE_ALIGNMENT_EXCEPTION],[
1015 AC_CACHE_CHECK([if double alignment breaks rules, find actual alignment],
1016 pac_cv_c_double_alignment_exception,[
1020 int main( int argc, char *argv[] )
1023 struct { char a; double b; } char_double;
1024 struct { double b; char a; } double_char;
1025 int extent1, extent2, align_4 = 0;
1027 extent1 = sizeof(char_double);
1028 extent2 = sizeof(double_char);
1030 /* we're interested in the largest value, will let separate test
1031 * deal with position-based issues.
1033 if (extent1 < extent2) extent1 = extent2;
1034 if ((sizeof(double) == 8) && (extent1 % 8) != 0) {
1035 if (extent1 % 4 == 0) {
1036 #ifdef HAVE_MAX_FP_ALIGNMENT
1037 if (HAVE_MAX_FP_ALIGNMENT >= 8) align_4 = 1;
1044 cf = fopen( "ctest.out", "w" );
1046 if (align_4) fprintf( cf, "four\n" );
1047 else fprintf( cf, "no\n" );
1052 pac_cv_c_double_alignment_exception=`cat ctest.out`,
1053 pac_cv_c_double_alignment_exception="unknown",
1054 pac_cv_c_double_alignment_exception="$CROSS_ALIGN_DOUBLE_EXCEPTION")
1057 if test -z "$pac_cv_c_double_alignment_exception" ; then
1058 pac_cv_c_double_alignment_exception="unknown"
1062 dnl Test for odd struct alignment rule that only applies max.
1063 dnl padding when double value is at front of type.
1064 dnl Puts result in pac_cv_c_double_pos_align.
1066 dnl Search for "Power alignment mode" for more details.
1068 dnl Possible values include yes, no, and unknown.
1070 AC_DEFUN([PAC_C_DOUBLE_POS_ALIGN],[
1071 AC_CACHE_CHECK([if alignment of structs with doubles is based on position],
1072 pac_cv_c_double_pos_align,[
1076 int main( int argc, char *argv[] )
1079 int padding_varies_by_pos = 0;
1080 struct { char a; double b; } char_double;
1081 struct { double b; char a; } double_char;
1082 int extent1, extent2;
1084 extent1 = sizeof(char_double);
1085 extent2 = sizeof(double_char);
1086 if (extent1 != extent2) padding_varies_by_pos = 1;
1088 cf = fopen( "ctest.out", "w" );
1089 if (padding_varies_by_pos) fprintf( cf, "yes\n" );
1090 else fprintf( cf, "no\n" );
1095 pac_cv_c_double_pos_align=`cat ctest.out`,
1096 pac_cv_c_double_pos_align="unknown",
1097 pac_cv_c_double_pos_align="$CROSS_ALIGN_DOUBLE_POS")
1100 if test -z "$pac_cv_c_double_pos_align" ; then
1101 pac_cv_c_double_pos_align="unknown"
1105 dnl Test for odd struct alignment rule that only applies max.
1106 dnl padding when long long int value is at front of type.
1107 dnl Puts result in pac_cv_c_llint_pos_align.
1109 dnl Search for "Power alignment mode" for more details.
1111 dnl Possible values include yes, no, and unknown.
1113 AC_DEFUN([PAC_C_LLINT_POS_ALIGN],[
1114 AC_CACHE_CHECK([if alignment of structs with long long ints is based on position],
1115 pac_cv_c_llint_pos_align,[
1119 int main( int argc, char *argv[] )
1122 int padding_varies_by_pos = 0;
1123 #ifdef HAVE_LONG_LONG_INT
1124 struct { char a; long long int b; } char_llint;
1125 struct { long long int b; char a; } llint_char;
1126 int extent1, extent2;
1128 extent1 = sizeof(char_llint);
1129 extent2 = sizeof(llint_char);
1130 if (extent1 != extent2) padding_varies_by_pos = 1;
1133 cf = fopen( "ctest.out", "w" );
1134 if (padding_varies_by_pos) fprintf( cf, "yes\n" );
1135 else fprintf( cf, "no\n" );
1140 pac_cv_c_llint_pos_align=`cat ctest.out`,
1141 pac_cv_c_llint_pos_align="unknown",
1142 pac_cv_c_llint_pos_align="$CROSS_ALIGN_LLINT_POS")
1145 if test -z "$pac_cv_c_llint_pos_align" ; then
1146 pac_cv_c_llint_pos_align="unknown"
1151 dnl PAC_FUNC_NEEDS_DECL - Set NEEDS_<funcname>_DECL if a declaration is needed
1154 dnl PAC_FUNC_NEEDS_DECL(headerfiles,funcname)
1157 dnl Sets 'NEEDS_<funcname>_DECL' if 'funcname' is not declared by the
1161 dnl Try to compile a program with the function, but passed with an incorrect
1162 dnl calling sequence. If the compilation fails, then the declaration
1163 dnl is provided within the header files. If the compilation succeeds,
1164 dnl the declaration is required.
1166 dnl We use a 'double' as the first argument to try and catch varargs
1167 dnl routines that may use an int or pointer as the first argument.
1169 dnl There is one difficulty - if the compiler has been instructed to
1170 dnl fail on implicitly defined functions, then this test will always
1174 AC_DEFUN([PAC_FUNC_NEEDS_DECL],[
1175 AC_CACHE_CHECK([whether $2 needs a declaration],
1176 pac_cv_func_decl_$2,[
1178 int $2(double, int, double, const char *);],[int a=$2(1.0,27,1.0,"foo");],
1179 pac_cv_func_decl_$2=yes,pac_cv_func_decl_$2=no)])
1180 if test "$pac_cv_func_decl_$2" = "yes" ; then
1181 changequote(<<,>>)dnl
1182 define(<<PAC_FUNC_NAME>>, translit(NEEDS_$2_DECL, [a-z *], [A-Z__]))dnl
1183 changequote([, ])dnl
1184 AC_DEFINE_UNQUOTED(PAC_FUNC_NAME,1,[Define if $2 needs a declaration])
1185 undefine([PAC_FUNC_NAME])
1189 dnl PAC_C_GNU_ATTRIBUTE - See if the GCC __attribute__ specifier is allow.
1190 dnl Use the following
1191 dnl #ifndef HAVE_GCC_ATTRIBUTE
1192 dnl #define __attribute__(a)
1194 dnl If *not*, define __attribute__(a) as null
1196 dnl We start by requiring Gcc. Some other compilers accept __attribute__
1197 dnl but generate warning messages, or have different interpretations
1198 dnl (which seems to make __attribute__ just as bad as #pragma)
1199 dnl For example, the Intel icc compiler accepts __attribute__ and
1200 dnl __attribute__((pure)) but generates warnings for __attribute__((format...))
1202 AC_DEFUN([PAC_C_GNU_ATTRIBUTE],[
1203 AC_REQUIRE([AC_PROG_CC_GNU])
1204 if test "$ac_cv_prog_gcc" = "yes" ; then
1205 AC_CACHE_CHECK([whether __attribute__ allowed],
1206 pac_cv_gnu_attr_pure,[
1207 AC_TRY_COMPILE([int foo(int) __attribute__ ((pure));],[int a;],
1208 pac_cv_gnu_attr_pure=yes,pac_cv_gnu_attr_pure=no)])
1209 AC_CACHE_CHECK([whether __attribute__((format)) allowed],
1210 pac_cv_gnu_attr_format,[
1211 AC_TRY_COMPILE([int foo(char *,...) __attribute__ ((format(printf,1,2)));],[int a;],
1212 pac_cv_gnu_attr_format=yes,pac_cv_gnu_attr_format=no)])
1213 if test "$pac_cv_gnu_attr_pure" = "yes" -a "$pac_cv_gnu_attr_format" = "yes" ; then
1214 AC_DEFINE(HAVE_GCC_ATTRIBUTE,1,[Define if GNU __attribute__ is supported])
1219 dnl Check for a broken install (fails to preserve file modification times,
1220 dnl thus breaking libraries.
1222 dnl Create a library, install it, and then try to link against it.
1223 AC_DEFUN([PAC_PROG_INSTALL_BREAKS_LIBS],[
1224 AC_CACHE_CHECK([whether install breaks libraries],
1225 ac_cv_prog_install_breaks_libs,[
1226 AC_REQUIRE([AC_PROG_RANLIB])
1227 AC_REQUIRE([AC_PROG_INSTALL])
1228 AC_REQUIRE([AC_PROG_CC])
1229 ac_cv_prog_install_breaks_libs=yes
1232 AC_LANG_SOURCE([ int foo(int); int foo(int a){return a;} ])
1234 if ${AR-ar} ${AR_FLAGS-cr} libconftest.a conftest.$OBJEXT >/dev/null 2>&1 ; then
1235 if ${RANLIB-:} libconftest.a >/dev/null 2>&1 ; then
1236 # Anything less than sleep 10, and Mac OS/X (Darwin)
1237 # will claim that install works because ranlib won't complain
1239 libinstall="$INSTALL_DATA"
1240 eval "libinstall=\"$libinstall\""
1241 if ${libinstall} libconftest.a libconftest1.a >/dev/null 2>&1 ; then
1243 LIBS="libconftest1.a"
1246 extern int foo(int);
1247 int main(int argc, char **argv){ return foo(0); }
1250 # Success! Install works
1251 ac_cv_prog_install_breaks_libs=no
1253 # Failure! Does install -p work?
1254 rm -f libconftest1.a
1255 if ${libinstall} -p libconftest.a libconftest1.a >/dev/null 2>&1 ; then
1257 # Success! Install works
1258 ac_cv_prog_install_breaks_libs="no, with -p"
1267 rm -f libconftest*.a
1268 ]) dnl Endof ac_cache_check
1270 if test -z "$RANLIB_AFTER_INSTALL" ; then
1271 RANLIB_AFTER_INSTALL=no
1273 case "$ac_cv_prog_install_breaks_libs" in
1275 RANLIB_AFTER_INSTALL=yes
1278 INSTALL_DATA="$INSTALL_DATA -p"
1285 AC_SUBST(RANLIB_AFTER_INSTALL)
1289 # determine if the compiler defines a symbol containing the function name
1290 # Inspired by checks within the src/mpid/globus/configure.in file in MPICH2
1292 # These tests check not only that the compiler defines some symbol, such
1293 # as __FUNCTION__, but that the symbol correctly names the function.
1296 # HAVE__FUNC__ (if __func__ defined)
1297 # HAVE_CAP__FUNC__ (if __FUNC__ defined)
1298 # HAVE__FUNCTION__ (if __FUNCTION__ defined)
1300 AC_DEFUN([PAC_CC_FUNCTION_NAME_SYMBOL],[
1301 AC_CACHE_CHECK([whether the compiler defines __func__],
1302 pac_cv_have__func__,[
1310 return (strcmp(__func__, "foo") == 0);
1312 int main(int argc, char ** argv)
1314 return (foo() ? 0 : 1);
1317 ], pac_cv_have__func__=yes, pac_cv_have__func__=no,tmp_am_cross=yes)
1318 if test "$tmp_am_cross" = yes ; then
1325 return (strcmp(__func__, "foo") == 0);
1327 int main(int argc, char ** argv)
1329 return (foo() ? 0 : 1);
1332 ], pac_cv_have__func__=yes, pac_cv_have__func__=no)
1336 if test "$pac_cv_have__func__" = "yes" ; then
1337 AC_DEFINE(HAVE__FUNC__,,[define if the compiler defines __func__])
1340 AC_CACHE_CHECK([whether the compiler defines __FUNC__],
1341 pac_cv_have_cap__func__,[
1349 return (strcmp(__FUNC__, "foo") == 0);
1351 int main(int argc, char ** argv)
1353 return (foo() ? 0 : 1);
1356 ], pac_cv_have_cap__func__=yes, pac_cv_have_cap__func__=no,tmp_am_cross=yes)
1357 if test "$tmp_am_cross" = yes ; then
1364 return (strcmp(__FUNC__, "foo") == 0);
1366 int main(int argc, char ** argv)
1368 return (foo() ? 0 : 1);
1371 ], pac_cv_have__func__=yes, pac_cv_have__func__=no)
1375 if test "$pac_cv_have_cap__func__" = "yes" ; then
1376 AC_DEFINE(HAVE_CAP__FUNC__,,[define if the compiler defines __FUNC__])
1379 AC_CACHE_CHECK([whether the compiler sets __FUNCTION__],
1380 pac_cv_have__function__,[
1388 return (strcmp(__FUNCTION__, "foo") == 0);
1390 int main(int argc, char ** argv)
1392 return (foo() ? 0 : 1);
1395 ], pac_cv_have__function__=yes, pac_cv_have__function__=no,tmp_am_cross=yes)
1396 if test "$tmp_am_cross" = yes ; then
1403 return (strcmp(__FUNCTION__, "foo") == 0);
1405 int main(int argc, char ** argv)
1407 return (foo() ? 0 : 1);
1410 ], pac_cv_have__func__=yes, pac_cv_have__func__=no)
1414 if test "$pac_cv_have__function__" = "yes" ; then
1415 AC_DEFINE(HAVE__FUNCTION__,,[define if the compiler defines __FUNCTION__])
1421 dnl Check structure alignment
1422 AC_DEFUN([PAC_STRUCT_ALIGNMENT],[
1423 # Initialize alignment checks
1430 # See if long double exists
1431 AC_TRY_COMPILE(,[long double a;],have_long_double=yes,have_long_double=no)
1433 # Get sizes of regular types
1434 AC_CHECK_SIZEOF(char)
1435 AC_CHECK_SIZEOF(int)
1436 AC_CHECK_SIZEOF(short)
1437 AC_CHECK_SIZEOF(long)
1438 AC_CHECK_SIZEOF(float)
1439 AC_CHECK_SIZEOF(double)
1440 AC_CHECK_SIZEOF(long double)
1442 # char_int comparison
1443 AC_CHECK_SIZEOF(char_int, 0, [typedef struct { char a; int b; } char_int; ])
1444 size=`expr $ac_cv_sizeof_char + $ac_cv_sizeof_int`
1445 extent=$ac_cv_sizeof_char_int
1446 if test "$size" != "$extent" ; then is_packed=0 ; fi
1447 if test "`expr $extent % $ac_cv_sizeof_int`" != "0" ; then is_largest=0 ; fi
1448 if test "`expr $extent % 2`" != "0" ; then is_two=0 ; fi
1449 if test "`expr $extent % 4`" != "0" ; then is_four=0 ; fi
1450 if test "$ac_cv_sizeof_int" = "8" -a "`expr $extent % 8`" != "0" ; then
1454 # char_short comparison
1455 AC_CHECK_SIZEOF(char_short, 0, [typedef struct { char a; short b; } char_short; ])
1456 size=`expr $ac_cv_sizeof_char + $ac_cv_sizeof_short`
1457 extent=$ac_cv_sizeof_char_short
1458 if test "$size" != "$extent" ; then is_packed=0 ; fi
1459 if test "`expr $extent % $ac_cv_sizeof_short`" != "0" ; then is_largest=0 ; fi
1460 if test "`expr $extent % 2`" != "0" ; then is_two=0 ; fi
1461 if test "$ac_cv_sizeof_short" = "4" -a "`expr $extent % 4`" != "0" ; then
1464 if test "$ac_cv_sizeof_short" = "8" -a "`expr $extent % 8`" != "0" ; then
1468 # char_long comparison
1469 AC_CHECK_SIZEOF(char_long, 0, [typedef struct { char a; long b; } char_long; ])
1470 size=`expr $ac_cv_sizeof_char + $ac_cv_sizeof_long`
1471 extent=$ac_cv_sizeof_char_long
1472 if test "$size" != "$extent" ; then is_packed=0 ; fi
1473 if test "`expr $extent % $ac_cv_sizeof_long`" != "0" ; then is_largest=0 ; fi
1474 if test "`expr $extent % 2`" != "0" ; then is_two=0 ; fi
1475 if test "`expr $extent % 4`" != "0" ; then is_four=0 ; fi
1476 if test "$ac_cv_sizeof_long" = "8" -a "`expr $extent % 8`" != "0" ; then
1480 # char_float comparison
1481 AC_CHECK_SIZEOF(char_float, 0, [typedef struct { char a; float b; } char_float; ])
1482 size=`expr $ac_cv_sizeof_char + $ac_cv_sizeof_float`
1483 extent=$ac_cv_sizeof_char_float
1484 if test "$size" != "$extent" ; then is_packed=0 ; fi
1485 if test "`expr $extent % $ac_cv_sizeof_float`" != "0" ; then is_largest=0 ; fi
1486 if test "`expr $extent % 2`" != "0" ; then is_two=0 ; fi
1487 if test "`expr $extent % 4`" != "0" ; then is_four=0 ; fi
1488 if test "$ac_cv_sizeof_float" = "8" -a "`expr $extent % 8`" != "0" ; then
1492 # char_double comparison
1493 AC_CHECK_SIZEOF(char_double, 0, [typedef struct { char a; double b; } char_double; ])
1494 size=`expr $ac_cv_sizeof_char + $ac_cv_sizeof_double`
1495 extent=$ac_cv_sizeof_char_double
1496 if test "$size" != "$extent" ; then is_packed=0 ; fi
1497 if test "`expr $extent % $ac_cv_sizeof_double`" != "0" ; then is_largest=0 ; fi
1498 if test "`expr $extent % 2`" != "0" ; then is_two=0 ; fi
1499 if test "`expr $extent % 4`" != "0" ; then is_four=0 ; fi
1500 if test "$ac_cv_sizeof_double" = "8" -a "`expr $extent % 8`" != "0" ; then
1504 # char_long_double comparison
1505 if test "$have_long_double" = "yes"; then
1506 AC_CHECK_SIZEOF(char_long_double, 0, [
1512 size=`expr $ac_cv_sizeof_char + $ac_cv_sizeof_long_double`
1513 extent=$ac_cv_sizeof_char_long_double
1514 if test "$size" != "$extent" ; then is_packed=0 ; fi
1515 if test "`expr $extent % $ac_cv_sizeof_long_double`" != "0" ; then is_largest=0 ; fi
1516 if test "`expr $extent % 2`" != "0" ; then is_two=0 ; fi
1517 if test "`expr $extent % 4`" != "0" ; then is_four=0 ; fi
1518 if test "$ac_cv_sizeof_long_double" = "8" -a "`expr $extent % 8`" != "0" ; then
1523 # char_int_char comparison
1524 AC_CHECK_SIZEOF(char_int_char, 0, [
1531 size=`expr $ac_cv_sizeof_char + $ac_cv_sizeof_int + $ac_cv_sizeof_char`
1532 extent=$ac_cv_sizeof_char_int_char
1533 if test "$size" != "$extent" ; then is_packed=0 ; fi
1534 if test "`expr $extent % $ac_cv_sizeof_int`" != "0" ; then is_largest=0 ; fi
1535 if test "`expr $extent % 2`" != "0" ; then is_two=0 ; fi
1536 if test "`expr $extent % 4`" != "0" ; then is_four=0 ; fi
1537 if test "$ac_cv_sizeof_int" = "8" -a "`expr $extent % 8`" != "0" ; then
1541 # char_short_char comparison
1542 AC_CHECK_SIZEOF(char_short_char, 0, [
1549 size=`expr $ac_cv_sizeof_char + $ac_cv_sizeof_short + $ac_cv_sizeof_char`
1550 extent=$ac_cv_sizeof_char_short_char
1551 if test "$size" != "$extent" ; then is_packed=0 ; fi
1552 if test "`expr $extent % $ac_cv_sizeof_short`" != "0" ; then is_largest=0 ; fi
1553 if test "`expr $extent % 2`" != "0" ; then is_two=0 ; fi
1554 if test "$ac_cv_sizeof_short" = "4" -a "`expr $extent % 4`" != "0" ; then
1557 if test "$ac_cv_sizeof_short" = "8" -a "`expr $extent % 8`" != "0" ; then
1561 # If aligned mod 8, it will be aligned mod 4
1562 if test $is_eight = 1 ; then is_four=0 ; is_two=0 ; fi
1563 if test $is_four = 1 ; then is_two=0 ; fi
1565 # Largest supersedes 8
1566 if test $is_largest = 1 ; then is_eight=0 ; fi
1568 # Find the alignment
1569 if test "`expr $is_packed + $is_largest + $is_two + $is_four + $is_eight`" = "0" ; then
1570 pac_cv_struct_alignment="unknown"
1571 elif test "`expr $is_packed + $is_largest + $is_two + $is_four + $is_eight`" != "1" ; then
1572 pac_cv_struct_alignment="unknown"
1573 elif test $is_packed = 1 ; then
1574 pac_cv_struct_alignment="packed"
1575 elif test $is_largest = 1 ; then
1576 pac_cv_struct_alignment="largest"
1577 elif test $is_two = 1 ; then
1578 pac_cv_struct_alignment="two"
1579 elif test $is_four = 1 ; then
1580 pac_cv_struct_alignment="four"
1581 elif test $is_eight = 1 ; then
1582 pac_cv_struct_alignment="eight"
1586 dnl PAC_C_MACRO_VA_ARGS
1588 dnl will AC_DEFINE([HAVE_MACRO_VA_ARGS]) if the compiler supports C99 variable
1589 dnl length argument lists in macros (#define foo(...) bar(__VA_ARGS__))
1590 AC_DEFUN([PAC_C_MACRO_VA_ARGS],[
1591 AC_MSG_CHECKING([for variable argument list macro functionality])
1592 AC_LINK_IFELSE([AC_LANG_PROGRAM([
1594 #define conftest_va_arg_macro(...) printf(__VA_ARGS__)
1596 [conftest_va_arg_macro("a test %d", 3);])],
1597 [AC_DEFINE([HAVE_MACRO_VA_ARGS],[1],[Define if C99-style variable argument list macro functionality])
1598 AC_MSG_RESULT([yes])],
1599 [AC_MSG_RESULT([no])])