From 219b69d72e878094f3ce03a9e70719709a9b4c43 Mon Sep 17 00:00:00 2001 From: Waldemar Brodkorb Date: Wed, 9 Dec 2015 08:05:10 +0100 Subject: libc/stdio: Rework custom streams interface similar to glibc. Save 20 bytes per FILE structure, avoid indirect call for read/write/seek/close operations for normal streams. Additionally, custom streams has fileno = -2 now, like in glibc. bloat-o-meter report (UCLIBC_HAS_GLIBC_CUSTOM_STREAMS=y): function old new delta fopencookie 69 131 +62 ftello64 233 260 +27 fseeko64 298 319 +21 fclose 423 442 +19 .rodata 16696 16708 +12 fileno_unlocked 53 45 -8 __ns_name_pack 859 851 -8 vswscanf 184 144 -40 vdprintf 231 187 -44 vsscanf 210 151 -59 vswprintf 269 201 -68 vsnprintf 249 181 -68 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 5/7 up/down: 141/-295) Total: -154 bytes Signed-off-by: Leonid Lisovskiy Signed-off-by: Waldemar Brodkorb --- libc/stdio/_scanf.c | 27 --------------------------- 1 file changed, 27 deletions(-) (limited to 'libc/stdio/_scanf.c') diff --git a/libc/stdio/_scanf.c b/libc/stdio/_scanf.c index f2a96700b..80e49567f 100644 --- a/libc/stdio/_scanf.c +++ b/libc/stdio/_scanf.c @@ -202,15 +202,6 @@ int vsscanf(const char *sp, const char *fmt, va_list ap) { FILE f; -/* __STDIO_STREAM_RESET_GCS(&f); */ -#ifdef __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__ - f.__cookie = &(f.__filedes); - f.__gcs.read = NULL; - f.__gcs.write = NULL; - f.__gcs.seek = NULL; - f.__gcs.close = NULL; -#endif - f.__filedes = __STDIO_STREAM_FAKE_VSSCANF_FILEDES; f.__modeflags = (__FLAG_NARROW|__FLAG_READONLY|__FLAG_READING); @@ -249,15 +240,6 @@ int vsscanf(const char *sp, const char *fmt, va_list ap) f.bufpos = (unsigned char *) ((void *) sp); f.bufread = f.bufpos + strlen(sp); -/* __STDIO_STREAM_RESET_GCS(&f.f); */ -#ifdef __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__ - f.f.__cookie = &(f.f.__filedes); - f.f.__gcs.read = NULL; - f.f.__gcs.write = NULL; - f.f.__gcs.seek = NULL; - f.f.__gcs.close = NULL; -#endif - f.f.__filedes = __STDIO_STREAM_FAKE_VSSCANF_FILEDES_NB; f.f.__modeflags = (__FLAG_NARROW|__FLAG_READONLY|__FLAG_READING); @@ -383,15 +365,6 @@ int vswscanf(const wchar_t * __restrict str, const wchar_t * __restrict format, __STDIO_STREAM_DISABLE_GETC(&f); __STDIO_STREAM_DISABLE_PUTC(&f); -/* __STDIO_STREAM_RESET_GCS(&f); */ -#ifdef __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__ - f.__cookie = &(f.__filedes); - f.__gcs.read = NULL; - f.__gcs.write = NULL; - f.__gcs.seek = NULL; - f.__gcs.close = NULL; -#endif - f.__filedes = __STDIO_STREAM_FAKE_VSWSCANF_FILEDES; f.__modeflags = (__FLAG_WIDE|__FLAG_READONLY|__FLAG_READING); -- cgit v1.2.3