| 1 |
/* COVERAGE: eventfd eventfd2 */ |
| 2 |
|
| 3 |
#define _GNU_SOURCE |
| 4 |
#include <unistd.h> |
| 5 |
#include <sys/syscall.h> |
| 6 |
|
| 7 |
// If SYS_eventfd2 is defined, let's assume that sys/eventfd.h exists |
| 8 |
// and that glibc has a eventfd() wrapper function. |
| 9 |
#ifdef SYS_eventfd2 |
| 10 |
#include <sys/eventfd.h> |
| 11 |
#endif |
| 12 |
|
| 13 |
int main() |
| 14 |
{ |
| 15 |
#ifdef SYS_eventfd2 |
| 16 |
int fd = eventfd(0, 0); |
| 17 |
//staptest// eventfd[2]? (0[[[[, 0x0]]]]?) = NNNN |
| 18 |
|
| 19 |
#ifdef EFD_NONBLOCK |
| 20 |
fd = eventfd(1, EFD_NONBLOCK); |
| 21 |
//staptest// eventfd2 (1, EFD_NONBLOCK) = NNNN |
| 22 |
|
| 23 |
fd = eventfd(2, EFD_CLOEXEC); |
| 24 |
//staptest// eventfd2 (2, EFD_CLOEXEC) = NNNN |
| 25 |
|
| 26 |
fd = eventfd(3, EFD_NONBLOCK|EFD_CLOEXEC); |
| 27 |
//staptest// eventfd2 (3, EFD_NONBLOCK|EFD_CLOEXEC) = NNNN |
| 28 |
#endif |
| 29 |
|
| 30 |
fd = eventfd(-1, 0); |
| 31 |
//staptest// eventfd[2]? (4294967295[[[[, 0x0]]]]?) = NNNN |
| 32 |
|
| 33 |
fd = eventfd(4, -1); |
| 34 |
//staptest// eventfd2 (4, EFD_[^ ]+|XXXX) = -NNNN (EINVAL) |
| 35 |
#endif |
| 36 |
|
| 37 |
// Try to force an eventfd() (as opposed to a eventfd2()) syscall. |
| 38 |
#ifdef SYS_eventfd |
| 39 |
syscall(SYS_eventfd, 5); |
| 40 |
//staptest// eventfd (5) = NNNN |
| 41 |
|
| 42 |
syscall(SYS_eventfd, -1); |
| 43 |
//staptest// eventfd (4294967295) = NNNN |
| 44 |
#endif |
| 45 |
return 0; |
| 46 |
} |