From patchwork Sat Aug 10 01:00:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 34037 Received: (qmail 74828 invoked by alias); 10 Aug 2019 01:03:38 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 74782 invoked by uid 89); 10 Aug 2019 01:03:37 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, KAM_SHORT autolearn=ham version=3.3.1 spammy=vary X-HELO: esa5.hgst.iphmx.com DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1565399014; x=1596935014; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=foW6Lbz6Z3HL0cjyasJJfrvDwqyX68y0AXDNBwboNk8=; b=nWx997dkDKy73PawVUXMhbxlySfuh10DpoALNtkylITaK/Er6RZfeJ8t Hz9vtSLw5yZmg8nHfpPHFh1o1/l+n2V1oXGeNz7nnOBedfJhedmu3zYPA TUMdJVQ9A1eUqLnHvcWlQNXNtzFz9Oi3H2WawRPPjcQwVVcF+xHI8TFdH iB+ki8PfFPqae865dowyQdRbOHq0PpT8pinAm+ZBpaN39J/5Pnl3UJ3FG 6L2DsfA1x3DP6PMOBm6XAubAKYjktg6JTROv6R1vtuUHkrhLlj3VyPjbk uOiV9Ora7ag/y40CV4QhqXIR4tMHJA/nXQjkSBSOs0TMWh9F7IzUd0Hgr w==; IronPort-SDR: CYcKoYD0eLa1C4iYaLtkv3cdgLSyOY/cNbjw+uP3DgU20doO1SLnuCSW7aRc4jrmiTqpi4+QZa nsoMGYZNWCMi3quWICYhmvhh8cZHLQnQKjFtSpnF8dJ8P++e0CN4Ivceu/WWs6SUmDL8VUf+Pp cJ4AXcJtTyV6uuWJ1hfo42gqu1QGZyp7CEB361XW4uXprVwXJDvprHU/pN7scRcO8PphABsM6s cIod6pO5ysrZ3rPcISYoc+jw0l+eUaogZpDMpmtP1yBz8H6ZyH3bR2483zpGBp4rp8Erl5pYkQ nxw= IronPort-SDR: 62pp1fA7kzwMbIccmzSQ0+TDkCbUlwjtoGz7o33QhY+AlKFGPyrXv8rUUi8cTG1DN6/Y6vDwPx HwKNjh19cqcUrhEoUdaAIUjOgMBmlwjHzmTlTQW2uMDJHXuhR7GaoWjmh0S21EeD5KTc7PdMyZ Sy5VDVPre6eQ1jZAQc/UVp7iWRQqQIytaHKmKJj1FXS5mlR3l4frIv2Kc7fllcgPluMCogsBXS 8aTMMFRoGwilAkHF+xQJSRQvlVVqlM2GkNLPHk6sD4QZShjPNFf2y5gyyNzAe1WyQFbHXRzGPE VzbUGbKV9337z8EOWcjopmUE IronPort-SDR: 0Mvr37BOyeqpqxy+d7KT2IL7H+UVr04CaYkur6VBB90A/Vh/AhXCs4yn0X0Ev9Nsz/teji8Ydt kn2X3ZqyJl9F4bt+jbJDzg8fJ/FYW9whTLijiz3dSFeaQUTQVwPlGKNgafvUdCK+W3/UpTHOsA sNlWHRySjQb4CoSno3yIDqAdZBnHOeVsHuJIT6bhLPdONhBCpEFf2W/PlpjdsceWUO8Hb/ZpV6 XR5G5CyC+AcXcEl8rSe/pPMjdR3wS/obKww3VotndBn/8RZtuW4V2xR3+h2bCy4DfMWCobfHed gm0= From: Alistair Francis To: libc-alpha@sourceware.org Cc: arnd@arndb.de, adhemerval.zanella@linaro.org, fweimer@redhat.com, palmer@sifive.com, macro@wdc.com, zongbox@gmail.com, alistair.francis@wdc.com, alistair23@gmail.com Subject: [RFC v4 10/24] RISC-V: Use 64-bit time_t and off_t for RV32 and RV64 Date: Fri, 9 Aug 2019 18:00:13 -0700 Message-Id: <40790cabda4fbe4ae11ac5d07a7fd64946fc6ef2.1565398513.git.alistair.francis@wdc.com> In-Reply-To: References: MIME-Version: 1.0 Using the original glibc headers under bits/ let's make small modifications to use 64-bit time_t and off_t for both RV32 and RV64. For the typesizes.h, here are justifications for the changes from the generic version (based on Arnd's very helpful feedback): - All the !__USE_FILE_OFFSET64 types (__off_t, __ino_t, __rlim_t, ...) are changed to match the 64-bit replacements. - __time_t is defined to 64 bit, but no __time64_t is added. This makes sense as we don't have the time64 support for other 32-bit architectures yet, and it will be easy to change when that happens. - __suseconds_t is 64-bit. This matches what we use the kerne ABI for the few drivers that are relying on 'struct timeval' input arguments in ioctl, as well as the adjtimex system call. It means that timeval has to be defined without the padding, unlike timespec, which needs padding. Signed-off-by: Alistair Francis --- ChangeLog | 4 + .../unix/sysv/linux/riscv/bits/environments.h | 85 +++++++++++++++++++ sysdeps/unix/sysv/linux/riscv/bits/time64.h | 36 ++++++++ sysdeps/unix/sysv/linux/riscv/bits/timesize.h | 22 +++++ .../unix/sysv/linux/riscv/bits/typesizes.h | 84 ++++++++++++++++++ 5 files changed, 231 insertions(+) create mode 100644 sysdeps/unix/sysv/linux/riscv/bits/environments.h create mode 100644 sysdeps/unix/sysv/linux/riscv/bits/time64.h create mode 100644 sysdeps/unix/sysv/linux/riscv/bits/timesize.h create mode 100644 sysdeps/unix/sysv/linux/riscv/bits/typesizes.h diff --git a/ChangeLog b/ChangeLog index 6daa6f259e1..4c6b86456a3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1428,6 +1428,10 @@ * sysdeps/unix/sysv/linux/wait.c: Use __NR_waitid if avaliable. * sysdeps/unix/sysv/linux/waitpid.c: Likewise. * sysdeps/unix/sysv/linux/waitpid_nocancel.c: Likewise. + * sysdeps/unix/sysv/linux/riscv/bits/environments.h: Use 64-bit time_t and off_t for RV32 and RV64. + * sysdeps/unix/sysv/linux/riscv/bits/time64.h: Likewise. + * sysdeps/unix/sysv/linux/riscv/bits/timesize.h: Likewise. + * sysdeps/unix/sysv/linux/riscv/bits/typesizes.h: Likewise. 2019-06-20 Dmitry V. Levin Florian Weimer diff --git a/sysdeps/unix/sysv/linux/riscv/bits/environments.h b/sysdeps/unix/sysv/linux/riscv/bits/environments.h new file mode 100644 index 00000000000..bdbf18fca09 --- /dev/null +++ b/sysdeps/unix/sysv/linux/riscv/bits/environments.h @@ -0,0 +1,85 @@ +/* Copyright (C) 1999-2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _UNISTD_H +# error "Never include this file directly. Use instead" +#endif + +#include + +/* This header should define the following symbols under the described + situations. A value `1' means that the model is always supported, + `-1' means it is never supported. Undefined means it cannot be + statically decided. + + _POSIX_V7_ILP32_OFF32 32bit int, long, pointers, and off_t type + _POSIX_V7_ILP32_OFFBIG 32bit int, long, and pointers and larger off_t type + + _POSIX_V7_LP64_OFF32 64bit long and pointers and 32bit off_t type + _POSIX_V7_LPBIG_OFFBIG 64bit long and pointers and large off_t type + + The macros _POSIX_V6_ILP32_OFF32, _POSIX_V6_ILP32_OFFBIG, + _POSIX_V6_LP64_OFF32, _POSIX_V6_LPBIG_OFFBIG, _XBS5_ILP32_OFF32, + _XBS5_ILP32_OFFBIG, _XBS5_LP64_OFF32, and _XBS5_LPBIG_OFFBIG were + used in previous versions of the Unix standard and are available + only for compatibility. +*/ + +#if __WORDSIZE == 64 + +/* We can never provide environments with 32-bit wide pointers. */ +# define _POSIX_V7_ILP32_OFF32 -1 +# define _POSIX_V7_ILP32_OFFBIG -1 +# define _POSIX_V6_ILP32_OFF32 -1 +# define _POSIX_V6_ILP32_OFFBIG -1 +# define _XBS5_ILP32_OFF32 -1 +# define _XBS5_ILP32_OFFBIG -1 +/* We also have no use (for now) for an environment with bigger pointers + and offsets. */ +# define _POSIX_V7_LPBIG_OFFBIG -1 +# define _POSIX_V6_LPBIG_OFFBIG -1 +# define _XBS5_LPBIG_OFFBIG -1 + +/* By default we have 64-bit wide `long int', pointers and `off_t'. */ +# define _POSIX_V7_LP64_OFF64 1 +# define _POSIX_V6_LP64_OFF64 1 +# define _XBS5_LP64_OFF64 1 + +#else /* __WORDSIZE == 32 */ + +/* RISC-V requires 64-bit off_t + # undef _POSIX_V7_ILP32_OFF32 + # undef _POSIX_V6_ILP32_OFF32 + # undef _XBS5_ILP32_OFF32 + */ + +# define _POSIX_V7_ILP32_OFFBIG 1 +# define _POSIX_V6_ILP32_OFFBIG 1 +# define _XBS5_ILP32_OFFBIG 1 + +/* We can never provide environments with 64-bit wide pointers. */ +# define _POSIX_V7_LP64_OFF64 -1 +# define _POSIX_V7_LPBIG_OFFBIG -1 +# define _POSIX_V6_LP64_OFF64 -1 +# define _POSIX_V6_LPBIG_OFFBIG -1 +# define _XBS5_LP64_OFF64 -1 +# define _XBS5_LPBIG_OFFBIG -1 + +/* CFLAGS. */ +#define __ILP32_OFFBIG_CFLAGS "-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" + +#endif /* __WORDSIZE == 32 */ diff --git a/sysdeps/unix/sysv/linux/riscv/bits/time64.h b/sysdeps/unix/sysv/linux/riscv/bits/time64.h new file mode 100644 index 00000000000..4be26d32d47 --- /dev/null +++ b/sysdeps/unix/sysv/linux/riscv/bits/time64.h @@ -0,0 +1,36 @@ +/* bits/time64.h -- underlying types for __time64_t. Generic version. + Copyright (C) 2018-2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _BITS_TYPES_H +# error "Never include directly; use instead." +#endif + +#ifndef _BITS_TIME64_H +#define _BITS_TIME64_H 1 + +/* Define __TIME64_T_TYPE so that it is always a 64-bit type. */ + +#if __WORDSIZE == 64 +/* If we already have 64-bit time type then use it. */ +# define __TIME64_T_TYPE __TIME_T_TYPE +#else +/* Define a 64-bit time type alongsize the 32-bit one. */ +# define __TIME64_T_TYPE __SQUAD_TYPE +#endif + +#endif /* bits/time64.h */ diff --git a/sysdeps/unix/sysv/linux/riscv/bits/timesize.h b/sysdeps/unix/sysv/linux/riscv/bits/timesize.h new file mode 100644 index 00000000000..150af80f86f --- /dev/null +++ b/sysdeps/unix/sysv/linux/riscv/bits/timesize.h @@ -0,0 +1,22 @@ +/* Bit size of the time_t type at glibc build time, general case. + Copyright (C) 2018-2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +/* RV32 and RV64 both use 64-bit time_t */ +#define __TIMESIZE 64 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 00000000000..bd52fd9e2a6 --- /dev/null +++ b/sysdeps/unix/sysv/linux/riscv/bits/typesizes.h @@ -0,0 +1,84 @@ +/* bits/typesizes.h -- underlying types for *_t. Generic version. + Copyright (C) 2002-2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _BITS_TYPES_H +# error "Never include directly; use instead." +#endif + +#ifndef _BITS_TYPESIZES_H +#define _BITS_TYPESIZES_H 1 + +/* See for the meaning of these macros. This file exists so + that need not vary across different GNU platforms. */ +#define __DEV_T_TYPE __UQUAD_TYPE +#define __UID_T_TYPE __U32_TYPE +#define __GID_T_TYPE __U32_TYPE +#define __INO_T_TYPE __UQUAD_TYPE +#define __INO64_T_TYPE __UQUAD_TYPE +#define __MODE_T_TYPE __U32_TYPE +#define __NLINK_T_TYPE __U32_TYPE +#define __OFF_T_TYPE __SQUAD_TYPE +#define __OFF64_T_TYPE __SQUAD_TYPE +#define __PID_T_TYPE __S32_TYPE +#define __RLIM_T_TYPE __UQUAD_TYPE +#define __RLIM64_T_TYPE __UQUAD_TYPE +#define __BLKCNT_T_TYPE __SQUAD_TYPE +#define __BLKCNT64_T_TYPE __SQUAD_TYPE +#define __FSBLKCNT_T_TYPE __UQUAD_TYPE +#define __FSBLKCNT64_T_TYPE __UQUAD_TYPE +#define __FSFILCNT_T_TYPE __UQUAD_TYPE +#define __FSFILCNT64_T_TYPE __UQUAD_TYPE +#define __FSWORD_T_TYPE __SWORD_TYPE +#define __ID_T_TYPE __U32_TYPE +#define __CLOCK_T_TYPE __SLONGWORD_TYPE +#define __TIME_T_TYPE __SQUAD_TYPE +#define __USECONDS_T_TYPE __U32_TYPE +#define __SUSECONDS_T_TYPE __SQUAD_TYPE +#define __DADDR_T_TYPE __S32_TYPE +#define __KEY_T_TYPE __S32_TYPE +#define __CLOCKID_T_TYPE __S32_TYPE +#define __TIMER_T_TYPE void * +#define __BLKSIZE_T_TYPE __S32_TYPE +#define __FSID_T_TYPE struct { int __val[2]; } +#define __SSIZE_T_TYPE __SWORD_TYPE +#define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE +#define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE +#define __CPU_MASK_TYPE __ULONGWORD_TYPE + +/* Tell the libc code that off_t and off64_t are actually the same type + for all ABI purposes, even if possibly expressed as different base types + for C type-checking purposes. */ +# define __OFF_T_MATCHES_OFF64_T 1 + +/* Same for ino_t and ino64_t. */ +# define __INO_T_MATCHES_INO64_T 1 + +/* And for rlim_t and rlim64_t. */ +# define __RLIM_T_MATCHES_RLIM64_T 1 + +/* Define these as RV32 requires 64-bit syscall. */ +#if __riscv_xlen == 32 +#define __ASSUME_TIME64_SYSCALLS 1 +#define __ASSUME_RLIM64_SYSCALLS 1 +#endif + +/* Number of descriptors that can fit in an `fd_set'. */ +#define __FD_SETSIZE 1024 + + +#endif /* bits/typesizes.h */