From 03919b26ed41c31876db41f7cee076ced4513fad Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Tue, 16 Jul 2019 18:31:33 -0400 Subject: [PATCH] use namespace-safe __lseek for __stdio_seek instead of direct syscall this probably saves a few bytes, avoids duplicating the clunky lseek/_llseek syscall convention in two places, and sets the stage for fixing broken seeks on x32 and mipsn32. --- src/include/unistd.h | 1 + src/stdio/__stdio_seek.c | 10 ++-------- src/unistd/lseek.c | 5 +++-- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/include/unistd.h b/src/include/unistd.h index 6deb1bcc..1b4605c7 100644 --- a/src/include/unistd.h +++ b/src/include/unistd.h @@ -9,5 +9,6 @@ hidden int __dup3(int, int, int); hidden int __mkostemps(char *, int, int); hidden int __execvpe(const char *, char *const *, char *const *); hidden int __aio_close(int); +hidden off_t __lseek(int, off_t, int); #endif diff --git a/src/stdio/__stdio_seek.c b/src/stdio/__stdio_seek.c index 13e06a66..326ab9bc 100644 --- a/src/stdio/__stdio_seek.c +++ b/src/stdio/__stdio_seek.c @@ -1,13 +1,7 @@ #include "stdio_impl.h" +#include off_t __stdio_seek(FILE *f, off_t off, int whence) { - off_t ret; -#ifdef SYS__llseek - if (syscall(SYS__llseek, f->fd, off>>32, off, &ret, whence)<0) - ret = -1; -#else - ret = syscall(SYS_lseek, f->fd, off, whence); -#endif - return ret; + return __lseek(f->fd, off, whence); } diff --git a/src/unistd/lseek.c b/src/unistd/lseek.c index bf8cd852..b4984f3e 100644 --- a/src/unistd/lseek.c +++ b/src/unistd/lseek.c @@ -1,7 +1,7 @@ #include #include "syscall.h" -off_t lseek(int fd, off_t offset, int whence) +off_t __lseek(int fd, off_t offset, int whence) { #ifdef SYS__llseek off_t result; @@ -11,4 +11,5 @@ off_t lseek(int fd, off_t offset, int whence) #endif } -weak_alias(lseek, lseek64); +weak_alias(__lseek, lseek); +weak_alias(__lseek, lseek64); -- 2.25.1