summaryrefslogtreecommitdiff
path: root/linuxnamespaces
diff options
context:
space:
mode:
Diffstat (limited to 'linuxnamespaces')
-rw-r--r--linuxnamespaces/syscalls.py16
1 files changed, 6 insertions, 10 deletions
diff --git a/linuxnamespaces/syscalls.py b/linuxnamespaces/syscalls.py
index 11800c6..9d2b1ba 100644
--- a/linuxnamespaces/syscalls.py
+++ b/linuxnamespaces/syscalls.py
@@ -73,9 +73,9 @@ class EventFDFlags(enum.IntFlag):
"""This value may be supplied as flags to eventfd(2)."""
NONE = 0
- CLOEXEC = 0o2000000
- NONBLOCK = 0o4000
- SEMAPHORE = 0o1
+ CLOEXEC = os.EFD_CLOEXEC
+ NONBLOCK = os.EFD_NONBLOCK
+ SEMAPHORE = os.EFD_SEMAPHORE
ALL_FLAGS = CLOEXEC | NONBLOCK | SEMAPHORE
@@ -438,15 +438,13 @@ class EventFD:
) -> None:
if flags & ~EventFDFlags.ALL_FLAGS:
raise ValueError("invalid flags for eventfd")
- self.fd = call_libc("eventfd", initval, int(flags))
+ self.fd = os.eventfd(initval, int(flags))
def read(self) -> int:
"""Decrease the value of the eventfd using eventfd_read."""
if self.fd < 0:
raise ValueError("attempt to read from closed eventfd")
- cvalue = ctypes.c_ulonglong()
- call_libc("eventfd_read", self.fd, ctypes.byref(cvalue))
- return cvalue.value
+ return os.eventfd_read(self.fd)
def __handle_readable(self, fd: int, fut: asyncio.Future[int]) -> None:
"""Internal helper of aread."""
@@ -481,9 +479,7 @@ class EventFD:
"""Add the given value to the eventfd using eventfd_write."""
if self.fd < 0:
raise ValueError("attempt to read from closed eventfd")
- if value < 0 or (value >> 64):
- raise ValueError("value for eventfd_write out of range")
- call_libc("eventfd_write", self.fd, ctypes.c_ulonglong(value))
+ os.eventfd_write(self.fd, value)
def fileno(self) -> int:
"""Return the underlying file descriptor."""