Home
last modified time | relevance | path

Searched refs:fd (Results 1 – 25 of 193) sorted by relevance

12345678

/Zephyr-latest/tests/posix/fs/src/
Dtest_fs_open_flags.c16 int fd = 0; in test_file_open_flags() local
22 fd = open(THE_FILE, 0); in test_file_open_flags()
23 if (fd >= 0 || errno != ENOENT) { in test_file_open_flags()
24 TC_PRINT("Expected fail; fd = %d, errno = %d\n", fd, errno); in test_file_open_flags()
25 if (fd >= 0) { in test_file_open_flags()
26 close(fd); in test_file_open_flags()
32 fd = open(THE_FILE, O_RDONLY); in test_file_open_flags()
33 if (fd >= 0 || errno != ENOENT) { in test_file_open_flags()
34 TC_PRINT("Expected fail; fd = %d, errno = %d\n", fd, errno); in test_file_open_flags()
35 if (fd >= 0) { in test_file_open_flags()
[all …]
/Zephyr-latest/lib/os/
Dfdtable.c79 static int z_fd_ref(int fd) in z_fd_ref() argument
81 return atomic_inc(&fdtable[fd].refcount) + 1; in z_fd_ref()
84 static int z_fd_unref(int fd) in z_fd_unref() argument
94 old_rc = atomic_get(&fdtable[fd].refcount); in z_fd_unref()
98 } while (!atomic_cas(&fdtable[fd].refcount, old_rc, old_rc - 1)); in z_fd_unref()
104 fdtable[fd].obj = NULL; in z_fd_unref()
105 fdtable[fd].vtable = NULL; in z_fd_unref()
112 int fd; in _find_fd_entry() local
114 for (fd = 0; fd < ARRAY_SIZE(fdtable); fd++) { in _find_fd_entry()
115 if (!atomic_get(&fdtable[fd].refcount)) { in _find_fd_entry()
[all …]
/Zephyr-latest/tests/arch/common/semihost/src/
Dmain.c16 long read, fd; in ZTEST() local
19 fd = semihost_open(test_file, SEMIHOST_OPEN_WB); in ZTEST()
20 zassert_true(fd > 0, "Bad handle (%d)", fd); in ZTEST()
21 zassert_equal(semihost_flen(fd), 0, "File not empty"); in ZTEST()
24 zassert_equal(semihost_write(fd, w_buffer, sizeof(w_buffer)), 0, "Write failed"); in ZTEST()
25 zassert_equal(semihost_flen(fd), sizeof(w_buffer), "Size not updated"); in ZTEST()
26 zassert_equal(semihost_write(fd, w_buffer, sizeof(w_buffer)), 0, "Write failed"); in ZTEST()
27 zassert_equal(semihost_flen(fd), 2 * sizeof(w_buffer), "Size not updated"); in ZTEST()
30 read = semihost_read(fd, r_buffer, sizeof(r_buffer)); in ZTEST()
34 zassert_equal(semihost_close(fd), 0, "Close failed"); in ZTEST()
[all …]
/Zephyr-latest/subsys/net/lib/lwm2m/
Dlwm2m_rw_senml_json.c302 static int init_object_name_parameters(struct json_out_formatter_data *fd, in init_object_name_parameters() argument
307 if (fd->add_base_name_to_start) { in init_object_name_parameters()
309 ret = snprintk(fd->bn_string, sizeof(fd->bn_string), "/%u/%u/", path->obj_id, in init_object_name_parameters()
317 if (fd->writer_flags & WRITER_RESOURCE_INSTANCE) { in init_object_name_parameters()
318 ret = snprintk(fd->name_string, sizeof(fd->name_string), "%u/%u", path->res_id, in init_object_name_parameters()
321 ret = snprintk(fd->name_string, sizeof(fd->name_string), "%u", path->res_id); in init_object_name_parameters()
334 struct json_out_formatter_data *fd; in put_begin() local
336 fd = engine_get_out_user_data(out); in put_begin()
337 if (!fd) { in put_begin()
347 fd->base_name.level = LWM2M_PATH_LEVEL_NONE; in put_begin()
[all …]
Dlwm2m_rw_json.c193 static int init_object_name_parameters(struct json_out_formatter_data *fd, in init_object_name_parameters() argument
199 if (fd->writer_flags & WRITER_RESOURCE_INSTANCE) { in init_object_name_parameters()
200 ret = snprintk(fd->name_string, sizeof(fd->name_string), "%u/%u", path->res_id, in init_object_name_parameters()
203 ret = snprintk(fd->name_string, sizeof(fd->name_string), "%u", path->res_id); in init_object_name_parameters()
246 static int json_add_separator(struct lwm2m_output_context *out, struct json_out_formatter_data *fd) in json_add_separator() argument
250 if (fd->writer_flags & WRITER_OUTPUT_VALUE) { in json_add_separator()
263 static void json_postprefix(struct json_out_formatter_data *fd) in json_postprefix() argument
265 fd->writer_flags |= WRITER_OUTPUT_VALUE; in json_postprefix()
269 struct json_out_formatter_data *fd, int float_string_length) in json_float_object_write() argument
277 len = json_add_separator(out, fd); in json_float_object_write()
[all …]
Dlwm2m_rw_senml_cbor.c81 #define GET_CBOR_FD_NAME(fd) ((fd)->names[(fd)->name_cnt]) argument
83 #define GET_CBOR_FD_REC(fd) \ argument
84 &((fd)->input.lwm2m_senml_record_m[(fd)->input.lwm2m_senml_record_m_count])
86 #define GET_IN_FD_REC_I(fd, i) &((fd)->dcd.lwm2m_senml_record_m[i]) argument
88 #define CONSUME_CBOR_FD_REC(fd) \ argument
89 &((fd)->input.lwm2m_senml_record_m[(fd)->input.lwm2m_senml_record_m_count++])
97 struct cbor_out_fmt_data *fd = &fdio.o; in setup_out_fmt_data() local
99 (void)memset(fd, 0, sizeof(*fd)); in setup_out_fmt_data()
100 engine_set_out_user_data(&msg->out, fd); in setup_out_fmt_data()
101 fd->name_sz = SENML_MAX_NAME_SIZE; in setup_out_fmt_data()
[all …]
/Zephyr-latest/tests/posix/eventfd/src/
D_main.c9 void reopen(int *fd, int initval, int flags) in reopen() argument
11 zassert_not_null(fd); in reopen()
12 zassert_ok(close(*fd)); in reopen()
13 *fd = eventfd(initval, flags); in reopen()
14 zassert_true(*fd >= 0, "eventfd(%d, %d) failed: %d", initval, flags, errno); in reopen()
17 int is_blocked(int fd, short *event) in is_blocked() argument
22 pfd.fd = fd; in is_blocked()
33 void eventfd_poll_unset_common(int fd) in eventfd_poll_unset_common() argument
40 ret = is_blocked(fd, &event); in eventfd_poll_unset_common()
43 ret = eventfd_write(fd, TESTVAL); in eventfd_poll_unset_common()
[all …]
Dnonblocking.c14 reopen(&fixture->fd, 0, EFD_NONBLOCK); in ZTEST_F()
16 ret = eventfd_read(fixture->fd, &val); in ZTEST_F()
20 ret = eventfd_write(fixture->fd, TESTVAL); in ZTEST_F()
23 ret = eventfd_read(fixture->fd, &val); in ZTEST_F()
27 ret = eventfd_read(fixture->fd, &val); in ZTEST_F()
34 reopen(&fixture->fd, TESTVAL, EFD_NONBLOCK); in ZTEST_F()
35 eventfd_poll_set_common(fixture->fd); in ZTEST_F()
40 reopen(&fixture->fd, 0, EFD_NONBLOCK); in ZTEST_F()
41 eventfd_poll_unset_common(fixture->fd); in ZTEST_F()
49 reopen(&fixture->fd, 0, EFD_NONBLOCK); in ZTEST_F()
[all …]
Dioctl.c22 flags = ioctl(fixture->fd, F_GETFL, 0); in ZTEST_F()
26 ret = is_blocked(fixture->fd, &event); in ZTEST_F()
30 ret = eventfd_write(fixture->fd, 3); in ZTEST_F()
33 ret = eventfd_read(fixture->fd, &val); in ZTEST_F()
39 ret = ioctl(fixture->fd, F_SETFL, O_NONBLOCK); in ZTEST_F()
42 flags = ioctl(fixture->fd, F_GETFL, 0); in ZTEST_F()
46 ret = is_blocked(fixture->fd, &event); in ZTEST_F()
51 ret = eventfd_write(fixture->fd, 19); in ZTEST_F()
54 ret = eventfd_read(fixture->fd, &val); in ZTEST_F()
60 ret = ioctl(fixture->fd, F_SETFL, 0); in ZTEST_F()
[all …]
Dblocking.c14 ret = eventfd_write(fixture->fd, 3); in ZTEST_F()
17 ret = eventfd_write(fixture->fd, 2); in ZTEST_F()
20 ret = eventfd_read(fixture->fd, &val); in ZTEST_F()
25 reopen(&fixture->fd, 0, EFD_SEMAPHORE); in ZTEST_F()
27 ret = eventfd_write(fixture->fd, 3); in ZTEST_F()
30 ret = eventfd_write(fixture->fd, 2); in ZTEST_F()
33 ret = eventfd_read(fixture->fd, &val); in ZTEST_F()
43 ret = eventfd_write(fixture->fd, 0); in ZTEST_F()
44 zassert_equal(ret, 0, "fd == %d", fixture->fd); in ZTEST_F()
47 ret = is_blocked(fixture->fd, &event); in ZTEST_F()
[all …]
/Zephyr-latest/modules/thrift/src/thrift/server/
DTFDServer.cpp36 xport(int fd) : xport(fd, eventfd(0, EFD_SEMAPHORE)) in xport() argument
39 xport(int fd, int efd) : fd(fd), efd(efd) in xport() argument
41 __ASSERT(fd >= 0, "invalid fd %d", fd); in xport()
44 LOG_DBG("created xport with fd %d and efd %d", fd, efd); in xport()
57 .fd = fd, in read_virt()
62 .fd = efd, in read_virt()
74 if (efd == -1 || fd == -1) { in read_virt()
79 LOG_ERR("failed to poll fds %d, %d: %d", fd, efd, errno); in read_virt()
85 LOG_DBG("fd %d is invalid", pfd.fd); in read_virt()
91 r = ::read(fd, buf, len); in read_virt()
[all …]
/Zephyr-latest/arch/common/
Dsemihost.c23 long fd; member
27 long fd; member
31 long fd; member
36 long fd; member
42 long fd; member
73 long semihost_close(long fd) in semihost_close() argument
76 .fd = fd in semihost_close()
82 long semihost_flen(long fd) in semihost_flen() argument
85 .fd = fd in semihost_flen()
91 long semihost_seek(long fd, long offset) in semihost_seek() argument
[all …]
/Zephyr-latest/subsys/net/lib/sockets/
Dsocket_dispatcher.c16 int fd; member
53 int new_fd, fd; in sock_dispatch_socket() local
71 fd = ctx->fd; in sock_dispatch_socket()
72 zvfs_finalize_typed_fd(fd, obj, (const struct fd_op_vtable *)vtable, ZVFS_MODE_IFSOCK); in sock_dispatch_socket()
79 return fd; in sock_dispatch_socket()
142 int fd; in sock_dispatch_read_vmeth() local
146 fd = sock_dispatch_default(obj); in sock_dispatch_read_vmeth()
147 if (fd < 0) { in sock_dispatch_read_vmeth()
151 new_obj = zvfs_get_fd_obj_and_vtable(fd, &vtable, NULL); in sock_dispatch_read_vmeth()
162 int fd; in sock_dispatch_write_vmeth() local
[all …]
/Zephyr-latest/tests/lib/fdtable/src/
Dmain.c27 int fd = zvfs_reserve_fd(); /* function being tested */ in ZTEST() local
29 zassert_true(fd >= 0, "fd < 0"); in ZTEST()
31 zvfs_free_fd(fd); in ZTEST()
38 int fd = zvfs_reserve_fd(); in ZTEST() local
39 zassert_true(fd >= 0, "fd < 0"); in ZTEST()
42 obj = zvfs_get_fd_obj_and_vtable(fd, &vtable, in ZTEST()
47 zvfs_free_fd(fd); in ZTEST()
52 int fd = zvfs_reserve_fd(); in ZTEST() local
53 zassert_true(fd >= 0, "fd < 0"); in ZTEST()
59 int *obj = zvfs_get_fd_obj(fd, vtable, err); /* function being tested */ in ZTEST()
[all …]
/Zephyr-latest/samples/net/sockets/can/src/
Dmain.c48 int fd = POINTER_TO_INT(can_fd); in tx() local
65 ret = send(fd, &sframe, sizeof(sframe), 0); in tx()
77 int fd, ret; in create_socket() local
79 fd = socket(AF_CAN, SOCK_RAW, CAN_RAW); in create_socket()
80 if (fd < 0) { in create_socket()
81 LOG_ERR("Cannot create %s CAN socket (%d)", "2nd", fd); in create_socket()
82 return fd; in create_socket()
89 ret = bind(fd, (struct sockaddr *)&can_addr, sizeof(can_addr)); in create_socket()
92 (void)close(fd); in create_socket()
96 (void)setsockopt(fd, SOL_CAN_RAW, CAN_RAW_FILTER, sfilter, in create_socket()
[all …]
/Zephyr-latest/drivers/can/
Dcan_native_linux_adapt.c48 int fd, opt, ret = -EINVAL; in linux_socketcan_iface_open() local
50 fd = socket(PF_CAN, SOCK_RAW, CAN_RAW); in linux_socketcan_iface_open()
51 if (fd < 0) { in linux_socketcan_iface_open()
60 ret = ioctl(fd, SIOCGIFINDEX, (void *)&ifr); in linux_socketcan_iface_open()
62 close(fd); in linux_socketcan_iface_open()
69 ret = bind(fd, (struct sockaddr *)&addr, sizeof(addr)); in linux_socketcan_iface_open()
71 close(fd); in linux_socketcan_iface_open()
77 ret = setsockopt(fd, SOL_CAN_RAW, CAN_RAW_RECV_OWN_MSGS, &opt, sizeof(opt)); in linux_socketcan_iface_open()
79 close(fd); in linux_socketcan_iface_open()
83 return fd; in linux_socketcan_iface_open()
[all …]
/Zephyr-latest/samples/net/sockets/echo_async_select/src/
Dsocket_echo_select.c22 #define READ(fd, buf, sz) read(fd, buf, sz) argument
23 #define WRITE(fd, buf, sz) write(fd, buf, sz) argument
33 #define READ(fd, buf, sz) recv(fd, buf, sz, 0) argument
34 #define WRITE(fd, buf, sz) send(fd, buf, sz, 0) argument
58 static void setblocking(int fd, bool val) in setblocking() argument
62 fl = fcntl(fd, F_GETFL, 0); in setblocking()
73 res = fcntl(fd, F_SETFL, fl); in setblocking()
79 int pollfds_add(int fd) in pollfds_add() argument
81 FD_SET(fd, &readfds); in pollfds_add()
83 if (fd >= fdnum) { in pollfds_add()
[all …]
/Zephyr-latest/tests/posix/shm/src/
Dmain.c42 int fd[N]; in ZTEST() local
60 fd[0] = shm_open(VALID_SHM_PATH, VALID_FLAGS, VALID_MODE); in ZTEST()
61 zassert_true(fd[0] >= 0, "shm_open(%s, %x, %04o) failed: %d", VALID_SHM_PATH, VALID_FLAGS, in ZTEST()
65 zassert_ok(fstat(fd[0], &st)); in ZTEST()
70 zassert_ok(close(fd[0])); in ZTEST()
77 fd[i] = shm_open(VALID_SHM_PATH, i == 0 ? CREATE_FLAGS : OPEN_FLAGS, VALID_MODE); in ZTEST()
78 zassert_true(fd[i] >= 0, "shm_open(%s, %x, %04o) failed: %d", VALID_SHM_PATH, in ZTEST()
83 zassert_ok(close(fd[i - 1])); in ZTEST()
89 int fd; in ZTEST() local
100 fd = shm_open(VALID_SHM_PATH, VALID_FLAGS, VALID_MODE); in ZTEST()
[all …]
/Zephyr-latest/lib/posix/options/
Ddevice_io.c17 int zvfs_close(int fd);
18 FILE *zvfs_fdopen(int fd, const char *mode);
21 ssize_t zvfs_read(int fd, void *buf, size_t sz, size_t *from_offset);
22 ssize_t zvfs_write(int fd, const void *buf, size_t sz, size_t *from_offset);
24 void FD_CLR(int fd, struct zvfs_fd_set *fdset) in FD_CLR() argument
26 return ZVFS_FD_CLR(fd, fdset); in FD_CLR()
29 int FD_ISSET(int fd, struct zvfs_fd_set *fdset) in FD_ISSET() argument
31 return ZVFS_FD_ISSET(fd, fdset); in FD_ISSET()
34 void FD_SET(int fd, struct zvfs_fd_set *fdset) in FD_SET() argument
36 ZVFS_FD_SET(fd, fdset); in FD_SET()
[all …]
Dfd_mgmt.c17 int zvfs_fcntl(int fd, int cmd, va_list arg);
18 int zvfs_ftruncate(int fd, off_t length);
19 off_t zvfs_lseek(int fd, off_t offset, int whence);
21 int fcntl(int fd, int cmd, ...) in fcntl() argument
27 ret = zvfs_fcntl(fd, cmd, args); in fcntl()
36 int ftruncate(int fd, off_t length) in ftruncate() argument
38 return zvfs_ftruncate(fd, length); in ftruncate()
44 off_t lseek(int fd, off_t offset, int whence) in lseek() argument
46 return zvfs_lseek(fd, offset, whence); in lseek()
Dfsync.c10 int zvfs_fsync(int fd);
12 int fsync(int fd) in fsync() argument
14 return zvfs_fsync(fd); in fsync()
21 int fdatasync(int fd) in fdatasync() argument
23 return fsync(fd); in fdatasync()
/Zephyr-latest/samples/net/sockets/echo_async/src/
Dsocket_echo.c56 static void setblocking(int fd, bool val) in setblocking() argument
60 fl = fcntl(fd, F_GETFL, 0); in setblocking()
71 res = fcntl(fd, F_SETFL, fl); in setblocking()
77 int pollfds_add(int fd) in pollfds_add() argument
84 if (pollfds[i].fd < 0) { in pollfds_add()
93 pollfds[i].fd = fd; in pollfds_add()
99 void pollfds_del(int fd) in pollfds_del() argument
102 if (pollfds[i].fd == fd) { in pollfds_del()
103 pollfds[i].fd = -1; in pollfds_del()
199 int fd = pollfds[i].fd; in main() local
[all …]
/Zephyr-latest/drivers/ethernet/
Deth_native_posix_adapt.c44 int fd, ret = -EINVAL; in eth_iface_create() local
46 fd = open(dev_name, O_RDWR); in eth_iface_create()
47 if (fd < 0) { in eth_iface_create()
58 ret = ioctl(fd, TUNSETIFF, (void *)&ifr); in eth_iface_create()
61 close(fd); in eth_iface_create()
66 return fd; in eth_iface_create()
69 int eth_iface_remove(int fd) in eth_iface_remove() argument
71 return close(fd); in eth_iface_remove()
94 int eth_wait_data(int fd) in eth_wait_data() argument
102 FD_SET(fd, &rset); in eth_wait_data()
[all …]
/Zephyr-latest/scripts/native_simulator/common/src/
Dnsi_host_trampolines.c19 int nsi_host_close(int fd) in nsi_host_close() argument
21 return close(fd); in nsi_host_close()
34 int nsi_host_isatty(int fd) in nsi_host_isatty() argument
36 return isatty(fd); in nsi_host_isatty()
54 long nsi_host_read(int fd, void *buffer, unsigned long size) in nsi_host_read() argument
56 return read(fd, buffer, size); in nsi_host_read()
74 long nsi_host_write(int fd, const void *buffer, unsigned long size) in nsi_host_write() argument
76 return write(fd, buffer, size); in nsi_host_write()
/Zephyr-latest/tests/posix/xsi_streams/src/
Dmain.c14 int fd = -1; in ZTEST() local
15 int ret = putmsg(fd, ctrl, data, 0); in ZTEST()
33 int fd = -1; in ZTEST() local
34 int ret = fattach(fd, path); in ZTEST()
44 int fd = -1; in ZTEST() local
45 int ret = getmsg(fd, ctrl, data, 0); in ZTEST()
55 int fd = -1; in ZTEST() local
56 int ret = getpmsg(fd, ctrl, data, 0, 0); in ZTEST()
64 int fd = -1; in ZTEST() local
65 int ret = isastream(fd); in ZTEST()

12345678