Skip to content
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

[WIP][fs] Setup streams of minimal libc to use fdtable for more unified manner. #79397

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

RAJAGOPALAN-GANGADHARAN
Copy link
Contributor

This is a WIP PR, the description will be updated at a later point of time.

To implement file io functions like fopen, fwrite in minimal libc, fs support is needed. To have this support fdtable will be leveraged, as this facilitates the conversion between posix fd and standard files.

For starters, define the standard streams (stdio, stdout) as an fd_entry which has the virtual methods for read and write. This follows the same approach as POSIX DEVICE IO. The std streams will be installed during hook install step which zephyr os calls during application bootstrap. If the file support is not needed then the streams can fall back to integers (We can consider using fd_entry for them as well and have the fd numbers as an object - but it probably uses unnecessary space in code hence opted for simple integers).

Split the vmethods for each streams as each of them will perform different operations.

How can this be used for fopen, fwrite etc? Similar vmethods will be written on top of fs apis.

This PR just aims at showing the concept and get reviewers opinion on this approach, unit tests and proper flags will be defined in a followup revision.

Tested locally using ./scripts/twister -i -T tests/posix -T tests/lib/c_lib -p qemu_x86_64 -p qemu_riscv64 and validated functionality using a simple app that prints hello world.

Signed-off-by: RAJAGOPALAN-GANGADHARAN <[email protected]>

[WIP]Fix warnings treated as errors during twister run

Signed-off-by: RAJAGOPALAN-GANGADHARAN <[email protected]>
@cfriedt
Copy link
Member

cfriedt commented Oct 3, 2024

@RAJAGOPALAN-GANGADHARAN - I would suggest putting this PR into draft mode until you feel that it's ready for review.

@keith-packard
Copy link
Collaborator

Given the stated goals of the minimal C library (having enough stand-alone library bits to test Zephyr core code), do we actually want this?

@RAJAGOPALAN-GANGADHARAN RAJAGOPALAN-GANGADHARAN marked this pull request as draft October 4, 2024 09:46
@RAJAGOPALAN-GANGADHARAN
Copy link
Contributor Author

Given the stated goals of the minimal C library (having enough stand-alone library bits to test Zephyr core code), do we actually want this?

Apologies, I couldn't understand this. The thought process in this pr was to decouple a lot of library specific code from core os (fs in this case), this will facilitate easier implementation of other libc functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Base OS Base OS Library (lib/os) area: C Library C Standard Library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants