-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
posix: implement other _POSIX_THREAD_SAFE_FUNCTIONS
#74350
base: main
Are you sure you want to change the base?
posix: implement other _POSIX_THREAD_SAFE_FUNCTIONS
#74350
Conversation
fd80070
to
740c14b
Compare
740c14b
to
f69126e
Compare
f69126e
to
a88e0ba
Compare
#ifdef CONFIG_PICOLIBC | ||
/* Not sure how to do this for picolibc */ | ||
void flockfile(FILE *file); | ||
int ftrylockfile(FILE *file); | ||
void funlockfile(FILE *file); | ||
int putc_unlocked(int c, FILE *file); | ||
int putchar_unlocked(int c); | ||
int getc_unlocked(FILE *stream); | ||
int getchar_unlocked(void); | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@keith-packard do you have any idea on how to approach this?
The stdio.h
that's being included here seems to be https://github.com/zephyrproject-rtos/picolibc/blob/main/newlib/libc/tinystdio/stdio.h, but https://github.com/zephyrproject-rtos/picolibc/blob/main/newlib/libc/stdio/stdio.h has the declaration I need.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the declarations are missing from picolibc for whatever reason, I think this should be ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed them from picolibc as there is no way for any application to use them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like we just need to add these to picolibc. which standard are these from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's in the _POSIX_THREAD_SAFE_FUNCTIONS
option group
https://pubs.opengroup.org/onlinepubs/9699919799/functions/flockfile.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is fine too for the time being. Thanks for adding tests
a88e0ba
to
aa3d548
Compare
aa3d548
to
59d5f21
Compare
9679aaa
to
e8681e8
Compare
Implement file locking functions and added testcase. Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Add a simple implementation for putc_unlocked() & putchar_unlocked(). Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Add stub implementation and test for `getc_unlocked()` & `getchar_unlocked()`. Signed-off-by: Yong Cong Sin <ycsin@meta.com>
e8681e8
to
a206ee6
Compare
int getc_unlocked(FILE *stream) | ||
{ | ||
ARG_UNUSED(stream); | ||
|
||
errno = ENOSYS; | ||
|
||
return EOF; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this one, I would add a zvfs_getc_unlocked()
and just call that.
zvfs_getc_unlocked()
should do some basic error checking but should not incur lock overhead.
E.g. check to see if stream
is a valid pointer with IS_ARRAY_ELEMENT()
, check the read()
vtable method is non-NULL
, etc.
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
Note
Has a commit from #74629
Time-related functions are in #74180.
This PR implements:
flockfile()
ftrylockfile()
funlockfile()
putc_unlocked()
putchar_unlocked()
getc_unlocked()
(stub)getchar_unlocked()
(stub)