The syscall defines only a signed long, but the kernel expects unsigned. No idea if this is intentional or if it breaks anything. I just had to look why gcc complained about pointer to int conversions. diff -p -purN klibc-0.168/klibc/SYSCALLS.def klibc-0.168.fcntl/klibc/SYSCALLS.def --- klibc-0.168/klibc/SYSCALLS.def 2004-08-03 03:04:30.000000000 +0200 +++ klibc-0.168.fcntl/klibc/SYSCALLS.def 2004-08-25 15:32:30.000000000 +0200 @@ -120,7 +120,7 @@ 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) +int 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 *) -- USB is for mice, FireWire is for men! sUse lINUX ag, n?RNBERG
H. Peter Anvin
2004-Aug-25 12:16 UTC
[klibc] Re: [PATCH] fcntl takes unsigned long as third arg
Olaf Hering wrote:> The syscall defines only a signed long, but the kernel expects unsigned. > No idea if this is intentional or if it breaks anything. I just had to > look why gcc complained about pointer to int conversions. > > diff -p -purN klibc-0.168/klibc/SYSCALLS.def klibc-0.168.fcntl/klibc/SYSCALLS.def > --- klibc-0.168/klibc/SYSCALLS.def 2004-08-03 03:04:30.000000000 +0200 > +++ klibc-0.168.fcntl/klibc/SYSCALLS.def 2004-08-25 15:32:30.000000000 +0200 > @@ -120,7 +120,7 @@ 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) > +int 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 *) >Hm. POSIX wants signed long; glibc has int fcntl(int, int, ...), since it needs to take either a signed long or a struct flock. Probably we need to do something similar to the hack we did for open(2). -hpa
H. Peter Anvin
2004-Aug-25 12:48 UTC
[klibc] Re: [PATCH] fcntl takes unsigned long as third arg
Olaf Hering wrote:> The syscall defines only a signed long, but the kernel expects unsigned. > No idea if this is intentional or if it breaks anything. I just had to > look why gcc complained about pointer to int conversions. > > diff -p -purN klibc-0.168/klibc/SYSCALLS.def klibc-0.168.fcntl/klibc/SYSCALLS.def > --- klibc-0.168/klibc/SYSCALLS.def 2004-08-03 03:04:30.000000000 +0200 > +++ klibc-0.168.fcntl/klibc/SYSCALLS.def 2004-08-25 15:32:30.000000000 +0200 > @@ -120,7 +120,7 @@ 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) > +int 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 *)Bleah. fcntl() is a can of worms. Not only is it varadic, but it has a whole different set of operations for "struct flock64". I really hate multiplexed system calls. I *really, really* hate multiplexed API calls. -hpa
Dave Dodge
2004-Aug-26 11:53 UTC
[klibc] Re: [PATCH] fcntl takes unsigned long as third arg
On Wed, Aug 25, 2004 at 12:16:49PM -0700, H. Peter Anvin wrote:> Olaf Hering wrote: > >-int fcntl(int, int, long) > >+int fcntl(int, int, unsigned long) > > Hm. POSIX wants signed long;Just FYI, the Single Unix Specification (v2 and v3) says: int fcntl(int fildes, int cmd, ...); http://www.unix.org/version3/online.html -Dave Dodge
H. Peter Anvin
2004-Aug-26 12:19 UTC
[klibc] Re: [PATCH] fcntl takes unsigned long as third arg
Dave Dodge wrote:> > Just FYI, the Single Unix Specification (v2 and v3) says: > > int fcntl(int fildes, int cmd, ...); >Yup, a multiplexed, varadic syscall, visible to apps. GAG BARF PUKE VOMIT :( I implemented that yesterday (in 0.170); it should now also call fcntl64() with F_GETLK64 et al where appropriate, too. -hpa