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

fix many things #83368

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

cfriedt
Copy link
Member

@cfriedt cfriedt commented Dec 24, 2024

This is a partial solution to the libc FILE / zvfs fd_entry alias problem (see commit titled "os: fdtable: provide z_libc_file_alloc() abstraction").

I might try to pull this branch in here as well.

main...cfriedt:zephyr:posix-hidden-kconfig-for-thread-safe-functions

We should theoretically be able to implement POSIX_SYSTEM_DATABASE with either POSIX_SYSTEM_DATABASE_R functions or with file locking and readline-type calls.

Before an integer file descriptor may be used, it must be
finalized. This is where most fields are initialized.

Previously, if a file object is was re-used, it could
inherit the offset field of the previously closed file object,
making reading from the beginning of the file impossible
until the offset was manually zero'ed.

The offset should *always* be zero when a file is newly opened.

Signed-off-by: Chris Friedt <[email protected]>
Do not set TC_PROVIDES_POSIX_C_LANG_SUPPORT_R as the default in
lib/posix/options/Kconfig.c_lang_r . TC_PROVIDES options are
only intended to be set by C libraries that implement parts of
the POSIX standard.

Signed-off-by: Chris Friedt <[email protected]>
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 a z_libc_file_alloc() function that
allocates and populates the required fields of a FILE
object.

Zephyr currently only provides the integer file descriptor
to the C library for initializing FILE objects.

Signed-off-by: Chris Friedt <[email protected]>
Provide an implementation for the POSIX_SYSTEM_DATABASE_R
Option Group.

This group is required for all conforming implementations and is
therefore required for PSE51, PSE52, PSE53, PSE54, and all other
possible subprofiles.

Signed-off-by: Chris Friedt <[email protected]>
@cfriedt cfriedt requested a review from ycsin December 24, 2024 17:59
Add a teststuite to exercise the POSIX_SYSTEM_DATABASE_R
Option Group.

Signed-off-by: Chris Friedt <[email protected]>
Provide an implementation for the POSIX_SYSTEM_DATABASE Option
Group.

Signed-off-by: Chris Friedt <[email protected]>
Provide an implementation of the POSIX_FILE_LOCKING Option
Group.

Signed-off-by: Chris Friedt <[email protected]>
The functions associated with the _POSIX_THREAD_SAFE_FUNCTIONS
Option are members of other POSIX Option Groups. Specifically,
POSIX_C_LANG_SUPPORT_R, POSIX_FILE_LOCKING, POSIX_FILE_SYSTEM_R,
and POSIX_SYSTEM_DATABASE_R.

Moreover, _POSIX_THREAD_SAFE_FUNCTIONS is required to be
available with any conforming implementation.

Therefore, it does not make sense to have a Kconfig option to
turn it off or on; it should be enabled or disabled based on
whether the required POSIX Option Groups are active.

Signed-off-by: Chris Friedt <[email protected]>
@cfriedt cfriedt force-pushed the create-posix-system-database-option-group branch from 5ad1363 to 164eac8 Compare December 24, 2024 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant