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. 7 * 8 * See also http://bugs.kde.org/show_bug.cgi?id=160907. 9 */ 10 11 #define _GNU_SOURCE 12 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 #if defined(HAVE_SYS_POLL_H) 24 #include <sys/poll.h> 25 #endif 26 #if defined(HAVE_SYS_SIGNALFD_H) 27 #include <sys/signalfd.h> 28 #endif 29 #include <sys/stat.h> 30 #include <unistd.h> 31 32 int main (void) 33 { 34 #if defined(HAVE_SIGNALFD) && defined(HAVE_EVENTFD) \ 35 && defined(HAVE_EVENTFD_READ) && defined(HAVE_PPOLL) 36 { 37 sigset_t mask; 38 int fd, fd2; 39 eventfd_t ev; 40 struct timespec ts = { .tv_sec = 1, .tv_nsec = 0 }; 41 struct pollfd pfd[2]; 42 43 sigemptyset (&mask); 44 sigaddset (&mask, SIGUSR1); 45 fd = signalfd (-1, &mask, 0); 46 sigaddset (&mask, SIGUSR2); 47 fd = signalfd (fd, &mask, 0); 48 fd2 = eventfd (5, 0); 49 eventfd_read (fd2, &ev); 50 pfd[0].fd = fd; 51 pfd[0].events = POLLIN|POLLOUT; 52 pfd[1].fd = fd2; 53 pfd[1].events = POLLIN|POLLOUT; 54 ppoll (pfd, 2, &ts, &mask); 55 } 56 #endif 57 58 #if defined(HAVE_UTIMENSAT) 59 unlink("/tmp/valgrind-utimensat-test"); 60 close (creat ("/tmp/valgrind-utimensat-test", S_IRUSR | S_IWUSR)); 61 { 62 struct timespec ts2[2] = { [0].tv_sec = 10000000, [1].tv_sec = 20000000 }; 63 utimensat (AT_FDCWD, "/tmp/valgrind-utimensat-test", ts2, 0); 64 } 65 unlink("/tmp/valgrind-utimensat-test"); 66 #endif 67 68 #if defined(HAVE_EPOLL_CREATE) && defined(HAVE_EPOLL_PWAIT) 69 { 70 int fd3; 71 struct epoll_event evs[10]; 72 sigset_t mask; 73 74 sigemptyset (&mask); 75 sigaddset (&mask, SIGUSR1); 76 sigaddset (&mask, SIGUSR2); 77 fd3 = epoll_create (10); 78 epoll_pwait (fd3, evs, 10, 0, &mask); 79 } 80 #endif 81 82 return 0; 83 } 84