Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(195)

Unified Diff: third_party/tcmalloc/chromium/src/base/spinlock_linux-inl.h

Issue 1294001: Make the seccomp sandbox compatible with tcmalloc:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sandbox/linux/seccomp/maps.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
}
« no previous file with comments | « sandbox/linux/seccomp/maps.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698