aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt9
-rw-r--r--src/config.h.in1
-rw-r--r--src/html/houdini.h10
3 files changed, 16 insertions, 4 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 4b13dd7..691e268 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -93,8 +93,13 @@ install(FILES cmark.h ${CMAKE_CURRENT_BINARY_DIR}/cmark_export.h
DESTINATION include
)
-include (CheckIncludeFile)
-CHECK_INCLUDE_FILE (stdbool.h HAVE_STDBOOL_H)
+# Feature tests
+include(CheckIncludeFile)
+include(CheckCSourceCompiles)
+CHECK_INCLUDE_FILE(stdbool.h HAVE_STDBOOL_H)
+CHECK_C_SOURCE_COMPILES(
+ "int main() { __builtin_expect(0,0); return 0; }"
+ HAVE___BUILTIN_EXPECT)
CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
diff --git a/src/config.h.in b/src/config.h.in
index 2165d03..bd39c4e 100644
--- a/src/config.h.in
+++ b/src/config.h.in
@@ -6,3 +6,4 @@
typedef char bool;
#endif
+#cmakedefine HAVE___BUILTIN_EXPECT
diff --git a/src/html/houdini.h b/src/html/houdini.h
index b8ed0d9..9e1200e 100644
--- a/src/html/houdini.h
+++ b/src/html/houdini.h
@@ -6,10 +6,16 @@ extern "C" {
#endif
#include <stdint.h>
+#include "config.h"
#include "buffer.h"
-#define likely(x) __builtin_expect((x),1)
-#define unlikely(x) __builtin_expect((x),0)
+#ifdef HAVE___BUILTIN_EXPECT
+# define likely(x) __builtin_expect((x),1)
+# define unlikely(x) __builtin_expect((x),0)
+#else
+# define likely(x) (x)
+# define unlikely(x) (x)
+#endif
#ifdef HOUDINI_USE_LOCALE
# define _isxdigit(c) isxdigit(c)