1 /**
2  * D header file for GNU/Linux.
3  *
4  * License:   $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
5  * Authors:   Nemanja Boric
6  */
7 module core.sys.linux.sys.eventfd;
8 
9 version (linux):
10 extern (C):
11 @nogc:
12 nothrow:
13 
14 version (ARM)     version = ARM_Any;
15 version (AArch64) version = ARM_Any;
16 version (HPPA)    version = HPPA_Any;
17 version (MIPS32)  version = MIPS_Any;
18 version (MIPS64)  version = MIPS_Any;
19 version (PPC)     version = PPC_Any;
20 version (PPC64)   version = PPC_Any;
21 version (RISCV32) version = RISCV_Any;
22 version (RISCV64) version = RISCV_Any;
23 version (S390)    version = IBMZ_Any;
24 version (SPARC)   version = SPARC_Any;
25 version (SPARC64) version = SPARC_Any;
26 version (SystemZ) version = IBMZ_Any;
27 version (X86)     version = X86_Any;
28 version (X86_64)  version = X86_Any;
29 
30 import core.stdc.stdint: uint64_t;
31 
32 /// Type for the event counter
33 alias uint64_t eventfd_t;
34 
35 /* Return file descriptor for generic event channel.  Set initial
36    value to count.  */
37 int eventfd (uint count, int flags);
38 
39 /* Read event counter and possibly wait for events.  */
40 int eventfd_read (int fd, eventfd_t* value);
41 
42 /* Increment event counter.  */
43 int eventfd_write (int fd, eventfd_t value);
44 
45 version (CRuntime_UClibc)
46 {
47     version (MIPS_Any)
48     {
49         enum EFD_SEMAPHORE = 1;
50         enum EFD_CLOEXEC = 0x80000; // octal!02000000
51         enum EFD_NONBLOCK = 0x80; // octal!00000200
52     }
53     else version (SPARC_Any)
54     {
55         enum EFD_SEMAPHORE = 1;
56         enum EFD_CLOEXEC = 0x400000;
57         enum EFD_NONBLOCK = 0x004000;
58     }
59     else
60     {
61         enum EFD_SEMAPHORE = 1;
62         enum EFD_CLOEXEC = 0x80000; // octal!02000000
63         enum EFD_NONBLOCK = 0x800; // octal!00004000
64     }
65 }
66 else version (X86_Any)
67 {
68     enum EFD_SEMAPHORE = 1;
69     enum EFD_CLOEXEC = 0x80000; // octal!2000000
70     enum EFD_NONBLOCK = 0x800; // octal!4000
71 }
72 else version (HPPA_Any)
73 {
74     enum EFD_SEMAPHORE = 1;
75     enum EFD_CLOEXEC = 0x200000; // octal!10000000
76     enum EFD_NONBLOCK = 0x10004; // octal!00200004
77 }
78 else version (MIPS_Any)
79 {
80     enum EFD_SEMAPHORE = 1;
81     enum EFD_CLOEXEC = 0x80000; // octal!2000000
82     enum EFD_NONBLOCK = 0x80; // octal!200
83 }
84 else version (PPC_Any)
85 {
86     enum EFD_SEMAPHORE = 1;
87     enum EFD_CLOEXEC = 0x80000; // octal!2000000
88     enum EFD_NONBLOCK = 0x800; // octal!4000
89 }
90 else version (ARM_Any)
91 {
92     enum EFD_SEMAPHORE = 1;
93     enum EFD_CLOEXEC = 0x80000; // octal!2000000
94     enum EFD_NONBLOCK = 0x800; // octal!4000
95 }
96 else version (RISCV_Any)
97 {
98     enum EFD_SEMAPHORE = 1;
99     enum EFD_CLOEXEC = 0x80000; // octal!2000000
100     enum EFD_NONBLOCK = 0x800; // octal!4000
101 }
102 else version (SPARC_Any)
103 {
104     enum EFD_SEMAPHORE = 1;
105     enum EFD_CLOEXEC = 0x80000; // octal!2000000
106     enum EFD_NONBLOCK = 0x800; // octal!4000
107 }
108 else version (IBMZ_Any)
109 {
110     enum EFD_SEMAPHORE = 1;
111     enum EFD_CLOEXEC = 0x80000; // octal!2000000
112     enum EFD_NONBLOCK = 0x800; // octal!4000
113 }
114 else
115     static assert(0, "unimplemented");