[PATCH v3 1/3] tools/nolibc: fix up #error compile failures with -ENOSYS
Zhangjin Wu
falcon at tinylab.org
Tue Jun 6 22:19:14 PDT 2023
> On Sat, Jun 3, 2023, at 11:01, Zhangjin Wu wrote:
> >
> > Suggested-by: Arnd Bergmann <arnd at arndb.de>
> > Link:
> > https://lore.kernel.org/linux-riscv/5e7d2adf-e96f-41ca-a4c6-5c87a25d4c9c@app.fastmail.com/
> > Signed-off-by: Zhangjin Wu <falcon at tinylab.org>
> > ---
> > tools/include/nolibc/sys.h | 26 +++++++++++++-------------
> > 1 file changed, 13 insertions(+), 13 deletions(-)
> >
> > diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h
> > index 856249a11890..78c86f124335 100644
> > --- a/tools/include/nolibc/sys.h
> > +++ b/tools/include/nolibc/sys.h
> > @@ -124,7 +124,7 @@ int sys_chmod(const char *path, mode_t mode)
> > #elif defined(__NR_chmod)
> > return my_syscall2(__NR_chmod, path, mode);
> > #else
> > -#error Neither __NR_fchmodat nor __NR_chmod defined, cannot implement
> > sys_chmod()
> > + return -ENOSYS;
> > #endif
> > }
>
> I think the most logical would be to have each syscall (chmod,
> fchmodat, ...) have its own function that returns -ENOSYS if
> that is not defined, and have the logic that decides which one
> to use as a separate function.
>
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?
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'.
And further, use poll() as an example, in its manpage [1], there may be some
new types, such as 'nfds_t', but 'int' is used in tools/include/nolibc/sys.h
currently, do we need to add nfds_t?
The 'idtypes_t' and 'id_t' types used by waitid() [2] is similar, both
of them can simply use the 'int' type.
The above two questions are important to the coming patches, it may determine
how I should tune the new llseek() and waitid() syscalls and their library
routines. very welcome your suggestions.
> 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 ;-)
Best regards,
Zhangjin
---
[1]: https://linux.die.net/man/2/poll
[2]: https://linux.die.net/man/2/waitid
>
> Arnd
More information about the linux-riscv
mailing list