File: eventfd.c

package info (click to toggle)
systemtap 5.1-5
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 47,964 kB
  • sloc: cpp: 80,838; ansic: 54,757; xml: 49,725; exp: 43,665; sh: 11,527; python: 5,003; perl: 2,252; tcl: 1,312; makefile: 1,006; javascript: 149; lisp: 105; awk: 101; asm: 91; java: 70; sed: 16
file content (46 lines) | stat: -rw-r--r-- 1,104 bytes parent folder | download | duplicates (6)
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;
}