This patch factors out the portion of __sinit that depends on syscalls
into its own source file, sinit.c. The portion of __sinit that does
not depend on syscalls is left in findfp.c in the function
__sinitnostd. This factorization allows the developer compiling newlib
to modify CHECK_INIT to call __sinitnostd instead of __sinit. The next
step would be to create a new macro, CHECK_INIT_NOSTD, and modify the
functions that do not require the standard streams to be initialized
to call CHECK_INIT_NOSTD instead of CHECK_INIT.
makebuf uses stat to set the buffering to line mode if the stream is a
teletype. In the existing __sinit, this code is armoured in an #ifdef
HAVE_FCNTL. I did the same thing in makebuf to prevent makebuf
depending on stat if HAVE_FCNTL is not defined. Presumably HAVE_STAT
would be a better name, but there's currently no such define used in
newlib.
Is this patch suitable for application? I grant that this
functionality is somewhat of a special need; however, giving newlib
the ability to produce binaries that do not depend on system calls is
a nice feature for embedded systems.
Cheers,
Shaun
2005-12-15 Shaun Jackman <sjackman@gmail.com>
* libc/stdio/Makefile.am (GENERAL_SOURCES): Add sinit.c.
* libc/stdio/findfp.c (std, __sinit): Move this function to sinit.c.
(__sinitnostd): New function.
(__sfp): Call CHECK_INIT instead of __sinit.
* libc/stdio/local.h (__sinitnostd): New function declaration.
* libc/stdio/makebuf.c: Armour the calls to stat in HAVE_FCNTL.
* libc/stdio/sinit.c: New file.