From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-2.8 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_GMAIL_RCVD, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=no autolearn_force=no version=3.4.2 Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id D20601F466 for ; Wed, 15 Jan 2020 05:10:16 +0000 (UTC) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-type; q=dns; s=default; b=iwMp /r11llmrXuaR6z7XVypwJa9voU1Mui3P3xaK7rWmmREy1sk74OEdFhxLHDpa6n2G VuDrwdoWDZa4t2DvyI7o/ciB7/CPo9sAxkvlSPud6Tx3vJZLZFL+kAPTz8D/u4Eu oO3z8FUw1i6IZffH4mhZExphZ+2pxKMCOTn4D1w= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-type; s=default; bh=ye9gsceE0R GPfZQtypliUZZuI4c=; b=psJ0ubng45x5xldx35WuqUhR9o89lEnclp31SBNHDb +oTRnAjZJOh6bZPV6rwZ4moRcc7pt3AEzc6P/PhWiSpJ84LtJQjYqJDvBRXF8ST9 kcvP8csweryKxempjB9EwWl6X/ao+61gBlc39RN16fSkbRYwrcdyt8Ga0kq5yHtz U= Received: (qmail 46807 invoked by alias); 15 Jan 2020 05:10:14 -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 Received: (qmail 46797 invoked by uid 89); 15 Jan 2020 05:10:14 -0000 Authentication-Results: sourceware.org; auth=none X-HELO: mail-lj1-f172.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Q6Dw35cc60g6iv4iDmZvI4tik6zadO3vTLL71Clqa60=; b=O86XU+o48VhO0WjpKyosuQKvdIzDNTduhyWoNIKIOObE9o3IStyuWMJowhdzZotdUV +JT/ud8kZ8Ses7mZtCU5DncFQ53bir1+8Uy87/nxejf3orALfHPSKpU4Z98NomJoIJ2K AsQ2y8aPBRlL8puXg5lIUd2+aW2JWwf8MwB+2TVrnsajYsNiuD58UcVCNst6OzGUXwqb phhb2p9ezIu55eWwe/gkI0EKh10zVeXSVNrM/e18Mom1Ty/+w/gARNe5KSjiUDyAEbCk CZ2ucWgonUdsMoyzvaSvhUcAWD12y8z/NHIEt4ACcXE4qPLT9GQzhmUmeSiz754EH0Wi 1C2Q== MIME-Version: 1.0 References: <4e95f95966d8d7c6a8339160dc62d81c1f6a1bfb.1578824547.git.alistair.francis@wdc.com> <20200114130746.4bc56ee0@jawa> In-Reply-To: <20200114130746.4bc56ee0@jawa> From: Alistair Francis Date: Wed, 15 Jan 2020 15:09:33 +1000 Message-ID: Subject: Re: [RFC v6 07/23] RISC-V: Use 64-bit time_t and off_t for RV32 and RV64 To: Lukasz Majewski Cc: Alistair Francis , GNU C Library , Arnd Bergmann , Adhemerval Zanella , Florian Weimer , Joseph Myers , Palmer Dabbelt , "Maciej W. Rozycki" , Zong Li Content-Type: text/plain; charset="UTF-8" On Tue, Jan 14, 2020 at 10:07 PM Lukasz Majewski wrote: > > Hi Alistair, > > > 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 > > ^^^^^ kernel Fixed > > > 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. --- > > .../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 | 90 > > +++++++++++++++++++ sysdeps/unix/sysv/linux/riscv/kernel_stat.h | > > 23 +++++ 5 files changed, 256 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 > > create mode 100644 sysdeps/unix/sysv/linux/riscv/kernel_stat.h > > > > 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 0000000000..8d401d1976 > > --- /dev/null > > +++ b/sysdeps/unix/sysv/linux/riscv/bits/environments.h > > @@ -0,0 +1,85 @@ > > +/* Copyright (C) 1999-2020 Free Software Foundation, Inc. > > + This file is part of the GNU C Library. > > 2020 > > > + > > + 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 0000000000..cc21b45ef1 > > --- /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-2020 Free Software Foundation, Inc. > > + This file is part of the GNU C Library. > > 2020 ? > > > + > > + 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 0000000000..afb5d86b2b > > --- /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-2020 Free Software Foundation, Inc. > > + This file is part of the GNU C Library. > > + > > 2020 I have updated them all to "2019-2020" as I wrote it in 2019 and all the other glibc files seem to have a range for the copyright. Alistair > > > + 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 > > Ok. > > > 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 0000000000..0da3bdeb5d > > --- /dev/null > > +++ b/sysdeps/unix/sysv/linux/riscv/bits/typesizes.h > > @@ -0,0 +1,90 @@ > > +/* 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 > > + > > +/* And for fsblkcnt_t and fsfilcnt_t */ > > +# define __STATFS_MATCHES_STATFS64 1 > > + > > +/* And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. */ > > +# define __STATFS_MATCHES_STATFS64 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 */ > > diff --git a/sysdeps/unix/sysv/linux/riscv/kernel_stat.h > > b/sysdeps/unix/sysv/linux/riscv/kernel_stat.h new file mode 100644 > > index 0000000000..2c026f1b9c > > --- /dev/null > > +++ b/sysdeps/unix/sysv/linux/riscv/kernel_stat.h > > @@ -0,0 +1,23 @@ > > +/* Copyright (C) 2011-2020 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 > > + > > +#define STAT_IS_KERNEL_STAT 1 > > + > > +#define XSTAT_IS_XSTAT64 1 > > +#define STATFS_IS_STATFS64 0 > > > > > Best regards, > > Lukasz Majewski > > -- > > DENX Software Engineering GmbH, Managing Director: Wolfgang Denk > HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany > Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de