switching ARC to 64-bit time_t (Re: [RFC v6 07/23] RISC-V: Use 64-bit time_t and off_t for RV32 and RV64)
Hi Alistair, Arnd On 2/14/20 2:39 PM, Alistair Francis wrote: > On Tue, Feb 11, 2020 at 5:30 PM Joseph Myers wrote: >> On Tue, 11 Feb 2020, Alistair Francis wrote: >> > diff --git a/sysdeps/unix/sysv/linux/riscv/bits/typesizes.h > b/sysdeps/unix/sysv/linux/riscv/bits/typesizes.h > new file mode 100644 > index 00..0da3bdeb5d > --- /dev/null > +++ b/sysdeps/unix/sysv/linux/riscv/bits/typesizes.h I was hoping newer arches could simply use the asm-generic one ? >>> We need to specify that RV32 uses a 64-bit time_t. The generic ones >>> don't do that for 32-bit arches. >> Since it seems we'd like future 32-bit ports of glibc to use 64-bit time >> and offsets, we should make that as easy as possible. >> >> That is, you need an RISC-V-specific bits/timesize.h. But you shouldn't >> need an RISC-V-specific bits/typesizes.h - rather, make the linux/generic >> one do the right thing for __TIME_T_TYPE based on bits/timesize.h. And >> have some other header that 32-bit linux/generic ports can use to say >> whether they use the 64-bit offset/stat/statfs interface, that >> bits/typesizes.h can use together with its existing __LP64__ check, and >> make the definitions of __OFF_T_TYPE etc. check that as well, and then you >> shouldn't need an RISC-V-specific bits/typesizes.h - the RISC-V-specific >> headers should be strictly minimal. (No architecture-specific >> bits/time64.h headers should be needed in any case.) > Ok, I have updated this. I'll send the patch once my "Always use > 32-bit time_t for certain syscalls" series is in (the headers are > changed in that series). I guess you haven't pushed changes yet, which don't make full copy of typesizes.h ? Anyhow I have a version based on your prior next branch where I switched ARC to 64-bit time_t - things work fine in general but I see some additional failures with the testsuite. Consider io/test-stat2.c which calls stat() and stat64() and compares the results: it now fails for ctime mismatch | ... | st_atime: [72] 644245094405576070 vs [72] 644245094405576070 OK | st_mtime: [88] 197568495616000 vs [88] 197568495616000 OK | st_ctime: [104] 0 vs [104] 2306351876938924035 FAIL In kernel asm-generic stat64 has 32-bit ctime (secs) struct stat64 { ... int st_atime; <-- offset 72 unsigned int st_atime_nsec; int st_mtime; <-- offset *80* unsigned int st_mtime_nsec; int st_ctime; <-- offset 92 unsigned int st_ctime_nsec; ... }; In glibc, we have 64-bit time_t based timestamps so the structure diverges with kernel counterpart from time fields onwards. __extension__ typedef __int64_t __time_t; <-- ARC switched to 64-bit time_t struct timespec { __time_t tv_sec; <-- 8 long int tv_nsec; <-- 4 int: 32; <-- 4 }; struct stat64 { ... struct timespec st_atim; <-- offset 72 struct timespec st_mtim; <-- offset *88* struct timespec st_ctim; <-- offset 104 int __glibc_reserved[2]; }; However glibc stat64()wrapper calls sysdeps/unix/sysv/linux/generic/wordsize-32/xstat64.c which for ARC is just doing a pass thru syscall because we do have __NR_fstatat64 - hence the issues I see. It needs itemized copy __xstat64 (int vers, const char *name, struct stat64 *buf) { #ifdef __NR_fstatat64 return INLINE_SYSCALL (fstatat64, 4, AT_FDCWD, name, buf, 0); #else int rc = INLINE_SYSCALL (statx, 5, AT_FDCWD, name, AT_NO_AUTOMOUNT, STATX_BASIC_STATS, &tmp); __cp_stat64_statx (buf, &tmp); #endif An the reason this all works on RISCV is that your kernel doesn't define __ARCH_WANT_STAT64 -> lacks __NR_statat64 and instead uses the statx call which does itemized copy and would work fine when copying from 32-bits time (in kernel) to 64-bits container in glibc. Is this is right understanding or am I missing something here. How do I build a latest RISCV 32-bit kernel + userland - do you have a buildroot branch somewhere that I can build / test with qemu ? Thx, -Vineet ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: switching ARC to 64-bit time_t (Re: [RFC v6 07/23] RISC-V: Use 64-bit time_t and off_t for RV32 and RV64)
On Tue, 18 Feb 2020, Vineet Gupta wrote: > An the reason this all works on RISCV is that your kernel doesn't define > __ARCH_WANT_STAT64 -> lacks __NR_statat64 and instead uses the statx call > which > does itemized copy and would work fine when copying from 32-bits time (in > kernel) > to 64-bits container in glibc. Is this is right understanding or am I missing > something here. That looks right - so you'll need a way (e.g. a new macro in kernel_stat.h) to tell the stat implementations to use the statx path even though the older stat64 syscalls exist. -- Joseph S. Myers jos...@codesourcery.com ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [RFC v6 07/23] RISC-V: Use 64-bit time_t and off_t for RV32 and RV64
Hi Alistair, On 1/12/20 2:33 AM, Alistair Francis wrote: > diff --git a/sysdeps/unix/sysv/linux/riscv/kernel_stat.h > b/sysdeps/unix/sysv/linux/riscv/kernel_stat.h [snip]... > +#define STAT_IS_KERNEL_STAT 1 Isn't this irrelevant: seems to be only used for legacy __NR_stat/__NR_stat64 syscalls based__xstat()/__xstat64(). > + > +#define XSTAT_IS_XSTAT64 1 > +#define STATFS_IS_STATFS64 0 > ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [RFC v6 07/23] RISC-V: Use 64-bit time_t and off_t for RV32 and RV64
On Tue, Feb 18, 2020 at 4:57 PM Vineet Gupta wrote: > > Hi Alistair, > > On 1/12/20 2:33 AM, Alistair Francis wrote: > > diff --git a/sysdeps/unix/sysv/linux/riscv/kernel_stat.h > > b/sysdeps/unix/sysv/linux/riscv/kernel_stat.h > > [snip]... > > > +#define STAT_IS_KERNEL_STAT 1 > > Isn't this irrelevant: seems to be only used for legacy __NR_stat/__NR_stat64 > syscalls based__xstat()/__xstat64(). Is it? It seems to be used in a few places, including: sysdeps/unix/sysv/linux/fxstatat.c sysdeps/unix/sysv/linux/xstatconv.c Alistair > > > + > > +#define XSTAT_IS_XSTAT64 1 > > +#define STATFS_IS_STATFS64 0 > > > ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
[PATCH] Remove STATFS_IS_STATFS64 conditional as it is zero in all ports
Signed-off-by: Vineet Gupta --- sysdeps/unix/sysv/linux/alpha/kernel_stat.h | 1 - sysdeps/unix/sysv/linux/fstatfs64.c | 14 -- sysdeps/unix/sysv/linux/generic/kernel_stat.h | 2 -- .../unix/sysv/linux/generic/wordsize-32/fstatfs.c | 2 -- .../unix/sysv/linux/generic/wordsize-32/statfs.c | 2 -- sysdeps/unix/sysv/linux/hppa/kernel_stat.h| 1 - sysdeps/unix/sysv/linux/ia64/kernel_stat.h| 1 - sysdeps/unix/sysv/linux/kernel_stat.h | 1 - sysdeps/unix/sysv/linux/microblaze/kernel_stat.h | 1 - sysdeps/unix/sysv/linux/mips/kernel_stat.h| 1 - .../sysv/linux/powerpc/powerpc32/kernel_stat.h| 1 - .../sysv/linux/powerpc/powerpc64/kernel_stat.h| 1 - .../unix/sysv/linux/s390/s390-64/kernel_stat.h| 1 - .../unix/sysv/linux/sparc/sparc32/kernel_stat.h | 1 - .../unix/sysv/linux/sparc/sparc64/kernel_stat.h | 1 - sysdeps/unix/sysv/linux/statfs64.c| 15 --- sysdeps/unix/sysv/linux/x86_64/kernel_stat.h | 1 - 17 files changed, 47 deletions(-) diff --git a/sysdeps/unix/sysv/linux/alpha/kernel_stat.h b/sysdeps/unix/sysv/linux/alpha/kernel_stat.h index d637e099cfe4..670841140765 100644 --- a/sysdeps/unix/sysv/linux/alpha/kernel_stat.h +++ b/sysdeps/unix/sysv/linux/alpha/kernel_stat.h @@ -86,4 +86,3 @@ struct glibc21_stat }; #define XSTAT_IS_XSTAT64 1 -#define STATFS_IS_STATFS64 0 diff --git a/sysdeps/unix/sysv/linux/fstatfs64.c b/sysdeps/unix/sysv/linux/fstatfs64.c index 9d22fa228fa5..4a339b548aa7 100644 --- a/sysdeps/unix/sysv/linux/fstatfs64.c +++ b/sysdeps/unix/sysv/linux/fstatfs64.c @@ -22,15 +22,6 @@ #include #include -/* Hide the prototypes for __fstatfs and fstatfs so that GCC will not - complain about the different function signatures if they are aliased - to __fstat64. If STATFS_IS_STATFS64 is not zero then the statfs and - statfs64 structures have an identical layout but different type names. */ - -#if STATFS_IS_STATFS64 -# define __fstatfs __fstatfs_disable -# define fstatfs fstatfs_disable -#endif #include #include @@ -85,8 +76,3 @@ weak_alias (__fstatfs64, fstatfs64) #undef __fstatfs #undef fstatfs - -#if STATFS_IS_STATFS64 -weak_alias (__fstatfs64, __fstatfs) -weak_alias (__fstatfs64, fstatfs) -#endif diff --git a/sysdeps/unix/sysv/linux/generic/kernel_stat.h b/sysdeps/unix/sysv/linux/generic/kernel_stat.h index 2eed3596c0ed..5a600f188320 100644 --- a/sysdeps/unix/sysv/linux/generic/kernel_stat.h +++ b/sysdeps/unix/sysv/linux/generic/kernel_stat.h @@ -26,5 +26,3 @@ #else # define XSTAT_IS_XSTAT64 0 #endif - -#define STATFS_IS_STATFS64 0 diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/fstatfs.c b/sysdeps/unix/sysv/linux/generic/wordsize-32/fstatfs.c index 93d9d94a0a61..bacc1543013a 100644 --- a/sysdeps/unix/sysv/linux/generic/wordsize-32/fstatfs.c +++ b/sysdeps/unix/sysv/linux/generic/wordsize-32/fstatfs.c @@ -21,7 +21,6 @@ #include #include -#if !STATFS_IS_STATFS64 #include "overflow.h" /* Return information about the filesystem on which FD resides. */ @@ -32,4 +31,3 @@ __fstatfs (int fd, struct statfs *buf) return rc ?: statfs_overflow (buf); } weak_alias (__fstatfs, fstatfs) -#endif diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/statfs.c b/sysdeps/unix/sysv/linux/generic/wordsize-32/statfs.c index 7421501b4a40..a678e96058ce 100644 --- a/sysdeps/unix/sysv/linux/generic/wordsize-32/statfs.c +++ b/sysdeps/unix/sysv/linux/generic/wordsize-32/statfs.c @@ -21,7 +21,6 @@ #include #include -#if !STATFS_IS_STATFS64 #include "overflow.h" /* Return information about the filesystem on which FILE resides. */ @@ -33,4 +32,3 @@ __statfs (const char *file, struct statfs *buf) } libc_hidden_def (__statfs) weak_alias (__statfs, statfs) -#endif diff --git a/sysdeps/unix/sysv/linux/hppa/kernel_stat.h b/sysdeps/unix/sysv/linux/hppa/kernel_stat.h index a3ac53a1ef2f..9ffa3ba638ea 100644 --- a/sysdeps/unix/sysv/linux/hppa/kernel_stat.h +++ b/sysdeps/unix/sysv/linux/hppa/kernel_stat.h @@ -31,4 +31,3 @@ struct kernel_stat { #define _HAVE_STAT64_NSEC #define XSTAT_IS_XSTAT64 0 -#define STATFS_IS_STATFS64 0 diff --git a/sysdeps/unix/sysv/linux/ia64/kernel_stat.h b/sysdeps/unix/sysv/linux/ia64/kernel_stat.h index b38bf741d37b..da8e2a91eff7 100644 --- a/sysdeps/unix/sysv/linux/ia64/kernel_stat.h +++ b/sysdeps/unix/sysv/linux/ia64/kernel_stat.h @@ -18,4 +18,3 @@ #define STAT_IS_KERNEL_STAT 1 #define XSTAT_IS_XSTAT64 1 -#define STATFS_IS_STATFS64 0 diff --git a/sysdeps/unix/sysv/linux/kernel_stat.h b/sysdeps/unix/sysv/linux/kernel_stat.h index eecc962de390..4354d14f76e9 100644 --- a/sysdeps/unix/sysv/linux/kernel_stat.h +++ b/sysdeps/unix/sysv/linux/kernel_stat.h @@ -35,4 +35,3 @@ struct kernel_stat #define _HAVE_STAT64_NSEC #define XSTAT_IS_XSTAT64 0 -#define STATFS_IS_STATFS64 0 diff --git a/sysdeps/unix/sysv/linux/microblaze/kernel_stat.h b/sysdeps/unix/sysv/linux/microblaze/kernel_stat.h index
Re: [RFC v6 07/23] RISC-V: Use 64-bit time_t and off_t for RV32 and RV64
On 2/18/20 5:03 PM, Alistair Francis wrote: >>> +#define STAT_IS_KERNEL_STAT 1 >> Isn't this irrelevant: seems to be only used for legacy __NR_stat/__NR_stat64 >> syscalls based__xstat()/__xstat64(). > Is it? It seems to be used in a few places, including: > > sysdeps/unix/sysv/linux/fxstatat.c > sysdeps/unix/sysv/linux/xstatconv.c AFAIK that is not part of the asm-generic syscall ABI which ARC, RISCV et al use ! -Vineet ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc