mirror of
https://github.com/clearlinux/graphene.git
synced 2026-09-06 22:01:29 +00:00
Before PR #554, futex() syscall incorrectly failed if user-supplied timeout expired (also see PR #438). This patch adds test on futex() with timeout.
25 lines
516 B
C
25 lines
516 B
C
#include <unistd.h>
|
|
#include <stdio.h>
|
|
#include <sys/syscall.h>
|
|
#include <linux/futex.h>
|
|
#include <sys/time.h>
|
|
#include <errno.h>
|
|
|
|
int main (int argc, const char** argv) {
|
|
int myfutex = 0;
|
|
int ret;
|
|
|
|
struct timespec t = {
|
|
.tv_sec = 1,
|
|
.tv_nsec = 0
|
|
};
|
|
|
|
puts("invoke futex syscall with 1-second timeout");
|
|
ret = syscall(SYS_futex, &myfutex, FUTEX_WAIT, 0, &t, NULL, 0);
|
|
if (ret == -1 && errno == ETIMEDOUT) {
|
|
puts("futex correctly timed out");
|
|
}
|
|
|
|
return 0;
|
|
}
|