[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <78d91061-1bcd-4031-89e1-706c3f49d762@t-8ch.de>
Date: Fri, 26 May 2023 09:15:11 +0200
From: Thomas Weißschuh <thomas@...ch.de>
To: Zhangjin Wu <falcon@...ylab.org>
Cc: w@....eu, linux-kernel@...r.kernel.org,
linux-kselftest@...r.kernel.org, linux-riscv@...ts.infradead.org,
palmer@...belt.com, paul.walmsley@...ive.com
Subject: Re: [PATCH 09/13] tools/nolibc: sys_poll: riscv: use
__NR_ppoll_time64 for rv32
On 2023-05-25 01:57:24+0800, Zhangjin Wu wrote:
> rv32 uses the generic include/uapi/asm-generic/unistd.h and it has no
> __NR_ppoll after kernel commit d4c08b9776b3 ("riscv: Use latest system
> call ABI"), use __NR_ppoll_time64 instead.
>
> Signed-off-by: Zhangjin Wu <falcon@...ylab.org>
> ---
> tools/include/nolibc/std.h | 1 +
> tools/include/nolibc/sys.h | 7 ++++++-
> tools/include/nolibc/types.h | 6 ++++++
> 3 files changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/tools/include/nolibc/std.h b/tools/include/nolibc/std.h
> index 83c0b0cb9564..221385c0e823 100644
> --- a/tools/include/nolibc/std.h
> +++ b/tools/include/nolibc/std.h
> @@ -32,6 +32,7 @@ typedef signed long off_t;
> typedef signed long blksize_t;
> typedef signed long blkcnt_t;
> typedef signed long time_t;
> +typedef long long time64_t;
> typedef long long loff_t;
>
> #endif /* _NOLIBC_STD_H */
> diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h
> index 0ff77c0a06d7..08d38175bd7b 100644
> --- a/tools/include/nolibc/sys.h
> +++ b/tools/include/nolibc/sys.h
> @@ -923,8 +923,13 @@ int pivot_root(const char *new, const char *old)
> static __attribute__((unused))
> int sys_poll(struct pollfd *fds, int nfds, int timeout)
> {
> -#if defined(__NR_ppoll)
> +#if defined(__NR_ppoll) || defined(__NR_ppoll_time64)
> +#ifdef __NR_ppoll
> struct timespec t;
> +#else
> + struct timespec64 t;
> +#define __NR_ppoll __NR_ppoll_time64
> +#endif
>
> if (timeout >= 0) {
> t.tv_sec = timeout / 1000;
> diff --git a/tools/include/nolibc/types.h b/tools/include/nolibc/types.h
> index 15b0baffd336..ee914391439c 100644
> --- a/tools/include/nolibc/types.h
> +++ b/tools/include/nolibc/types.h
> @@ -203,6 +203,12 @@ struct stat {
> time_t st_ctime; /* time of last status change */
> };
>
> +/* needed by time64 syscalls */
> +struct timespec64 {
> + time64_t tv_sec; /* seconds */
> + long tv_nsec; /* nanoseconds */
> +};
A question to you and Willy, as it's also done the same for other types:
What is the advantage of custom definitions over using the one from the
kernel (maybe via a typedef).
>From linux/time_types.h:
struct __kernel_timespec {
__kernel_time64_t tv_set;
long long tv_nsec;
};
> +
> /* WARNING, it only deals with the 4096 first majors and 256 first minors */
> #define makedev(major, minor) ((dev_t)((((major) & 0xfff) << 8) | ((minor) & 0xff)))
> #define major(dev) ((unsigned int)(((dev) >> 8) & 0xfff))
> --
> 2.25.1
>
Powered by blists - more mailing lists