Skip to content

Commit 3e27c7f

Browse files
Christopher Friedtnashif
authored andcommitted
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 <[email protected]>
1 parent d370361 commit 3e27c7f

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

include/zephyr/posix/sys/eventfd.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
extern "C" {
1717
#endif
1818

19-
#define EFD_IN_USE 0x1
19+
#define EFD_IN_USE 0x1 __DEPRECATED_MACRO
2020
#define EFD_SEMAPHORE 0x2
2121
#define EFD_NONBLOCK O_NONBLOCK
22-
#define EFD_FLAGS_SET (EFD_SEMAPHORE | EFD_NONBLOCK)
22+
#define EFD_FLAGS_SET (EFD_SEMAPHORE | EFD_NONBLOCK) __DEPRECATED_MACRO
2323

2424
typedef uint64_t eventfd_t;
2525

lib/posix/eventfd.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
#include <zephyr/sys/fdtable.h>
1414
#include <zephyr/sys/math_extras.h>
1515

16+
#define EFD_IN_USE_INTERNAL 0x1
17+
#define EFD_FLAGS_SET_INTERNAL (EFD_SEMAPHORE | EFD_NONBLOCK)
18+
1619
struct eventfd {
1720
struct k_spinlock lock;
1821
eventfd_t cnt;
@@ -28,7 +31,7 @@ static const struct fd_op_vtable eventfd_fd_vtable;
2831

2932
static inline bool eventfd_is_in_use(struct eventfd *efd)
3033
{
31-
return (efd->flags & EFD_IN_USE) != 0;
34+
return (efd->flags & EFD_IN_USE_INTERNAL) != 0;
3235
}
3336

3437
static inline bool eventfd_is_semaphore(struct eventfd *efd)
@@ -201,15 +204,15 @@ static int eventfd_ioctl_op(void *obj, unsigned int request, va_list args)
201204

202205
switch (request) {
203206
case F_GETFL:
204-
ret = efd->flags & EFD_FLAGS_SET;
207+
ret = efd->flags & EFD_FLAGS_SET_INTERNAL;
205208
break;
206209

207210
case F_SETFL: {
208211
int flags;
209212

210213
flags = va_arg(args, int);
211214

212-
if (flags & ~EFD_FLAGS_SET) {
215+
if (flags & ~EFD_FLAGS_SET_INTERNAL) {
213216
errno = EINVAL;
214217
ret = -1;
215218
} else {
@@ -374,7 +377,7 @@ int eventfd(unsigned int initval, int flags)
374377
size_t offset;
375378
struct eventfd *efd = NULL;
376379

377-
if (flags & ~EFD_FLAGS_SET) {
380+
if (flags & ~EFD_FLAGS_SET_INTERNAL) {
378381
errno = EINVAL;
379382
return -1;
380383
}
@@ -392,7 +395,7 @@ int eventfd(unsigned int initval, int flags)
392395
return -1;
393396
}
394397

395-
efd->flags = EFD_IN_USE | flags;
398+
efd->flags = EFD_IN_USE_INTERNAL | flags;
396399
efd->cnt = initval;
397400

398401
z_finalize_fd(fd, efd, &eventfd_fd_vtable);

0 commit comments

Comments
 (0)