| Index: third_party/tcmalloc/chromium/src/base/spinlock_linux-inl.h
|
| ===================================================================
|
| --- third_party/tcmalloc/chromium/src/base/spinlock_linux-inl.h (revision 42483)
|
| +++ third_party/tcmalloc/chromium/src/base/spinlock_linux-inl.h (working copy)
|
| @@ -33,12 +33,22 @@
|
|
|
| #include <sched.h>
|
| #include <time.h>
|
| -#include "base/linux_syscall_support.h"
|
|
|
| #define FUTEX_WAIT 0
|
| #define FUTEX_WAKE 1
|
| #define FUTEX_PRIVATE_FLAG 128
|
|
|
| +// Note: Instead of making direct system calls that are inlined, we rely
|
| +// on the syscall() function in glibc to do the right thing. This
|
| +// is necessary to make the code compatible with the seccomp sandbox,
|
| +// which needs to be able to find and patch all places where system
|
| +// calls are made. Scanning through and patching glibc is fast, but
|
| +// doing so on the entire Chrome binary would be prohibitively
|
| +// expensive.
|
| +// This is a notable change from the upstream version of tcmalloc,
|
| +// which prefers direct system calls in order to improve compatibility
|
| +// with older toolchains and runtime libraries.
|
| +
|
| static bool have_futex;
|
| static int futex_private_flag = FUTEX_PRIVATE_FLAG;
|
|
|
| @@ -49,9 +59,9 @@
|
| // futexes are ints, so we can use them only when
|
| // that's the same size as the lockword_ in SpinLock.
|
| have_futex = (sizeof (Atomic32) == sizeof (int) &&
|
| - sys_futex(&x, FUTEX_WAKE, 1, 0) >= 0);
|
| + syscall(__NR_futex, &x, FUTEX_WAKE, 1, 0) >= 0);
|
| if (have_futex &&
|
| - sys_futex(&x, FUTEX_WAKE | futex_private_flag, 1, 0) < 0) {
|
| + syscall(__NR_futex, &x, FUTEX_WAKE | futex_private_flag, 1, 0) < 0) {
|
| futex_private_flag = 0;
|
| }
|
| }
|
| @@ -67,7 +77,7 @@
|
| tm.tv_nsec = 1000000; // 1ms; really we're trying to sleep for one kernel
|
| // clock tick
|
| while ((value = base::subtle::Acquire_CompareAndSwap(w, 0, 1)) != 0) {
|
| - sys_futex(reinterpret_cast<int *>(const_cast<Atomic32 *>(w)),
|
| + syscall(__NR_futex, reinterpret_cast<int *>(const_cast<Atomic32 *>(w)),
|
| FUTEX_WAIT | futex_private_flag,
|
| value, reinterpret_cast<struct kernel_timespec *>(&tm));
|
| }
|
| @@ -85,7 +95,7 @@
|
|
|
| static void SpinLockWake(volatile Atomic32 *w) {
|
| if (have_futex) {
|
| - sys_futex(reinterpret_cast<int *>(const_cast<Atomic32 *>(w)),
|
| + syscall(__NR_futex, reinterpret_cast<int *>(const_cast<Atomic32 *>(w)),
|
| FUTEX_WAKE | futex_private_flag, 1, 0);
|
| }
|
| }
|
|
|