Re: [PATCH v3 1/3] tools/nolibc: fix up #error compile failures with -ENOSYS

From: Arnd Bergmann
Date: Wed Jun 07 2023 - 04:45:57 EST


On Wed, Jun 7, 2023, at 07:19, Zhangjin Wu wrote:
>> On Sat, Jun 3, 2023, at 11:01, Zhangjin Wu wrote:
>
> Yeah, agreed, we can clean up them one by one, If split them to their own
> syscalls, I have two questions (for Arnd, and Willy too):
>
> 1. do we need to add the corresponding library routines at the same time?
>
> Use llseek() as an example, there will be llseek() and lsee64(). If off_t
> would be converted to 64bit, then, they can be simply added as follows:
>
> #define lseek64 lseek
> #define llseek lseek
>
> Or something like this:
>
> static __attribute__((unused))
> loff_t lseek(int fd, loff_t offset, int whence)
> {
> return lseek(fd, offset, whence);
> }
>
> static __attribute__((unused))
> off64_t lseek(int fd, off64_t offset, int whence)
> {
> return lseek(fd, offset, whence);
> }
>
> This one aligns with the other already added library routines.
>
> Which one do you like more?

lseek() is probably not a good example, as the llseek and lseek64
library functions are both nonstandard, and I'd suggest leaving them
out of nolibc altogether.

Are there any examples of functions where we actually want mulitple
versions?

> 2. If so, how to cope with the new types when add the library routines?
>
> Still use the above llseek() as an example, If not use '#define' method,
> We may need to declare loff_t and off64_t in std.h too:
>
> #define off64_t off_t
> #define loff_t off_t
>
> Or align with the other new types, use 'typedef' instead of '#define'.

If we do want to include the explicit off64_t interfaces from glibc,
I'd suggest doing it the same way as musl:
https://git.musl-libc.org/cgit/musl/tree/include/unistd.h#n201

>
>> This patch is a step in that direction though, so I think that's
>> totally fine.
>
> Thanks, so, can I pick your Reviewed-by for the first two patches? I'm ready to
> send v4 now ;-)

Yes, please do.

Arnd