[QUERY] Understanding call flow from stdio to stub syscalls in newlib (nvptx)

sam.edge.newlib@gmx.com sam.edge.newlib@gmx.com
Fri Jun 13 15:29:09 GMT 2025


On 13/06/2025 15:21, Arijit Kumar Das wrote:
> Hi,
> 
> I’m a new contributor to newlib, currently working on modifying the
> stub system calls in
> newlib/libc/machine/nvptx/misc.c as part of my Google Summer of Code
> 2025 project
> under GCC. The goal is to implement a memory-resident filesystem for
> nvptx targets.
> 
> To facilitate this, I’d like to better understand how higher-level
> stdio functions (e.g., fopen())
> resolve down to these low-level syscall stubs like open().
> Specifically, I’m looking for a
> rough call flow or trace of function calls (e.g, fopen() --> open()),
> and any relevant source
> files beyond misc.c that would be helpful for understanding this
> linkage within newlib.
> 
> Any guidance or references would be greatly appreciated.
> 
> Thanks and regards,
> Arijit Kumar Das

The sources for newlib are online-browsable via 
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git and the 
documentation for what is required for each FILE-based call at 
https://sourceware.org/newlib/ although the latter only tells you about 
the latest newlib release whereas your platform may be using an earlier 
one so checking the sources for the release in use can save some 
headaches. (I've implemented the FD-based APIs on newlib routing to 
FatFS, LittleFS & lwIP simultaneously in the past and the web site has 
led me astray sometimes!)

But provided you follow the POSIX specifications for the low level APIs 
(open(), close(), read(), write(), isatty(), lseek(), fstat() at least 
and maybe dirent.h, stat() and unlink()) as closely as you can given the 
limitations of your filesystem then newlib will be happy and you don't 
need to nor should you make assumptions about how exactly newlib uses 
them to implement the higher level APIs.

-- 
Sam Edge
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_0xE6200DE0C92CEC06_and_old_rev.asc
Type: application/pgp-keys
Size: 1140 bytes
Desc: OpenPGP public key
URL: <https://sourceware.org/pipermail/newlib/attachments/20250613/6bb6e9c4/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature.asc
Type: application/pgp-signature
Size: 236 bytes
Desc: OpenPGP digital signature
URL: <https://sourceware.org/pipermail/newlib/attachments/20250613/6bb6e9c4/attachment.sig>


More information about the Newlib mailing list