1 /*
2  * Copyright (c) 2024, Tenstorrent AI ULC
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include <stdarg.h>
8 #include <stddef.h>
9 #include <stdint.h>
10 
11 #include <zephyr/posix/unistd.h>
12 #include <zephyr/posix/sys/select.h>
13 #include <zephyr/posix/sys/socket.h>
14 #include <zephyr/sys/fdtable.h>
15 
16 /* prototypes for external, not-yet-public, functions in fdtable.c or fs.c */
17 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);
20 
fcntl(int fd,int cmd,...)21 int fcntl(int fd, int cmd, ...)
22 {
23 	int ret;
24 	va_list args;
25 
26 	va_start(args, cmd);
27 	ret = zvfs_fcntl(fd, cmd, args);
28 	va_end(args);
29 
30 	return ret;
31 }
32 #ifdef CONFIG_POSIX_FD_MGMT_ALIAS_FCNTL
33 FUNC_ALIAS(fcntl, _fcntl, int);
34 #endif /* CONFIG_POSIX_FD_MGMT_ALIAS_FCNTL */
35 
ftruncate(int fd,off_t length)36 int ftruncate(int fd, off_t length)
37 {
38 	return zvfs_ftruncate(fd, length);
39 }
40 #ifdef CONFIG_POSIX_FD_MGMT_ALIAS_FTRUNCATE
41 FUNC_ALIAS(ftruncate, _ftruncate, int);
42 #endif /* CONFIG_POSIX_FD_MGMT_ALIAS_FTRUNCATE */
43 
lseek(int fd,off_t offset,int whence)44 off_t lseek(int fd, off_t offset, int whence)
45 {
46 	return zvfs_lseek(fd, offset, whence);
47 }
48 #ifdef CONFIG_POSIX_FD_MGMT_ALIAS_LSEEK
49 FUNC_ALIAS(lseek, _lseek, off_t);
50 #endif /* CONFIG_POSIX_FD_MGMT_ALIAS_LSEEK */
51