diff options
author | H. Peter Anvin <hpa@zytor.com> | 2004-08-23 18:08:14 +0000 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2004-08-23 18:08:14 +0000 |
commit | 7bc93c4d2238731ba78642e79bd3bd6e1bd7151b (patch) | |
tree | b1e2bfb1a60cf761210c84e7cea70422c0fe15a6 | |
parent | 11f88810b1fc78693d7cce6b5c22e92b99db4d52 (diff) | |
download | klibc-7bc93c4d2238731ba78642e79bd3bd6e1bd7151b.tar.gz |
Use fcntl64() where applicable. The handling of "struct flock" isklibc-0.169
now broken on MIPS, but it was previously broken on all 32-bit arches.
-rw-r--r-- | include/fcntl.h | 23 | ||||
-rw-r--r-- | include/unistd.h | 2 | ||||
-rw-r--r-- | klibc/SYSCALLS.def | 3 | ||||
-rw-r--r-- | klibc/arch/i386/open.S | 3 | ||||
-rw-r--r-- | klibc/arch/i386/sysstub.ph | 9 | ||||
-rw-r--r-- | klibc/include/fcntl.h | 23 | ||||
-rw-r--r-- | klibc/include/unistd.h | 2 |
7 files changed, 61 insertions, 4 deletions
diff --git a/include/fcntl.h b/include/fcntl.h index b9336abdc4a11..a97ae8dcecc65 100644 --- a/include/fcntl.h +++ b/include/fcntl.h @@ -10,6 +10,27 @@ #include <sys/types.h> #include <linux/fcntl.h> +/* This is ugly, but "struct flock" has actually been defined with + a long off_t, so it's really "struct flock64". It just happens + to work. Gag. Barf. + + FIX THIS: It's broken on MIPS. */ + +#ifdef F_GETLK64 +# undef F_GETLK +# define F_GETLK F_GETLK64 +#endif + +#ifdef F_SETLK64 +# undef F_SETLK +# define F_SETLK F_SETLK64 +#endif + +#ifdef F_SETLKW64 +# undef F_SETLKW +# define F_SETLKW F_SETLKW64 +#endif + /* This is defined here as well as in <unistd.h> since old-style code would still include <fcntl.h> when using open(), and open() being a varadic function changes its calling convention on some architectures. */ @@ -17,4 +38,6 @@ __extern int open(const char *, int, ...); #endif +__extern int fcntl(int, int, ...); + #endif /* _FCNTL_H */ diff --git a/include/unistd.h b/include/unistd.h index d80ddbf99e563..aff3c2095f78f 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -93,7 +93,7 @@ __extern ssize_t pwrite(int, void *, size_t, off_t); __extern int dup(int); __extern int dup2(int, int); -__extern int fcntl(int, int, long); +__extern int fcntl(int, int, ...); __extern int ioctl(int, int, void *); __extern int flock(int, int); __extern int fsync(int); diff --git a/klibc/SYSCALLS.def b/klibc/SYSCALLS.def index f458e138490a1..b9c7cacd65987 100644 --- a/klibc/SYSCALLS.def +++ b/klibc/SYSCALLS.def @@ -120,7 +120,8 @@ int close(int) <32> int _llseek::__llseek(int, unsigned long, unsigned long, off_t *, int) int dup(int) int dup2(int, int) -int fcntl(int, int, long) +<i386> int fcntl64@varadic::fcntl(int, int, unsigned long) +<!i386> int fcntl64,fcntl::fcntl(int, int, unsigned long) int ioctl(int, int, void *) int flock(int, int) int _newselect,select::select(int, fd_set *, fd_set *, fd_set *, struct timeval *) diff --git a/klibc/arch/i386/open.S b/klibc/arch/i386/open.S index adc7f1ddad32d..4f492a156621e 100644 --- a/klibc/arch/i386/open.S +++ b/klibc/arch/i386/open.S @@ -2,7 +2,8 @@ * arch/i386/open.S * * Handle the open() system call - oddball due to the varadic - * prototype, which forces the use of the cdecl calling convention. + * prototype, which forces the use of the cdecl calling convention, + * and the need for O_LARGEFILE. */ #include <asm/unistd.h> diff --git a/klibc/arch/i386/sysstub.ph b/klibc/arch/i386/sysstub.ph index a1c8d5ca9b561..eaa818091140e 100644 --- a/klibc/arch/i386/sysstub.ph +++ b/klibc/arch/i386/sysstub.ph @@ -14,6 +14,15 @@ sub make_sysstub($$$$@) { print OUT "\t.type ${fname},\@function\n"; print OUT "\t.globl ${fname}\n"; print OUT "${fname}:\n"; + + if ( $stype eq 'varadic' ) { + print OUT "#ifdef REGPARM\n"; + print OUT "\tmovl 4(%esp),%eax\n"; + print OUT "\tmovl 8(%esp),%edx\n"; + print OUT "\tmovl 12(%esp),%ecx\n"; + print OUT "#endif\n"; + } + print OUT "\tpushl \$__NR_${sname}\n"; print OUT "\tjmp __syscall_common\n"; print OUT "\t.size ${fname},.-${fname}\n"; diff --git a/klibc/include/fcntl.h b/klibc/include/fcntl.h index b9336abdc4a11..a97ae8dcecc65 100644 --- a/klibc/include/fcntl.h +++ b/klibc/include/fcntl.h @@ -10,6 +10,27 @@ #include <sys/types.h> #include <linux/fcntl.h> +/* This is ugly, but "struct flock" has actually been defined with + a long off_t, so it's really "struct flock64". It just happens + to work. Gag. Barf. + + FIX THIS: It's broken on MIPS. */ + +#ifdef F_GETLK64 +# undef F_GETLK +# define F_GETLK F_GETLK64 +#endif + +#ifdef F_SETLK64 +# undef F_SETLK +# define F_SETLK F_SETLK64 +#endif + +#ifdef F_SETLKW64 +# undef F_SETLKW +# define F_SETLKW F_SETLKW64 +#endif + /* This is defined here as well as in <unistd.h> since old-style code would still include <fcntl.h> when using open(), and open() being a varadic function changes its calling convention on some architectures. */ @@ -17,4 +38,6 @@ __extern int open(const char *, int, ...); #endif +__extern int fcntl(int, int, ...); + #endif /* _FCNTL_H */ diff --git a/klibc/include/unistd.h b/klibc/include/unistd.h index d80ddbf99e563..aff3c2095f78f 100644 --- a/klibc/include/unistd.h +++ b/klibc/include/unistd.h @@ -93,7 +93,7 @@ __extern ssize_t pwrite(int, void *, size_t, off_t); __extern int dup(int); __extern int dup2(int, int); -__extern int fcntl(int, int, long); +__extern int fcntl(int, int, ...); __extern int ioctl(int, int, void *); __extern int flock(int, int); __extern int fsync(int); |