From 4a2808a9a6f3bf69563900d462db09bb41176475 Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Thu, 21 Apr 2005 21:03:19 +0000 Subject: [PATCH] check for builtin_expect and define GCC_UNLIKELY Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2188 --- acinclude.m4 | 6 ++++++ configure.in | 11 +++++++++++ src/platform/visualc/config.h | 1 + 3 files changed, 18 insertions(+) diff --git a/acinclude.m4 b/acinclude.m4 index 0392bbea..697e36fa 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -331,6 +331,12 @@ AH_BOTTOM([#if C_HAS_ATTRIBUTE #define GCC_ATTRIBUTE(x) /* attribute not supported */ #endif]) +AH_BOTTOM([#if C_HAS_BUILTIN_EXPECT +#define GCC_UNLIKELY(x) __builtin_expect((x),0) +#else +#define GCC_UNLIKELY(x) (x) +#endif]) + AH_BOTTOM([ typedef double Real64; diff --git a/configure.in b/configure.in index 13ecf042..0a4878bf 100644 --- a/configure.in +++ b/configure.in @@ -58,6 +58,17 @@ AC_MSG_CHECKING(if compiler allows __attribute__) AC_TRY_COMPILE([], [typedef struct { } __attribute__ ((packed)) junk;], [ AC_MSG_RESULT(yes);AC_DEFINE(C_HAS_ATTRIBUTE)],AC_MSG_RESULT(no)) +#Check if the compiler supports __builtin_expect +AH_TEMPLATE([C_HAS_BUILTIN_EXPECT],[Determines if the compilers supports __builtin_expect for branch prediction.]) +AC_MSG_CHECKING(if compiler allows __builtin_expect) +AC_TRY_COMPILE([],[ +int main(int argc,char* argv[]){ +int x=10;if( __builtin_expect ((x==1),0) ) ; +return 0; +} +], [ AC_MSG_RESULT(yes);AC_DEFINE(C_HAS_BUILTIN_EXPECT)],AC_MSG_RESULT(no)) + + AM_PATH_ALSA(0.9.0, AC_DEFINE(HAVE_ALSA,1,[Define to 1 to use ALSA for MIDI]) , : ) #Check for big endian machine, should #define WORD_BIGENDIAN if so diff --git a/src/platform/visualc/config.h b/src/platform/visualc/config.h index d28a4629..f80fb7ce 100644 --- a/src/platform/visualc/config.h +++ b/src/platform/visualc/config.h @@ -52,6 +52,7 @@ #define C_DIRECTSERIAL 1 #define GCC_ATTRIBUTE(x) /* attribute not supported */ +#define GCC_UNLIKELY(x) (x) typedef double Real64; /* The internal types */