diff mbox series

[uclibc-ng-devel] xtensa: Add time64 support.

Message ID 20240222125051.2341214-1-dm.chestnykh@gmail.com
State Accepted
Headers show
Series [uclibc-ng-devel] xtensa: Add time64 support. | expand

Commit Message

Dmitry Chestnykh Feb. 22, 2024, 12:50 p.m. UTC
- xtensa is the second architecture that supports
time64 inside uClibc-ng.
- Linux Kernel always uses 32bit time variables
inside `stat` structures, so there is a need
to use `st_atime`, `st_mtime` and `st_ctime` structures with the same
32bit-wide `tv_sec` and `tv_nsec` variables even if time64 is enabled.

Signed-off-by: Dmitry Chestnykh <dm.chestnykh@gmail.com>
---
 extra/Configs/Config.in                      |  2 +-
 libc/sysdeps/linux/xtensa/bits/kernel_stat.h | 22 ++++++++++++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)

Comments

Max Filippov Feb. 23, 2024, 7:35 a.m. UTC | #1
On Thu, Feb 22, 2024 at 4:51 AM Dmitry Chestnykh <dm.chestnykh@gmail.com> wrote:
>
> - xtensa is the second architecture that supports
> time64 inside uClibc-ng.
> - Linux Kernel always uses 32bit time variables
> inside `stat` structures, so there is a need
> to use `st_atime`, `st_mtime` and `st_ctime` structures with the same
> 32bit-wide `tv_sec` and `tv_nsec` variables even if time64 is enabled.
>
> Signed-off-by: Dmitry Chestnykh <dm.chestnykh@gmail.com>
> ---
>  extra/Configs/Config.in                      |  2 +-
>  libc/sysdeps/linux/xtensa/bits/kernel_stat.h | 22 ++++++++++++++++++++
>  2 files changed, 23 insertions(+), 1 deletion(-)

Reviewed-by: Max Filippov <jcmvbkbc@gmail.com>
Waldemar Brodkorb Feb. 24, 2024, 3:06 p.m. UTC | #2
Hi,
Max Filippov wrote,

> On Thu, Feb 22, 2024 at 4:51 AM Dmitry Chestnykh <dm.chestnykh@gmail.com> wrote:
> >
> > - xtensa is the second architecture that supports
> > time64 inside uClibc-ng.
> > - Linux Kernel always uses 32bit time variables
> > inside `stat` structures, so there is a need
> > to use `st_atime`, `st_mtime` and `st_ctime` structures with the same
> > 32bit-wide `tv_sec` and `tv_nsec` variables even if time64 is enabled.
> >
> > Signed-off-by: Dmitry Chestnykh <dm.chestnykh@gmail.com>
> > ---
> >  extra/Configs/Config.in                      |  2 +-
> >  libc/sysdeps/linux/xtensa/bits/kernel_stat.h | 22 ++++++++++++++++++++
> >  2 files changed, 23 insertions(+), 1 deletion(-)
> 
> Reviewed-by: Max Filippov <jcmvbkbc@gmail.com>

Thanks for review.
commited and pushed,
 best regards
  Waldemar
diff mbox series

Patch

diff --git a/extra/Configs/Config.in b/extra/Configs/Config.in
index 831b9f689..9351dffc8 100644
--- a/extra/Configs/Config.in
+++ b/extra/Configs/Config.in
@@ -1026,7 +1026,7 @@  config UCLIBC_FALLBACK_TO_ETC_LOCALTIME
 
 config UCLIBC_USE_TIME64
 	bool "Use *time64 syscalls instead of 32bit ones (if possible)"
-	depends on TARGET_arm
+	depends on TARGET_arm || TARGET_xtensa
 	# TODO: add support for other architectures
 	default n
 
diff --git a/libc/sysdeps/linux/xtensa/bits/kernel_stat.h b/libc/sysdeps/linux/xtensa/bits/kernel_stat.h
index d884344d3..80ccdb76a 100644
--- a/libc/sysdeps/linux/xtensa/bits/kernel_stat.h
+++ b/libc/sysdeps/linux/xtensa/bits/kernel_stat.h
@@ -5,6 +5,16 @@ 
  * struct kernel_stat should look like...  It turns out each arch has a
  * different opinion on the subject... */
 
+#if defined(__UCLIBC_USE_TIME64__)
+#include <bits/types.h>
+
+struct ts32_struct {
+	__S32_TYPE tv_sec;
+	__S32_TYPE tv_nsec;
+};
+
+#endif
+
 struct kernel_stat {
 	unsigned long	st_dev;
 	unsigned long	st_ino;
@@ -16,9 +26,15 @@  struct kernel_stat {
 	long		st_size;
 	unsigned long	st_blksize;
 	unsigned long	st_blocks;
+#if defined(__UCLIBC_USE_TIME64__)
+	struct ts32_struct __st_atim32;
+	struct ts32_struct __st_mtim32;
+	struct ts32_struct __st_ctim32;
+#else
 	struct timespec	st_atim;
 	struct timespec	st_mtim;
 	struct timespec	st_ctim;
+#endif
 	unsigned long	__unused4;
 	unsigned long	__unused5;
 };
@@ -35,9 +51,15 @@  struct kernel_stat64 {
 	unsigned long st_blksize;	/* Optimal block size for I/O. */
 	unsigned long __uclibc_unused2;
 	unsigned long long st_blocks;	/* Number 512-byte blocks allocated. */
+#if defined(__UCLIBC_USE_TIME64__)
+	struct ts32_struct __st_atim32;
+	struct ts32_struct __st_mtim32;
+	struct ts32_struct __st_ctim32;
+#else
 	struct timespec st_atim;	/* Time of last access. */
 	struct timespec st_mtim;	/* Time of last modification. */
 	struct timespec st_ctim;	/* Time of last status change. */
+#endif
 	unsigned long __uclibc_unused4;
 	unsigned long __uclibc_unused5;
 };