Merge "Restore __futex_wake and __futex_wait for LP32."
This commit is contained in:
commit
d4f37110ce
@ -31,10 +31,12 @@
|
|||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
#include <linux/futex.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
|
#include <sys/syscall.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
@ -199,4 +201,25 @@ extern "C" int vfdprintf(int fd, const char* fmt, va_list ap) {
|
|||||||
return vdprintf(fd, fmt, ap);
|
return vdprintf(fd, fmt, ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int __futex(volatile void* ftx, int op, int value, const struct timespec* timeout) {
|
||||||
|
// Our generated syscall assembler sets errno, but our callers (pthread functions) don't want to.
|
||||||
|
int saved_errno = errno;
|
||||||
|
if (syscall(__NR_futex, ftx, op, value, timeout) == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int result = -errno;
|
||||||
|
errno = saved_errno;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This used to be in <sys/atomics.h>.
|
||||||
|
extern "C" int __futex_wake(volatile void* ftx, int count) {
|
||||||
|
return __futex(ftx, FUTEX_WAKE, count, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
// This used to be in <sys/atomics.h>.
|
||||||
|
extern "C" int __futex_wait(volatile void* ftx, int value, const struct timespec* timeout) {
|
||||||
|
return __futex(ftx, FUTEX_WAIT, value, timeout);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user