The Pedigree Project
0.1
src
modules
subsys
posix
eventfd-syscalls.h
1
/*
2
* Copyright (c) 2026, Pedigree Developers
3
*
4
* Permission to use, copy, modify, and distribute this software for any
5
* purpose with or without fee is hereby granted, provided that the above
6
* copyright notice and this permission notice appear in all copies.
7
*/
8
9
#ifndef EVENTFD_SYSCALLS_H
10
#define EVENTFD_SYSCALLS_H
11
12
#include "pedigree/kernel/Atomic.h"
13
#include "pedigree/kernel/compiler.h"
14
#include "pedigree/kernel/process/ConditionVariable.h"
15
#include "pedigree/kernel/process/Mutex.h"
16
#include "pedigree/kernel/process/Readiness.h"
17
#include "pedigree/kernel/processor/types.h"
18
19
namespace
LinuxEventFd {
20
constexpr
int
Semaphore
= 0x00000001;
21
constexpr
int
NonBlock = 0x00000800;
22
constexpr
int
CloseOnExec = 0x00080000;
23
}
// namespace LinuxEventFd
24
26
class
EXPORTED_PUBLIC
EventFd
final :
public
ReadinessSource
{
27
public
:
28
EventFd
(uint64_t initialValue,
bool
semaphoreMode);
29
~EventFd
()
override
;
30
32
int
readValue(uint64_t& value,
bool
canBlock);
33
35
int
writeValue(uint64_t value,
bool
canBlock);
36
38
ReadyMask queryReady();
39
40
ReadinessGenerations
readinessGenerations
()
override
;
41
43
uint64_t writeGeneration()
const
;
44
46
MUST_USE_RESULT
bool
addDescriptorOwner();
47
void
removeDescriptorOwner();
48
49
private
:
50
EventFd
(
const
EventFd
&) =
delete
;
51
EventFd
& operator=(
const
EventFd
&) =
delete
;
52
53
Mutex
m_Lock;
54
ConditionVariable
m_Readers;
55
ConditionVariable
m_Writers;
56
uint64_t m_Counter;
57
Atomic<uint64_t>
m_WriteGeneration;
58
ReadinessGenerations
m_Generations;
59
size_t
m_DescriptorOwners;
60
bool
m_SemaphoreMode;
61
bool
m_DescriptorAdmissionOpen;
62
};
63
64
int
posix_eventfd(
unsigned
int
initialValue);
65
int
posix_eventfd2(
unsigned
int
initialValue,
int
flags);
66
67
#endif
Atomic
Definition
Atomic.h:35
ConditionVariable
Definition
ConditionVariable.h:35
EventFd
Definition
eventfd-syscalls.h:26
Mutex
Definition
Mutex.h:56
ReadinessSource
Definition
Readiness.h:86
ReadinessSource::readinessGenerations
virtual ReadinessGenerations readinessGenerations()
Definition
Readiness.cc:177
Semaphore
Definition
Semaphore.h:36
MUST_USE_RESULT
#define MUST_USE_RESULT
Definition
system/include/pedigree/kernel/compiler.h:70
ReadinessGenerations
Definition
Readiness.h:31
Generated on Tue Sep 22 2026 06:05:42 for The Pedigree Project by
1.9.8