Re: [PATCH] lseek.2: SYNOPSIS: Use correct types
From: Michael Kerrisk (man-pages)
Date: Sun Nov 22 2020 - 17:32:46 EST
[Adding libc-alpha@ here, so someone might correct me if I make a misstep]
Hello Alex,
On Sat, 21 Nov 2020 at 18:34, Alejandro Colomar <alx.manpages@xxxxxxxxx> wrote:
>
> The Linux kernel uses 'unsigned int' instead of 'int'
> for 'fd' and 'whence'.
> As glibc provides no wrapper, use the same types the kernel uses.
I see Florian already replied, but just to add a detail or two...
In general, the manual pages explicitly note the APIs that have no
glibc wrapper. (If not, that's a bug in the page, but I don't expect
there are many such bugs.)
Looking in <unistd.h>, we have:
[[
#ifndef __USE_FILE_OFFSET64
extern __off_t lseek (int __fd, __off_t __offset, int __whence) __THROW;
#else
# ifdef __REDIRECT_NTH
extern __off64_t __REDIRECT_NTH (lseek,
(int __fd, __off64_t __offset, int __whence),
lseek64);
# else
# define lseek lseek64
# endif
#endif
#ifdef __USE_LARGEFILE64
extern __off64_t lseek64 (int __fd, __off64_t __offset, int __whence)
__THROW;
#endif
]]
It looks to me like there's a prototype hiding in there. (And yes, I
don't find it so funny to decode the macro logic either.)
Thanks,
Michael
PS By the way, be aware that the code of many wrapper functions is
autogenerated from "syscalls.list" files in the glibc source, for
example, sysdeps/unix/sysv/linux/syscalls.list. This isn't the case
for lseek(), though, as far as I can see; I think the wrapper function
is defined in sysdeps/unix/sysv/linux/lseek.c.
--
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/