diff options
-rw-r--r-- | linuxnamespaces/syscalls.py | 16 | ||||
-rw-r--r-- | pyproject.toml | 2 |
2 files changed, 7 insertions, 11 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.""" diff --git a/pyproject.toml b/pyproject.toml index 04d6a5f..ac6be9e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ classifiers = [ "Typing :: Typed", "Programming Language :: Python :: 3", ] -requires-python = ">=3.9" +requires-python = ">=3.10" [project.optional-dependencies] # linuxnamespaces.systemd needs jeepney or dbussy, not both. |