-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
posix: deprecate POSIX_MAX_FDS and add POSIX_DEVICE_IO
The POSIX_MAX_FDS option does not correspond to any standard POSIX option. It was used to define the size of the file descriptor table, which is by no means exclusively used by POSIX (also net, fs, ...). POSIX_MAX_FDS is being deprecated in order to ensure that Zephyr's POSIX Kconfig variables correspond to those defined in the specification, as of IEEE 1003.1-2017. Namely, POSIX_OPEN_MAX. CONFIG_POSIX_MAX_OPEN_FILES is being deprecated for the same reason. To mitigate any possible layering violations, that option is not user selectable. It tracks the newly added CONFIG_ZVFS_OPEN_MAX option, which is native to Zephyr. With this deprecation, we introduce the following Kconfig options that map directly to standard POSIX Option Groups by simply removing "CONFIG_": * CONFIG_POSIX_DEVICE_IO Similarly, with this deprecation, we introduce the following Kconfig options that map directly to standard POSIX Options by simply removing "CONFIG": * CONFIG_POSIX_OPEN_MAX In order to maintain parity with the current feature set, we introduce the following Kconfig options. * CONFIG_POSIX_DEVICE_IO_ALIAS_CLOSE * CONFIG_POSIX_DEVICE_IO_ALIAS_OPEN * CONFIG_POSIX_DEVICE_IO_ALIAS_READ * CONFIG_POSIX_DEVICE_IO_ALIAS_WRITE Gate open(), close(), read(), and write() via the CONFIG_POSIX_DEVICE_IO Kconfig option and move implementations into device_io.c, to be conformant with the spec. Lastly, stage function names for upcoming ZVFS work, to be completed as part of the LTSv3 Roadmap (e.g. zvfs_open(), ..). Signed-off-by: Chris Friedt <[email protected]>
- Loading branch information
Chris Friedt
committed
May 22, 2024
1 parent
51a4ef8
commit c48f5af
Showing
55 changed files
with
221 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Copyright (c) 2024 Tenstorrent AI ULC | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
menuconfig POSIX_DEVICE_IO | ||
bool "POSIX Device IO" | ||
default y if POSIX_API | ||
select FDTABLE | ||
help | ||
Select 'y' here and Zephyr will provide an implementation of the POSIX_DEVICE_IO Option | ||
Group such as FD_CLR(), FD_ISSET(), FD_SET(), FD_ZERO(), close(), fdopen(), fileno(), open(), | ||
poll(), pread(), pselect(), pwrite(), read(), select(), and write(). | ||
|
||
For more informnation, please see | ||
https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_subprofiles.html | ||
|
||
if POSIX_DEVICE_IO | ||
|
||
# These options are intended to be used for compatibility with external POSIX | ||
# implementations such as those in Newlib or Picolibc. | ||
|
||
config POSIX_DEVICE_IO_ALIAS_CLOSE | ||
bool | ||
help | ||
Select 'y' here and Zephyr will provide an alias for close() as _close(). | ||
|
||
config POSIX_DEVICE_IO_ALIAS_OPEN | ||
bool | ||
help | ||
Select 'y' here and Zephyr will provide an alias for open() as _open(). | ||
|
||
config POSIX_DEVICE_IO_ALIAS_READ | ||
bool | ||
help | ||
Select 'y' here and Zephyr will provide an alias for read() as _read(). | ||
|
||
config POSIX_DEVICE_IO_ALIAS_WRITE | ||
bool | ||
help | ||
Select 'y' here and Zephyr will provide an alias for write() as _write(). | ||
|
||
endif # POSIX_DEVICE_IO |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright (c) 2024, Tenstorrent AI ULC | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <stddef.h> | ||
#include <stdint.h> | ||
|
||
#include <zephyr/posix/poll.h> | ||
#include <zephyr/posix/unistd.h> | ||
#include <zephyr/posix/sys/select.h> | ||
#include <zephyr/posix/sys/socket.h> | ||
|
||
/* prototypes for external, not-yet-public, functions in fdtable.c or fs.c */ | ||
int zvfs_close(int fd); | ||
int zvfs_open(const char *name, int flags); | ||
ssize_t zvfs_read(int fd, void *buf, size_t sz); | ||
ssize_t zvfs_write(int fd, const void *buf, size_t sz); | ||
|
||
int close(int fd) | ||
{ | ||
return zvfs_close(fd); | ||
} | ||
#ifdef CONFIG_POSIX_DEVICE_IO_ALIAS_CLOSE | ||
FUNC_ALIAS(close, _close, int); | ||
#endif /* CONFIG_POSIX_DEVICEIO_ALIAS_CLOSE */ | ||
|
||
int open(const char *name, int flags, ...) | ||
{ | ||
/* FIXME: necessarily need to check for O_CREAT and unpack ... if set */ | ||
return zvfs_open(name, flags); | ||
} | ||
#ifdef CONFIG_POSIX_DEVICE_IO_ALIAS_OPEN | ||
FUNC_ALIAS(open, _open, int); | ||
#endif /* CONFIG_POSIX_DEVICEIO_ALIAS_OPEN */ | ||
|
||
int poll(struct pollfd *fds, int nfds, int timeout) | ||
{ | ||
/* TODO: create zvfs_poll() and dispatch to subsystems based on file type */ | ||
return zsock_poll(fds, nfds, timeout); | ||
} | ||
|
||
ssize_t read(int fd, void *buf, size_t sz) | ||
{ | ||
return zvfs_read(fd, buf, sz); | ||
} | ||
#ifdef CONFIG_POSIX_DEVICE_IO_ALIAS_READ | ||
FUNC_ALIAS(read, _read, ssize_t); | ||
#endif /* CONFIG_POSIX_DEVICEIO_ALIAS_READ */ | ||
|
||
int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout) | ||
{ | ||
/* TODO: create zvfs_select() and dispatch to subsystems based on file type */ | ||
return zsock_select(nfds, readfds, writefds, exceptfds, (struct zsock_timeval *)timeout); | ||
} | ||
|
||
ssize_t write(int fd, const void *buf, size_t sz) | ||
{ | ||
return zvfs_write(fd, buf, sz); | ||
} | ||
#ifdef CONFIG_POSIX_DEVICE_IO_ALIAS_WRITE | ||
FUNC_ALIAS(write, _write, ssize_t); | ||
#endif /* CONFIG_POSIX_DEVICEIO_ALIAS_WRITE */ |
Oops, something went wrong.