File: eventfd.c

package info (click to toggle)
systemtap 3.1-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 32,860 kB
  • ctags: 12,513
  • sloc: cpp: 58,610; ansic: 58,189; exp: 37,322; sh: 10,633; xml: 7,771; perl: 2,252; python: 2,066; tcl: 1,305; makefile: 969; lisp: 105; java: 100; awk: 94; asm: 91; sed: 16
file content (46 lines) | stat: -rw-r--r-- 1,104 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/* COVERAGE: eventfd eventfd2 */

#define _GNU_SOURCE
#include <unistd.h>
#include <sys/syscall.h>

// If SYS_eventfd2 is defined, let's assume that sys/eventfd.h exists
// and that glibc has a eventfd() wrapper function.
#ifdef SYS_eventfd2
#include <sys/eventfd.h>
#endif

int main()
{
#ifdef SYS_eventfd2
  int fd = eventfd(0, 0);
  //staptest// eventfd[2]? (0[[[[, 0x0]]]]?) = NNNN

#ifdef EFD_NONBLOCK
  fd = eventfd(1, EFD_NONBLOCK);
  //staptest// eventfd2 (1, EFD_NONBLOCK) = NNNN

  fd = eventfd(2, EFD_CLOEXEC);
  //staptest// eventfd2 (2, EFD_CLOEXEC) = NNNN

  fd = eventfd(3, EFD_NONBLOCK|EFD_CLOEXEC);
  //staptest// eventfd2 (3, EFD_NONBLOCK|EFD_CLOEXEC) = NNNN
#endif

  fd = eventfd(-1, 0);
  //staptest// eventfd[2]? (4294967295[[[[, 0x0]]]]?) = NNNN

  fd = eventfd(4, -1);
  //staptest// eventfd2 (4, EFD_[^ ]+|XXXX) = -NNNN (EINVAL)
#endif

  // Try to force an eventfd() (as opposed to a eventfd2()) syscall.
#ifdef SYS_eventfd
  syscall(SYS_eventfd, 5);
  //staptest// eventfd (5) = NNNN

  syscall(SYS_eventfd, -1);
  //staptest// eventfd (4294967295) = NNNN
#endif
  return 0;
}