|
From: <sv...@va...> - 2011-09-17 06:29:38
|
Author: bart
Date: 2011-09-17 07:24:49 +0100 (Sat, 17 Sep 2011)
New Revision: 12035
Log:
Make drd/drd_pthread_intercepts.c compile again on Linux systems without usable <linux/futex.h> header
Modified:
trunk/configure.in
trunk/drd/drd_pthread_intercepts.c
Modified: trunk/configure.in
===================================================================
--- trunk/configure.in 2011-09-13 16:00:38 UTC (rev 12034)
+++ trunk/configure.in 2011-09-17 06:24:49 UTC (rev 12035)
@@ -1629,6 +1629,22 @@
sys/types.h \
])
+# Verify whether the <linux/futex.h> header is usable.
+AC_MSG_CHECKING([if <linux/futex.h> is usable])
+
+AC_TRY_COMPILE([
+#include <linux/futex.h>
+], [
+ return FUTEX_WAIT;
+],
+[
+AC_DEFINE([HAVE_USABLE_LINUX_FUTEX_H], 1,
+ [Define to 1 if you have a usable <linux/futex.h> header file.])
+AC_MSG_RESULT([yes])
+], [
+AC_MSG_RESULT([no])
+])
+
#----------------------------------------------------------------------------
# Checks for typedefs, structures, and compiler characteristics.
#----------------------------------------------------------------------------
Modified: trunk/drd/drd_pthread_intercepts.c
===================================================================
--- trunk/drd/drd_pthread_intercepts.c 2011-09-13 16:00:38 UTC (rev 12034)
+++ trunk/drd/drd_pthread_intercepts.c 2011-09-17 06:24:49 UTC (rev 12035)
@@ -56,14 +56,14 @@
#include <stdio.h> /* fprintf() */
#include <stdlib.h> /* malloc(), free() */
#include <unistd.h> /* confstr() */
-#ifdef __linux__
+#include "config.h" /* HAVE_PTHREAD_MUTEX_ADAPTIVE_NP etc. */
+#ifdef HAVE_USABLE_LINUX_FUTEX_H
#include <asm/unistd.h> /* __NR_futex */
#include <linux/futex.h> /* FUTEX_WAIT */
#ifndef FUTEX_PRIVATE_FLAG
#define FUTEX_PRIVATE_FLAG 0
#endif
#endif
-#include "config.h" /* HAVE_PTHREAD_MUTEX_ADAPTIVE_NP etc. */
#include "drd_basics.h" /* DRD_() */
#include "drd_clientreq.h"
#include "pub_tool_redir.h" /* VG_WRAP_FUNCTION_ZZ() */
@@ -194,7 +194,7 @@
int res = ENOSYS;
while (sema->counter == 0) {
-#if defined(__linux__) && defined(__NR_futex)
+#ifdef HAVE_USABLE_LINUX_FUTEX_H
if (syscall(__NR_futex, (UWord)&sema->counter,
FUTEX_WAIT | FUTEX_PRIVATE_FLAG, 0) == 0)
res = 0;
@@ -216,7 +216,7 @@
static void DRD_(sema_up)(DrdSema* sema)
{
sema->counter++;
-#if defined(__linux__) && defined(__NR_futex)
+#ifdef HAVE_USABLE_LINUX_FUTEX_H
syscall(__NR_futex, (UWord)&sema->counter,
FUTEX_WAKE | FUTEX_PRIVATE_FLAG, 1);
#endif
|