Use SYS_futex instead of __NR_futex
Use the C library definition for portability; also test for support instead of unconditionally enabling it.
This commit is contained in:
parent
ce7d8ed8a1
commit
60db5a827f
@ -105,7 +105,7 @@ int
|
||||
Semaphore::signal ()
|
||||
{
|
||||
if (std::atomic_fetch_add_explicit (&_value, 1, std::memory_order_relaxed) < 0) {
|
||||
while (syscall (__NR_futex, &_futex, FUTEX_WAKE_PRIVATE, 1, NULL, NULL, 0) < 1) {
|
||||
while (syscall (SYS_futex, &_futex, FUTEX_WAKE_PRIVATE, 1, NULL, NULL, 0) < 1) {
|
||||
sched_yield();
|
||||
}
|
||||
}
|
||||
@ -116,7 +116,7 @@ int
|
||||
Semaphore::wait ()
|
||||
{
|
||||
if (std::atomic_fetch_sub_explicit (&_value, 1, std::memory_order_relaxed) <= 0) {
|
||||
syscall(__NR_futex, &_futex, FUTEX_WAIT_PRIVATE, _futex, NULL, 0, 0);
|
||||
syscall(SYS_futex, &_futex, FUTEX_WAIT_PRIVATE, _futex, NULL, 0, 0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
12
wscript
12
wscript
@ -1358,8 +1358,16 @@ int main () { __int128 x = 0; return 0; }
|
||||
conf.env['NO_THREADED_WAVEVIEWS'] = True
|
||||
if not opts.no_futex_semaphore:
|
||||
if re.search ("linux", sys.platform) is not None and Options.options.dist_target != 'mingw':
|
||||
conf.define('USE_FUTEX_SEMAPHORE', 1)
|
||||
conf.env['USE_FUTEX_SEMAPHORE'] = True
|
||||
have_sys_futex = conf.check_cc(
|
||||
msg="Checking for 'futex' syscall support",
|
||||
features = 'c',
|
||||
mandatory = False,
|
||||
execute = False,
|
||||
fragment = "#include <sys/syscall.h>\n#include <linux/futex.h>\nint main () { int x = SYS_futex | FUTEX_WAKE_PRIVATE; return 0; }")
|
||||
|
||||
if have_sys_futex:
|
||||
conf.define('USE_FUTEX_SEMAPHORE', 1)
|
||||
conf.env['USE_FUTEX_SEMAPHORE'] = True
|
||||
|
||||
backends = opts.with_backends.split(',')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user