diff options
author | eschnett <eschnett@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2011-06-08 12:53:20 +0000 |
---|---|---|
committer | eschnett <eschnett@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2011-06-08 12:53:20 +0000 |
commit | 0213ad6de45b7ca9a67d7e22a55a1b1aff51c6dd (patch) | |
tree | 6f549813e148befeaa2d9c7b341fad10c5558f4d /lib/make/aclocal.m4 | |
parent | e1e744ad347233881aa0e67263b6a3bd98b3faf3 (diff) |
Improve auto-detection of "restrict" keyword
Update and improve the auto-detection of the "restrict" keyword; add
more test cases to detect more possible failures. Disable testing the
array syntax
void foo (double A[restrict]);
where the "restrict" keyword is given within the square brackets;
instead, one can use the pointer syntax
void foo (double *restrict const A);
which is tested.
Add support for the gcc built-in function "builtin_expect", which
tells the compiler the value that an expression is most likely to
have.
Re-enable the (currently commented out) definitions for attribute(hot)
and attribute(cold).
git-svn-id: http://svn.cactuscode.org/flesh/trunk@4702 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'lib/make/aclocal.m4')
-rw-r--r-- | lib/make/aclocal.m4 | 76 |
1 files changed, 64 insertions, 12 deletions
diff --git a/lib/make/aclocal.m4 b/lib/make/aclocal.m4 index 06c821fa..5b9b6188 100644 --- a/lib/make/aclocal.m4 +++ b/lib/make/aclocal.m4 @@ -377,11 +377,24 @@ AC_DEFUN(CCTK_CHECK_C_RESTRICT, [AC_CACHE_CHECK([for C restrict], cctk_cv_c_restrict, [cctk_cv_c_restrict=no for ac_kw in restrict __restrict__ __restrict; do - AC_TRY_COMPILE(, [ -double * $ac_kw foo; -void bar (void * $ac_kw arr[]); -struct tux { char * $ac_kw arr[3]; }; -void func (void * arr[$ac_kw]); + AC_TRY_COMPILE([ +double * $ac_kw p1; +double * $ac_kw p2[3]; +struct s1 { char * $ac_kw arr; }; +struct s2 { char * $ac_kw arr[3]; }; +void f1 (void * $ac_kw p); +void f2 (void * $ac_kw p[]); +void f3 (void * $ac_kw p[3]); +/* void f4 (void * $ac_kw p[$ac_kw]); */ +/* void f5 (void * $ac_kw p[$ac_kw 3]); */ +void f1 (void * $ac_kw p) { } +void f2 (void * $ac_kw p[]) { } +void f3 (void * $ac_kw p[3]) { } +/* void f4 (void * $ac_kw p[$ac_kw]) { } */ +/* void f5 (void * $ac_kw p[$ac_kw 3]) { } */ +], [ +double * $ac_kw v1; +double * $ac_kw v2[3]; ], [cctk_cv_c_restrict=$ac_kw; break]) done ]) @@ -399,10 +412,24 @@ AC_DEFUN(CCTK_CHECK_CXX_RESTRICT, AC_LANG_SAVE AC_LANG_CPLUSPLUS for ac_kw in restrict __restrict__ __restrict; do - AC_TRY_COMPILE(, [ -double * $ac_kw foo; -void bar (void * $ac_kw arr[]); -struct tux { char * $ac_kw arr[3]; }; + AC_TRY_COMPILE([ +double * $ac_kw p1; +double * $ac_kw p2[3]; +struct s1 { char * $ac_kw arr; }; +struct s2 { char * $ac_kw arr[3]; }; +void f1 (void * $ac_kw p); +void f2 (void * $ac_kw p[]); +void f3 (void * $ac_kw p[3]); +// void f4 (void * $ac_kw p[$ac_kw]); +// void f5 (void * $ac_kw p[$ac_kw 3]); +void f1 (void * $ac_kw p) { } +void f2 (void * $ac_kw p[]) { } +void f3 (void * $ac_kw p[3]) { } +// void f4 (void * $ac_kw p[$ac_kw]) { } +// void f5 (void * $ac_kw p[$ac_kw 3]) { } +], [ +double * $ac_kw v1; +double * $ac_kw v2[3]; ], [cctk_cv_cxx_restrict=$ac_kw; break]) done AC_LANG_RESTORE @@ -635,7 +662,7 @@ AC_DEFUN(CCTK_CXX_MEMBER_ATTRIBUTE_CONST, [cctk_cv_have_cxx_member_attribute_const=no AC_LANG_SAVE AC_LANG_CPLUSPLUS -AC_TRY_COMPILE(, struct { double foo (double) __attribute__((__const__)); };, cctk_cv_have_cxx_member_attribute_const=yes, cctk_cv_have_cxx_member_attribute_const=no) +AC_TRY_COMPILE(, struct bar { double foo (double) __attribute__((__const__)); };, cctk_cv_have_cxx_member_attribute_const=yes, cctk_cv_have_cxx_member_attribute_const=no) AC_LANG_RESTORE ]) if test "$cctk_cv_have_cxx_member_attribute_const" = "yes" ; then @@ -673,7 +700,7 @@ AC_DEFUN(CCTK_CXX_MEMBER_ATTRIBUTE_PURE, [cctk_cv_have_cxx_member_attribute_pure=no AC_LANG_SAVE AC_LANG_CPLUSPLUS -AC_TRY_COMPILE(, struct { double foo (double) __attribute__((__pure__)); };, cctk_cv_have_cxx_member_attribute_pure=yes, cctk_cv_have_cxx_member_attribute_pure=no) +AC_TRY_COMPILE(, struct bar { double foo (double) __attribute__((__pure__)); };, cctk_cv_have_cxx_member_attribute_pure=yes, cctk_cv_have_cxx_member_attribute_pure=no) AC_LANG_RESTORE ]) if test "$cctk_cv_have_cxx_member_attribute_pure" = "yes" ; then @@ -711,7 +738,7 @@ AC_DEFUN(CCTK_CXX_MEMBER_ATTRIBUTE_NOINLINE, [cctk_cv_have_cxx_member_attribute_noinline=no AC_LANG_SAVE AC_LANG_CPLUSPLUS -AC_TRY_COMPILE(, struct { double foo (double) __attribute__((__noinline__)); };, cctk_cv_have_cxx_member_attribute_noinline=yes, cctk_cv_have_cxx_member_attribute_noinline=no) +AC_TRY_COMPILE(, struct bar { double foo (double) __attribute__((__noinline__)); };, cctk_cv_have_cxx_member_attribute_noinline=yes, cctk_cv_have_cxx_member_attribute_noinline=no) AC_LANG_RESTORE ]) if test "$cctk_cv_have_cxx_member_attribute_noinline" = "yes" ; then @@ -818,3 +845,28 @@ if test "$cctk_cv_have_cxx_attribute_hot" = "yes" ; then AC_DEFINE(HAVE_CCTK_CXX_ATTRIBUTE_HOT) fi ]) + + + +AC_DEFUN(CCTK_C_BUILTIN_EXPECT, +[AC_CACHE_CHECK([for C __builtin_expect], cctk_cv_have_c_builtin_expect, +[cctk_cv_have_c_builtin_expect=no +AC_TRY_COMPILE(, __builtin_expect(0,0);, cctk_cv_have_c_builtin_expect=yes, cctk_cv_have_c_builtin_expect=no) +]) +if test "$cctk_cv_have_c_builtin_expect" = "yes" ; then + AC_DEFINE(HAVE_CCTK_C_BUILTIN_EXPECT) +fi +]) + +AC_DEFUN(CCTK_CXX_BUILTIN_EXPECT, +[AC_CACHE_CHECK([for CXX __builtin_expect], cctk_cv_have_cxx_builtin_expect, +[cctk_cv_have_cxx_builtin_expect=no +AC_LANG_SAVE +AC_LANG_CPLUSPLUS +AC_TRY_LINK(, __builtin_expect(0,0);, cctk_cv_have_cxx_builtin_expect=yes, cctk_cv_have_cxx_builtin_expect=no) +AC_LANG_RESTORE +]) +if test "$cctk_cv_have_cxx_builtin_expect" = "yes" ; then + AC_DEFINE(HAVE_CCTK_CXX_BUILTIN_EXPECT) +fi +]) |