mirror of
https://github.com/Zenithsiz/ftmemsim-valgrind.git
synced 2026-02-03 10:05:29 +00:00
Make drd/drd_pthread_intercepts.c compile again on Linux systems without usable <linux/futex.h> header
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12035
This commit is contained in:
parent
1423416745
commit
83f6f0137f
16
configure.in
16
configure.in
@ -1629,6 +1629,22 @@ AC_CHECK_HEADERS([ \
|
||||
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.
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
@ -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 @@ static void DRD_(sema_down)(DrdSema* sema)
|
||||
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_down)(DrdSema* sema)
|
||||
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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user