Line data Source code
1 0 : /*
2 : * Copyright (c) 2020 Tobias Svehagen
3 : *
4 : * SPDX-License-Identifier: Apache-2.0
5 : */
6 :
7 : #ifndef ZEPHYR_INCLUDE_POSIX_SYS_EVENTFD_H_
8 : #define ZEPHYR_INCLUDE_POSIX_SYS_EVENTFD_H_
9 :
10 : #include <zephyr/zvfs/eventfd.h>
11 :
12 : #ifdef __cplusplus
13 : extern "C" {
14 : #endif
15 :
16 0 : #define EFD_SEMAPHORE ZVFS_EFD_SEMAPHORE
17 0 : #define EFD_NONBLOCK ZVFS_EFD_NONBLOCK
18 :
19 0 : typedef zvfs_eventfd_t eventfd_t;
20 :
21 : /**
22 : * @brief Create a file descriptor for event notification
23 : *
24 : * The returned file descriptor can be used with POSIX read/write calls or
25 : * with the eventfd_read/eventfd_write functions.
26 : *
27 : * It also supports polling and by including an eventfd in a call to poll,
28 : * it is possible to signal and wake the polling thread by simply writing to
29 : * the eventfd.
30 : *
31 : * When using read() and write() on an eventfd, the size must always be at
32 : * least 8 bytes or the operation will fail with EINVAL.
33 : *
34 : * @return New eventfd file descriptor on success, -1 on error
35 : */
36 1 : int eventfd(unsigned int initval, int flags);
37 :
38 : /**
39 : * @brief Read from an eventfd
40 : *
41 : * If call is successful, the value parameter will have the value 1
42 : *
43 : * @param fd File descriptor
44 : * @param value Pointer for storing the read value
45 : *
46 : * @return 0 on success, -1 on error
47 : */
48 1 : int eventfd_read(int fd, eventfd_t *value);
49 :
50 : /**
51 : * @brief Write to an eventfd
52 : *
53 : * @param fd File descriptor
54 : * @param value Value to write
55 : *
56 : * @return 0 on success, -1 on error
57 : */
58 1 : int eventfd_write(int fd, eventfd_t value);
59 :
60 : #ifdef __cplusplus
61 : }
62 : #endif
63 :
64 : #endif /* ZEPHYR_INCLUDE_POSIX_SYS_EVENTFD_H_ */
|