[klibc] Initial implementation of buffered stdio

Initial implementation of buffered stdio.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
[klibc] Correct fdopen()

The middle argument to __fxopen() should be flags, not mode.
Remove an unused variable.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
[klibc] Add ungetc()

Add support for ungetc()

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
[klibc] Saner definition for BUFSIZ

Make BUFSIZ an architecture configurable, and have the default depend
on _KLIBC_MALLOC_CHUNK_SIZE.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
[klibc] Whitespace fix

Whitespace fix in usr/include/klibc/sysconfig.h

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
[klibc] kbuild: fix a compile warning

scripts/basic/fixdep.c: In function ‘traps’:
scripts/basic/fixdep.c:368: warning: dereferencing type-punned pointer will break strict-aliasing rules
scripts/basic/fixdep.c:370: warning: dereferencing type-punned pointer will break strict-aliasing rules

Fix similar to linux-2.6 d067aa741589a9783cc43315119e0f431b4e382c
commit.

Reported-by: Maciej Żenczykowski <maze@google.com>
Signed-off-by: maximilian attems <max@stro.at>
[klibc] kbuild: enable reproducible builds

This adds a new setting: KBUILD_REPRODUCIBLE
If it is non-empty, ar and ranlib will be called in such
a way that timestamps do not affect the build output.
This allows one to get perfectly reproducible builds.

Signed-off-by: Maciej Żenczykowski <maze@google.com>
Signed-off-by: maximilian attems <max@stro.at>
[klibc] fix typo in __static_inline macro definitions

Commit 57c0820992c7b735c7d6283e451b6dac49bf8b05 introduced
and obvious typo - fix it.

Signed-off-by: Maciej Żenczykowski <maze@google.com>
Signed-off-by: maximilian attems <max@stro.at>
[klibc] tests: fcntl close fd

fix ressource leak of fd.

Signed-off-by: maximilian attems <max@stro.at>
[klibc] kinit: ramdisk_load() fix leakage on error path

close respective file descriptor and stream.

Signed-off-by: maximilian attems <max@stro.at>
[klibc] utils: losesetup close fd

fix ressource leakage.

Signed-off-by: maximilian attems <max@stro.at>
[klibc] utils: dd close fds on error pathes

fix several ressource leakages.

Signed-off-by: maximilian attems <max@stro.at>
[klibc] utils: mknod massage

Show usage instead of segfaulting when no args are passed.

0d844078 added typec and assigned value without actually using it.
As variable is properly named just use it in coressponding  switch.

Signed-off-by: maximilian attems <max@stro.at>
[klibc] ipconfig: parse_device nuke unused variable i

gets assigned a value without any further usage.

Signed-off-by: maximilian attems <max@stro.at>
[klibc] cpio: remove useless if before free

Signed-off-by: maximilian attems <max@stro.at>
[klibc] nfsmounf: start_dummy_portmap() close fd on error path

fix ressource leakage.

Signed-off-by: maximilian attems <max@stro.at>
[klibc] cat cleanup ugly ifdefery

no point in carrying those ifdefs along,
just cleanup the code that seems either BSD specific or
can't work on klibc.

Signed-off-by: maximilian attems <max@stro.at>
[klibc] utils: cleanup unused includes

several errno.h for no good reasons.
cleanup losesetup which is not using getopt_long,
thus doesn't need getopt.h included.

Move stdarg.h include up in losesetup to more proper place.

Signed-off-by: maximilian attems <max@stro.at>
[klibc] kinit: cleanup unused includes

Found some unused ctype.h, alloca.h and errno.h.

Signed-off-by: maximilian attems <max@stro.at>
[klibc] tests: cleanup unused includes

Several unused errno.h and a stdarg.h.

Signed-off-by: maximilian attems <max@stro.at>