Add missing zstd.h to coregrind Makefile.am noinst_HEADERS
[valgrind.git] / memcheck / tests / linux / syscalls-2007.c
blobb91df82a5e75932aec4a4fc94b24b8cd595ab907
1 /**
2 * Test program for some Linux syscalls introduced during 2006 and 2007:
3 * - epoll_pwait() was introduced in the 2.6.19 kernel, released in November
4 * 2006.
5 * - utimensat(), eventfd(), timerfd() and signalfd() were introduced in the
6 * 2.6.22 kernel, released in July 2007.
8 * See also http://bugs.kde.org/show_bug.cgi?id=160907.
9 */
11 #define _GNU_SOURCE
13 #include "../../config.h"
14 #include <fcntl.h>
15 #include <signal.h>
16 #include <stdint.h>
17 #if defined(HAVE_SYS_EPOLL_H)
18 #include <sys/epoll.h>
19 #endif
20 #if defined(HAVE_SYS_EVENTFD_H)
21 #include <sys/eventfd.h>
22 #endif
23 #include <poll.h>
24 #if defined(HAVE_SYS_SIGNALFD_H)
25 #include <sys/signalfd.h>
26 #endif
27 #include <sys/stat.h>
28 #include <unistd.h>
30 int main (void)
32 #if defined(HAVE_SIGNALFD) && defined(HAVE_EVENTFD) \
33 && defined(HAVE_EVENTFD_READ) && defined(HAVE_PPOLL)
35 sigset_t mask;
36 int fd, fd2;
37 eventfd_t ev;
38 struct timespec ts = { .tv_sec = 1, .tv_nsec = 0 };
39 struct pollfd pfd[2];
41 sigemptyset (&mask);
42 sigaddset (&mask, SIGUSR1);
43 fd = signalfd (-1, &mask, 0);
44 sigaddset (&mask, SIGUSR2);
45 fd = signalfd (fd, &mask, 0);
46 fd2 = eventfd (5, 0);
47 eventfd_read (fd2, &ev);
48 pfd[0].fd = fd;
49 pfd[0].events = POLLIN|POLLOUT;
50 pfd[1].fd = fd2;
51 pfd[1].events = POLLIN|POLLOUT;
52 ppoll (pfd, 2, &ts, &mask);
54 #endif
56 #if defined(HAVE_UTIMENSAT)
57 unlink("/tmp/valgrind-utimensat-test");
58 close (creat ("/tmp/valgrind-utimensat-test", S_IRUSR | S_IWUSR));
60 struct timespec ts2[2] = { [0].tv_sec = 10000000, [1].tv_sec = 20000000 };
61 utimensat (AT_FDCWD, "/tmp/valgrind-utimensat-test", ts2, 0);
63 unlink("/tmp/valgrind-utimensat-test");
64 #endif
66 #if defined(HAVE_EPOLL_CREATE) && defined(HAVE_EPOLL_PWAIT)
68 int fd3;
69 struct epoll_event evs[10];
70 sigset_t mask;
72 sigemptyset (&mask);
73 sigaddset (&mask, SIGUSR1);
74 sigaddset (&mask, SIGUSR2);
75 fd3 = epoll_create (10);
76 epoll_pwait (fd3, evs, 10, 0, &mask);
78 #endif
80 #if defined(HAVE_EPOLL_CREATE) && defined(HAVE_EPOLL_PWAIT)
82 int fd3;
83 struct epoll_event evs[10];
85 fd3 = epoll_create (10);
86 /* epoll_pwait can take a NULL sigmask. */
87 epoll_pwait (fd3, evs, 10, 1, NULL);
89 #endif
91 return 0;