summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJérémie Courrèges-Anglas <jca@wxcvbn.org>2014-02-20 02:02:02 +0100
committerJérémie Courrèges-Anglas <jca@wxcvbn.org>2014-02-20 02:02:02 +0100
commit59f798c7c52247c7b3f565f96639d1af34ac70b5 (patch)
tree8360c61dc8c77def27dcbb8283cfd7334d43d9db
parent4bdb7748383f6cc59c397fdce05192e59571de5f (diff)
downloadratpoison-59f798c7c52247c7b3f565f96639d1af34ac70b5.zip
Test for __builtin_prefetch, not for __GNUC__.
* Fixes build with pcc.
-rw-r--r--configure.ac13
-rw-r--r--src/linkedlist.c6
-rw-r--r--src/linkedlist.h7
3 files changed, 17 insertions, 9 deletions
diff --git a/configure.ac b/configure.ac
index bc1aa03..faaa134 100644
--- a/configure.ac
+++ b/configure.ac
@@ -173,6 +173,19 @@ dnl Checks for library functions.
AC_CHECK_FUNCS(getline getopt_long setenv setpgid setpgrp setsid)
AC_CHECK_FUNCS(unsetenv vsnprintf)
+AH_TEMPLATE([HAVE___BUILTIN_PREFETCH],
+ [Define to 1 if your compiler supports the `__builtin_prefetch' function.])
+AC_MSG_CHECKING([for __builtin_prefetch()])
+AC_LINK_IFELSE([AC_LANG_PROGRAM([],
+ [
+ int a = 9;
+ __builtin_prefetch(&a);
+ return 0;
+ ])],
+ [AC_DEFINE([HAVE___BUILTIN_PREFETCH], 1)
+ AC_MSG_RESULT(yes)],
+ [AC_MSG_RESULT(no)])
+
AM_LANGINFO_CODESET
AC_CONFIG_FILES([Makefile doc/Makefile src/Makefile contrib/Makefile])
diff --git a/src/linkedlist.c b/src/linkedlist.c
index ae3d143..adedf8a 100644
--- a/src/linkedlist.c
+++ b/src/linkedlist.c
@@ -24,12 +24,6 @@
#include "linkedlist.h"
-#if __GNUC__ <= 3
-void
-prefetch(const void *x)
-{;}
-#endif
-
/*
* Insert a new entry between two known consecutive entries.
*
diff --git a/src/linkedlist.h b/src/linkedlist.h
index 4434766..42fee3d 100644
--- a/src/linkedlist.h
+++ b/src/linkedlist.h
@@ -76,10 +76,11 @@ void list_add(struct list_head *new, struct list_head *head);
void __list_add(struct list_head *new,
struct list_head *prev,
struct list_head *next);
-#if __GNUC__ > 3
-#define prefetch __builtin_prefetch
+
+#ifdef HAVE___BUILTIN_PREFETCH
+#define prefetch(x) __builtin_prefetch(x)
#else
-void prefetch(const void *x);
+#define prefetch(x) ((void)(x))
#endif
/* Return the last element in the list. */