zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.74k stars 6.56k forks source link

libc: implement `feof()` #66933

Open ycsin opened 10 months ago

ycsin commented 10 months ago

This was originally added as a ticket under POSIX, but feof() is not a POSIX function. It is from C89.

https://en.cppreference.com/w/c/io/feof

The expectation from the POSIX API is that this function is implemented as part of whatever C library is in use.

DanTGL commented 10 hours ago

I would like to work on this.

Any advice?

cfriedt commented 10 hours ago

@DanTGL - we probably need some ZVFS implementation of this (in fdtable.h) and a feof() wrapper in the common libc.

DanTGL commented 9 hours ago

@DanTGL - we probably need some ZVFS implementation of this (in fdtable.h) and a feof() wrapper in the common libc.

Ok, so the feof function in the common libc just calls the ZVFS implementation directly. How should the file descriptor and the end-of-file indicator be handled?

I'm guessing that the end-of-file indicator is stored in the fd_entry?