-
Notifications
You must be signed in to change notification settings - Fork 7.9k
zvfs: improve libc FILE to integer fd abstraction (v3) #96278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
fkokosinski
wants to merge
8
commits into
zephyrproject-rtos:main
Choose a base branch
from
antmicro:82751-fdopen
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or 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
Previously, there was an implicit assumption that Zephyr's internal struct fd_entry * was synonymous with FILE * from the C library. This is generally not the case and aliasing these two distinct types was preventing a fair bit of functionality from Just Working - namely stdio function calls like fgets() and fopen(). The problem count be seen directly when trying to use a function like zvfs_fdopen(). Instead of aliasing the two types, require that all Zephyr C libraries provide 1. FILE *z_libc_file_alloc(int fd, const char *mode) Allocate and populate the required fields of a FILE object 2. int z_libc_file_get_fd(FILE *fp) Convert a FILE* object to an integer file descriptor. For Picolibc and Newlib-based C libraries, these functions set and get the integer file descriptor from a field of the internal FILE object representation. For the minimal C library, these functions convert between array index and struct fd_entry pointers. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Add a testsuite for the POSIX_DEVICE_IO Option Group. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Get testsuite pseudo-working. Zephyr does not yet support doing much with STDIN_FILENO, STDOUT_FILENO, and basically does not support STDERR_FILENO at all. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com> Co-authored-by: Jakub Klimczak <jklimczak@internships.antmicro.com>
c16f5e7
to
5b6996a
Compare
This commit adds a common ZVFS-based implementation of fclose(). Signed-off-by: Jakub Klimczak <jklimczak@internships.antmicro.com> Signed-off-by: Filip Kokosinski <fkokosinski@antmicro.com>
Return a proper FILE pointer for standard streams. Signed-off-by: Jakub Klimczak <jklimczak@internships.antmicro.com> Signed-off-by: Filip Kokosinski <fkokosinski@antmicro.com>
This commit fixes stdin handling when picolibc is used. Signed-off-by: Jakub Klimczak <jklimczak@internships.antmicro.com> Signed-off-by: Filip Kokosinski <fkokosinski@antmicro.com>
Add a test to the POSIX filesystem API suite that checks whether fdopen() returns a valid value. Signed-off-by: Jakub Klimczak <jklimczak@internships.antmicro.com> Signed-off-by: Filip Kokosinski <fkokosinski@antmicro.com>
Expand the test to cover every libc that Zephyr currently integrates. Signed-off-by: Jakub Klimczak <jklimczak@internships.antmicro.com> Signed-off-by: Filip Kokosinski <fkokosinski@antmicro.com>
5b6996a
to
2656691
Compare
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Follow-up to the work in #83386 and #90916.