Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
eventfd.h File Reference
#include <stdint.h>
#include <zephyr/kernel.h>
#include <zephyr/posix/fcntl.h>

Go to the source code of this file.

Macros

#define EFD_IN_USE   0x1 __DEPRECATED_MACRO
 
#define EFD_SEMAPHORE   0x2
 
#define EFD_NONBLOCK   O_NONBLOCK
 
#define EFD_FLAGS_SET   (EFD_SEMAPHORE | EFD_NONBLOCK) __DEPRECATED_MACRO
 

Typedefs

typedef uint64_t eventfd_t
 

Functions

int eventfd (unsigned int initval, int flags)
 Create a file descriptor for event notification.
 
int eventfd_read (int fd, eventfd_t *value)
 Read from an eventfd.
 
int eventfd_write (int fd, eventfd_t value)
 Write to an eventfd.
 

Macro Definition Documentation

◆ EFD_FLAGS_SET

#define EFD_FLAGS_SET   (EFD_SEMAPHORE | EFD_NONBLOCK) __DEPRECATED_MACRO

◆ EFD_IN_USE

#define EFD_IN_USE   0x1 __DEPRECATED_MACRO

◆ EFD_NONBLOCK

#define EFD_NONBLOCK   O_NONBLOCK

◆ EFD_SEMAPHORE

#define EFD_SEMAPHORE   0x2

Typedef Documentation

◆ eventfd_t

Function Documentation

◆ eventfd()

int eventfd ( unsigned int  initval,
int  flags 
)

Create a file descriptor for event notification.

The returned file descriptor can be used with POSIX read/write calls or with the eventfd_read/eventfd_write functions.

It also supports polling and by including an eventfd in a call to poll, it is possible to signal and wake the polling thread by simply writing to the eventfd.

When using read() and write() on an eventfd, the size must always be at least 8 bytes or the operation will fail with EINVAL.

Returns
New eventfd file descriptor on success, -1 on error

◆ eventfd_read()

int eventfd_read ( int  fd,
eventfd_t value 
)

Read from an eventfd.

If call is successful, the value parameter will have the value 1

Parameters
fdFile descriptor
valuePointer for storing the read value
Returns
0 on success, -1 on error

◆ eventfd_write()

int eventfd_write ( int  fd,
eventfd_t  value 
)

Write to an eventfd.

Parameters
fdFile descriptor
valueValue to write
Returns
0 on success, -1 on error