From 3e27c7f4a74d9b20f5ea6bdb06b74826b22430ae Mon Sep 17 00:00:00 2001 From: Christopher Friedt Date: Thu, 1 Jun 2023 16:55:13 -0400 Subject: [PATCH] posix: eventfd: deprecate non-public EFD macros Deprecate `EFD_IN_USE` and `EFD_FLAGS_SET` as they are not specified as part of any public `eventfd()` API. While those are being deprecated, use `_INTERNAL` variants. Signed-off-by: Christopher Friedt --- include/zephyr/posix/sys/eventfd.h | 4 ++-- lib/posix/eventfd.c | 13 ++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/include/zephyr/posix/sys/eventfd.h b/include/zephyr/posix/sys/eventfd.h index db86a9d54b5..8f1443d7a9a 100644 --- a/include/zephyr/posix/sys/eventfd.h +++ b/include/zephyr/posix/sys/eventfd.h @@ -16,10 +16,10 @@ extern "C" { #endif -#define EFD_IN_USE 0x1 +#define EFD_IN_USE 0x1 __DEPRECATED_MACRO #define EFD_SEMAPHORE 0x2 #define EFD_NONBLOCK O_NONBLOCK -#define EFD_FLAGS_SET (EFD_SEMAPHORE | EFD_NONBLOCK) +#define EFD_FLAGS_SET (EFD_SEMAPHORE | EFD_NONBLOCK) __DEPRECATED_MACRO typedef uint64_t eventfd_t; diff --git a/lib/posix/eventfd.c b/lib/posix/eventfd.c index 57b9b011311..a8cc059cb20 100644 --- a/lib/posix/eventfd.c +++ b/lib/posix/eventfd.c @@ -13,6 +13,9 @@ #include #include +#define EFD_IN_USE_INTERNAL 0x1 +#define EFD_FLAGS_SET_INTERNAL (EFD_SEMAPHORE | EFD_NONBLOCK) + struct eventfd { struct k_spinlock lock; eventfd_t cnt; @@ -28,7 +31,7 @@ static const struct fd_op_vtable eventfd_fd_vtable; static inline bool eventfd_is_in_use(struct eventfd *efd) { - return (efd->flags & EFD_IN_USE) != 0; + return (efd->flags & EFD_IN_USE_INTERNAL) != 0; } static inline bool eventfd_is_semaphore(struct eventfd *efd) @@ -201,7 +204,7 @@ static int eventfd_ioctl_op(void *obj, unsigned int request, va_list args) switch (request) { case F_GETFL: - ret = efd->flags & EFD_FLAGS_SET; + ret = efd->flags & EFD_FLAGS_SET_INTERNAL; break; case F_SETFL: { @@ -209,7 +212,7 @@ static int eventfd_ioctl_op(void *obj, unsigned int request, va_list args) flags = va_arg(args, int); - if (flags & ~EFD_FLAGS_SET) { + if (flags & ~EFD_FLAGS_SET_INTERNAL) { errno = EINVAL; ret = -1; } else { @@ -374,7 +377,7 @@ int eventfd(unsigned int initval, int flags) size_t offset; struct eventfd *efd = NULL; - if (flags & ~EFD_FLAGS_SET) { + if (flags & ~EFD_FLAGS_SET_INTERNAL) { errno = EINVAL; return -1; } @@ -392,7 +395,7 @@ int eventfd(unsigned int initval, int flags) return -1; } - efd->flags = EFD_IN_USE | flags; + efd->flags = EFD_IN_USE_INTERNAL | flags; efd->cnt = initval; z_finalize_fd(fd, efd, &eventfd_fd_vtable);