11
11
dnl developers notice this case.
12
12
AC_BEFORE([$0],[AC_PROG_CC])
13
13
PAC_PUSH_FLAG([CFLAGS])
14
AC_PROG_CC([icc pgcc xlc xlC pathcc cc gcc clang])
14
AC_PROG_CC([icc pgcc xlc xlC pathcc gcc clang cc])
15
15
PAC_POP_FLAG([CFLAGS])
341
if test "$pac_cv_prog_c_weak_symbols" = "no" ; then
341
if test "$pac_cv_prog_c_weak_symbols" != "no" ; then
344
342
case "$pac_cv_prog_c_weak_symbols" in
345
343
"pragma weak") AC_DEFINE(HAVE_PRAGMA_WEAK,1,[Supports weak pragma])
364
361
# Check if the alias option for weak attributes is allowed
365
362
AC_CACHE_CHECK([whether __attribute__((weak,alias(...))) allowed],
366
363
pac_cv_attr_weak_alias,[
364
PAC_PUSH_FLAG([CFLAGS])
365
# force an error exit if the weak attribute isn't understood
367
367
AC_TRY_COMPILE([int foo(int) __attribute__((weak,alias("__foo")));],[int a;],
368
pac_cv_attr_weak_alias=yes,pac_cv_attr_weak_alias=no)])
368
pac_cv_attr_weak_alias=yes,pac_cv_attr_weak_alias=no)
369
# Restore original CFLAGS
370
PAC_POP_FLAG([CFLAGS])])
371
if test "$pac_cv_attr_weak_alias" = "yes" ; then
372
AC_DEFINE(HAVE_WEAK_ATTRIBUTE,1,[Attribute style weak pragma])
374
if test "$pac_cv_prog_c_weak_symbols" = "no" -a "$pac_cv_attr_weak_alias" = "no" ; then
492
502
# should never be tolerated. This also ensures that we get quick
493
503
# compilation failures rather than later link failures that usually
494
504
# come from a function name typo.
505
# -Wcast-align -- Casting alignment warnings. This is an
506
# important check, but is temporarily disabled, since it is
507
# throwing too many (correct) warnings currently, causing us
508
# to miss other warnings.
509
# -Wshorten-64-to-32 -- Bad type-casting 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.
495
513
# the embedded newlines in this string are safe because we evaluate each
496
514
# argument in the for-loop below and append them to the CFLAGS with a space
497
515
# as the separator instead
498
516
pac_common_strict_flags="
502
519
-Wno-missing-field-initializers
503
520
-Wstrict-prototypes
504
521
-Wmissing-prototypes
1197
1215
dnl headerfiles.
1200
dnl Try to compile a program with the function, but passed with an incorrect
1201
dnl calling sequence. If the compilation fails, then the declaration
1202
dnl is provided within the header files. If the compilation succeeds,
1203
dnl the declaration is required.
1205
dnl We use a 'double' as the first argument to try and catch varargs
1206
dnl routines that may use an int or pointer as the first argument.
1208
dnl There is one difficulty - if the compiler has been instructed to
1209
dnl fail on implicitly defined functions, then this test will always
1218
dnl Attempt to assign library function to function pointer. If the function
1219
dnl is not declared in a header, this will fail. Use a non-static global so
1220
dnl the compiler does not warn about an unused variable.
1222
dnl Simply calling the function is not enough because C89 compilers allow
1223
dnl calls to implicitly-defined functions. Re-declaring a library function
1224
dnl with an incompatible prototype is also not sufficient because some
1225
dnl compilers (notably clang-3.2) only produce a warning in this case.
1213
1228
AC_DEFUN([PAC_FUNC_NEEDS_DECL],[
1214
1229
AC_CACHE_CHECK([whether $2 needs a declaration],
1215
1230
pac_cv_func_decl_$2,[
1216
1231
AC_TRY_COMPILE([$1
1217
int $2(double, int, double, const char *);],[int a=$2(1.0,27,1.0,"foo");],
1218
pac_cv_func_decl_$2=yes,pac_cv_func_decl_$2=no)])
1232
void (*fptr)(void) = (void(*)(void))$2;],[],
1233
pac_cv_func_decl_$2=no,pac_cv_func_decl_$2=yes)])
1219
1234
if test "$pac_cv_func_decl_$2" = "yes" ; then
1220
1235
changequote(<<,>>)dnl
1221
1236
define(<<PAC_FUNC_NAME>>, translit(NEEDS_$2_DECL, [a-z *], [A-Z__]))dnl
1620
1635
pac_cv_struct_alignment="eight"
1624
1639
dnl PAC_C_MACRO_VA_ARGS
1626
1641
dnl will AC_DEFINE([HAVE_MACRO_VA_ARGS]) if the compiler supports C99 variable
1627
1642
dnl length argument lists in macros (#define foo(...) bar(__VA_ARGS__))
1628
1643
AC_DEFUN([PAC_C_MACRO_VA_ARGS],[
1629
1644
AC_MSG_CHECKING([for variable argument list macro functionality])
1630
AC_LINK_IFELSE([AC_LANG_PROGRAM([
1646
# check if the program links correctly
1648
PAC_LINK_IFELSE_LOG([pac_test.log],[AC_LANG_PROGRAM([
1631
1649
#include <stdio.h>
1632
1650
#define conftest_va_arg_macro(...) printf(__VA_ARGS__)
1634
1652
[conftest_va_arg_macro("a test %d", 3);])],
1635
[AC_DEFINE([HAVE_MACRO_VA_ARGS],[1],[Define if C99-style variable argument list macro functionality])
1636
AC_MSG_RESULT([yes])],
1637
[AC_MSG_RESULT([no])])
1653
prog_links=yes,prog_links=no)
1655
# If the program linked OK, make sure there were no warnings
1656
if test "$prog_links" = "yes" -a "`cat pac_test.log`" = "" ; then
1657
AC_DEFINE([HAVE_MACRO_VA_ARGS],[1],[Define if C99-style variable argument list macro functionality])
1658
AC_MSG_RESULT([yes])
1665
# Will AC_DEFINE([HAVE_BUILTIN_EXPECT]) if the compiler supports __builtin_expect.
1666
AC_DEFUN([PAC_C_BUILTIN_EXPECT],[
1667
AC_MSG_CHECKING([if C compiler supports __builtin_expect])
1670
return __builtin_expect(1, 1) ? 1 : 0
1672
have_builtin_expect=yes
1673
AC_MSG_RESULT([yes])
1675
have_builtin_expect=no
1678
if test x$have_builtin_expect = xyes ; then
1679
AC_DEFINE([HAVE_BUILTIN_EXPECT], [1], [Define to 1 if the compiler supports __builtin_expect.])