#1379: Rename autoconfigured CCTK_BUILTIN functions to __builtin --------------------------+------------------------------------------------- Reporter: eschnett | Owner: Type: enhancement | Status: review Priority: major | Milestone: Component: Cactus | Version: development version Resolution: | Keywords: --------------------------+------------------------------------------------- Description changed by eschnett:
Old description:
With autoconf, it is common to define a work-around if a tested feature does not exist. For example, when the "inline" keyword does not exist, then there is a #define that allows code to still use "inline", instead of requiring all code to use CCTK_INLINE. This keeps code more readable.
Cactus tests for various __builtin_* features (__builtin_expect, __builtin_unreachable). If these are not present, it defines CCTK_BUILTIN work-around that one can use instead. I suggest to provide instead the respective __builtin_* functions.
We would keep the current CCTK_BUILTIN_* variants for backward compatibility (at least for some time), but would not define them for new builtins that we autoconfigure.
$ svn diff cctk_Config.h.in Index: cctk_Config.h.in =================================================================== --- cctk_Config.h.in (revision 5021) +++ cctk_Config.h.in (working copy) @@ -376,6 +376,7 @@ # define CCTK_BUILTIN_EXPECT(x,y) __builtin_expect(x,y) #else # define CCTK_BUILTIN_EXPECT(x,y) (x) +# define __builtin_expect(x,y) CCTK_BUILTIN_EXPECT(x,y) #endif
/* Whether __builtin_unreachable exists. */ @@ -384,8 +385,15 @@ # define CCTK_BUILTIN_UNREACHABLE() __builtin_unreachable() #else # define CCTK_BUILTIN_UNREACHABLE() CCTK_Abort(0, 1) +# define __builtin_unreachable() CCTK_BUILTIN_UNREACHABLE() #endif
/* OpenMP collapse clause */ #if (defined CCTK_DISABLE_OMP_COLLAPSE || \ (defined __IBMC__ && defined _ARCH_450D) || \ @@ -585,6 +593,7 @@ # define CCTK_BUILTIN_EXPECT(x,y) __builtin_expect(x,y) #else # define CCTK_BUILTIN_EXPECT(x,y) (x) +# define __builtin_expect(x,y) CCTK_BUILTIN_EXPECT(x,y) #endif
/* Whether __builtin_unreachable exists. */ @@ -593,8 +602,15 @@ # define CCTK_BUILTIN_UNREACHABLE() __builtin_unreachable() #else # define CCTK_BUILTIN_UNREACHABLE() CCTK_Abort(0, 1) +# define __builtin_unreachable() CCTK_BUILTIN_UNREACHABLE() #endif
/* Whether static_assert exists. */ #undef HAVE_CCTK_CXX_STATIC_ASSERT #ifdef HAVE_CCTK_CXX_STATIC_ASSERT
New description:
With autoconf, it is common to define a work-around if a tested feature does not exist. For example, when the "inline" keyword does not exist, then there is a #define that allows code to still use "inline", instead of requiring all code to use CCTK_INLINE. This keeps code more readable.
Cactus tests for various __builtin_* features (__builtin_expect, __builtin_unreachable). If these are not present, it defines CCTK_BUILTIN work-around that one can use instead. I suggest to provide instead the respective __builtin_* functions.
We would keep the current CCTK_BUILTIN_* variants for backward compatibility (at least for some time), but would not define them for new builtins that we autoconfigure.
{{{ $ svn diff cctk_Config.h.in Index: cctk_Config.h.in =================================================================== --- cctk_Config.h.in (revision 5021) +++ cctk_Config.h.in (working copy) @@ -376,6 +376,7 @@ # define CCTK_BUILTIN_EXPECT(x,y) __builtin_expect(x,y) #else # define CCTK_BUILTIN_EXPECT(x,y) (x) +# define __builtin_expect(x,y) CCTK_BUILTIN_EXPECT(x,y) #endif
/* Whether __builtin_unreachable exists. */ @@ -384,8 +385,15 @@ # define CCTK_BUILTIN_UNREACHABLE() __builtin_unreachable() #else # define CCTK_BUILTIN_UNREACHABLE() CCTK_Abort(0, 1) +# define __builtin_unreachable() CCTK_BUILTIN_UNREACHABLE() #endif
/* OpenMP collapse clause */ #if (defined CCTK_DISABLE_OMP_COLLAPSE || \ (defined __IBMC__ && defined _ARCH_450D) || \ @@ -585,6 +593,7 @@ # define CCTK_BUILTIN_EXPECT(x,y) __builtin_expect(x,y) #else # define CCTK_BUILTIN_EXPECT(x,y) (x) +# define __builtin_expect(x,y) CCTK_BUILTIN_EXPECT(x,y) #endif
/* Whether __builtin_unreachable exists. */ @@ -593,8 +602,15 @@ # define CCTK_BUILTIN_UNREACHABLE() __builtin_unreachable() #else # define CCTK_BUILTIN_UNREACHABLE() CCTK_Abort(0, 1) +# define __builtin_unreachable() CCTK_BUILTIN_UNREACHABLE() #endif
/* Whether static_assert exists. */ #undef HAVE_CCTK_CXX_STATIC_ASSERT #ifdef HAVE_CCTK_CXX_STATIC_ASSERT
}}}
--