diff options
author | Waldemar Brodkorb <wbx@openadk.org> | 2015-12-09 08:05:10 +0100 |
---|---|---|
committer | Waldemar Brodkorb <wbx@openadk.org> | 2015-12-17 20:35:19 +0100 |
commit | 219b69d72e878094f3ce03a9e70719709a9b4c43 (patch) | |
tree | c79c264c6e76d470e88ff57491ba3bf13c8aef46 /libc/stdio/_cs_funcs.c | |
parent | 2e116b2eeea5f47ca26458b1962783baced2784c (diff) |
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 <lly.dev@gmail.com>
Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>
Diffstat (limited to 'libc/stdio/_cs_funcs.c')
-rw-r--r-- | libc/stdio/_cs_funcs.c | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/libc/stdio/_cs_funcs.c b/libc/stdio/_cs_funcs.c index 9df93f227..be416a450 100644 --- a/libc/stdio/_cs_funcs.c +++ b/libc/stdio/_cs_funcs.c @@ -8,46 +8,6 @@ #include "_stdio.h" /**********************************************************************/ -#ifdef __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__ -/**********************************************************************/ - -ssize_t attribute_hidden _cs_read(void *cookie, char *buf, size_t bufsize) -{ - return read(*((int *) cookie), buf, bufsize); -} - -/**********************************************************************/ - -ssize_t attribute_hidden _cs_write(void *cookie, const char *buf, size_t bufsize) -{ - return write(*((int *) cookie), (char *) buf, bufsize); -} - -/**********************************************************************/ - -int attribute_hidden _cs_seek(void *cookie, register __offmax_t *pos, int whence) -{ - __offmax_t res; - -#ifdef __UCLIBC_HAS_LFS__ - res = lseek64(*((int *) cookie), *pos, whence); -#else - res = lseek(*((int *) cookie), *pos, whence); -#endif - - return (res >= 0) ? ((*pos = res), 0) : ((int) res); -} - -/**********************************************************************/ - -int attribute_hidden _cs_close(void *cookie) -{ - return close(*((int *) cookie)); -} - -/**********************************************************************/ -#else -/**********************************************************************/ int attribute_hidden __stdio_seek(FILE *stream, register __offmax_t *pos, int whence) { @@ -63,5 +23,3 @@ int attribute_hidden __stdio_seek(FILE *stream, register __offmax_t *pos, int wh } /**********************************************************************/ -#endif -/**********************************************************************/ |