unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Alistair Francis <alistair.francis@wdc.com>
Cc: GNU C Library <libc-alpha@sourceware.org>,
	 Adhemerval Zanella <adhemerval.zanella@linaro.org>,
	Florian Weimer <fweimer@redhat.com>,
	 Joseph Myers <joseph@codesourcery.com>,
	palmerdabbelt@google.com, macro@wdc.com,
	 Zong Li <zongbox@gmail.com>,
	Alistair Francis <alistair23@gmail.com>
Subject: Re: [RFC v6 06/23] sysdeps: Use long types with 64-bit time_t on 32-bit archs
Date: Sun, 12 Jan 2020 22:41:02 +0100	[thread overview]
Message-ID: <CAK8P3a0d8SVdOn4GF+-EoKbCH46y_ZBviVLYAVosC9rxqCZ3fw@mail.gmail.com> (raw)
In-Reply-To: <96c5552629ae8b306cff4b5cef44ba00634276d2.1578824547.git.alistair.francis@wdc.com>

On Sun, Jan 12, 2020 at 11:40 AM Alistair Francis
<alistair.francis@wdc.com> wrote:
>
> If we are using a 32-bit architecture with a 64-bit time_t let's
> define __SEM_PAD_BEFORE_TIME as 1. This is because the kernel is
> expecting a type __kernel_old_time_t which is 32-bit even with a
> 64-bit time_t. Instead of adding another check, let's just set
> __SEM_PAD_BEFORE_TIME as that will use a long type instead of
> long long.

I think you need to do this differently to avoid truncating the timestamp
to 32 bit. The type in the generic kernel headers for 32-bit targets is not
'__kernel_old_time_t sem_otime; __kernel_long_t pad' but it is
'unsigned long sem_otime; unsigned long sem_otime_high;'.

Both need to be combined to read the 64-bit time_t value. It should
be possible to do this in an architecture independent way, but note
that the two halves are not always adjacent or in the correct order,
and in one case (mips shmbuf) the high word is only 16 bit instead
of 32.

          Arnd

> ---
>  sysdeps/unix/sysv/linux/bits/sem-pad.h | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/sysdeps/unix/sysv/linux/bits/sem-pad.h b/sysdeps/unix/sysv/linux/bits/sem-pad.h
> index 566ce039cc..4b419a6100 100644
> --- a/sysdeps/unix/sysv/linux/bits/sem-pad.h
> +++ b/sysdeps/unix/sysv/linux/bits/sem-pad.h
> @@ -30,4 +30,15 @@
>     layout conversions for this structure.  */
>
>  #define __SEM_PAD_AFTER_TIME (__TIMESIZE == 32)
> -#define __SEM_PAD_BEFORE_TIME 0
> +
> +/* If we are using a 32-bit architecture with a 64-bit time_t let's
> +   define __SEM_PAD_BEFORE_TIME as 1. This is because the kernel is
> +   expecting a type __kernel_old_time_t which is 32-bit even with a
> +   64-bit time_t. Instead of adding another check, let's just set
> +   __SEM_PAD_BEFORE_TIME as that will use a long type instead of
> +   long long.  */
> +#if __WORDSIZE == 32 && __TIMESIZE == 64
> +# define __SEM_PAD_BEFORE_TIME 1
> +#else
> +# define __SEM_PAD_BEFORE_TIME 0
> +#endif
> --
> 2.24.1
>

  reply	other threads:[~2020-01-12 21:41 UTC|newest]

Thread overview: 138+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-12 10:33 [RFC v6 00/23] RISC-V glibc port for the 32-bit Alistair Francis
2020-01-12 10:33 ` [RFC v6 01/23] math/gen-libm-test.py: Convert to Python 3 Alistair Francis
2020-01-12 14:46   ` Joseph Myers
2020-01-14  6:53     ` Alistair Francis
2020-01-12 10:33 ` [RFC v6 02/23] tst-clone3: Use __NR_futex_time64 if we don't have __NR_futex Alistair Francis
2020-01-12 10:33 ` [RFC v6 03/23] time: Add a timeval with a long tv_sec and tv_usec Alistair Francis
2020-01-12 14:48   ` Joseph Myers
2020-01-14  7:18     ` Alistair Francis
2020-01-14 11:27       ` Lukasz Majewski
2020-01-14 10:16   ` Lukasz Majewski
2020-01-15  5:15     ` Alistair Francis
2020-01-15  8:01       ` Arnd Bergmann
2020-01-15  8:48       ` Lukasz Majewski
2020-01-12 10:33 ` [RFC v6 04/23] linux: Use 32-bit time_t for itimerval Alistair Francis
2020-01-14 10:58   ` Lukasz Majewski
2020-01-15 23:39     ` Alistair Francis
2020-01-16  1:21       ` Joseph Myers
2020-01-16  1:33         ` Alistair Francis
2020-01-16 13:34           ` Lukasz Majewski
2020-01-17  6:39             ` Alistair Francis
2020-01-17 11:14               ` Lukasz Majewski
2020-01-17 12:03                 ` Alistair Francis
2020-01-17 12:19                   ` Lukasz Majewski
2020-01-17 14:14                   ` Joseph Myers
2020-01-16 16:19           ` Joseph Myers
2020-01-17  6:40             ` Alistair Francis
2020-01-12 10:33 ` [RFC v6 05/23] linux: Use 32-bit time_t for rusage Alistair Francis
2020-01-14 11:58   ` Lukasz Majewski
2020-01-15 23:42     ` Alistair Francis
2020-01-12 10:33 ` [RFC v6 06/23] sysdeps: Use long types with 64-bit time_t on 32-bit archs Alistair Francis
2020-01-12 21:41   ` Arnd Bergmann [this message]
2020-01-16  7:30     ` Alistair Francis
2020-01-16  7:41       ` Alistair Francis
2020-01-16  8:36       ` Arnd Bergmann
2020-01-16 22:16         ` Alistair Francis
2020-01-16 22:41           ` Joseph Myers
2020-01-12 10:33 ` [RFC v6 07/23] RISC-V: Use 64-bit time_t and off_t for RV32 and RV64 Alistair Francis
2020-01-14 12:07   ` Lukasz Majewski
2020-01-15  5:09     ` Alistair Francis
2020-02-12  0:14   ` Vineet Gupta
2020-02-12  0:14     ` Alistair Francis
2020-02-12  1:30       ` Joseph Myers
2020-02-14 22:39         ` Alistair Francis
2020-02-18 23:05           ` 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) Vineet Gupta
2020-02-18 23:13             ` Joseph Myers
2020-02-19 23:09               ` Lukasz Majewski
2020-02-19 23:11             ` Lukasz Majewski
2020-02-20  8:31               ` Arnd Bergmann
2020-02-20  9:37                 ` Lukasz Majewski
2020-02-20 12:37                   ` Arnd Bergmann
2020-02-20 13:14                     ` Lukasz Majewski
2020-02-20 14:44                       ` Arnd Bergmann
2020-02-20 15:42                         ` Lukasz Majewski
2020-02-20 16:08                           ` Arnd Bergmann
2020-02-20 16:31                             ` Lukasz Majewski
2020-02-24  2:48                         ` Viresh Kumar
2020-02-21 19:56                     ` Alistair Francis
2020-02-22  8:42                   ` Arnd Bergmann
2020-02-24  9:00                     ` Lukasz Majewski
2020-02-24  9:46                       ` Andreas Schwab
2020-02-24 10:14                         ` Lukasz Majewski
2020-02-24 10:23                           ` Andreas Schwab
2020-02-24 10:36                             ` Lukasz Majewski
2020-02-24 10:42                               ` Andreas Schwab
2020-02-24 11:13                                 ` Lukasz Majewski
2020-02-24 12:41                                   ` Lukasz Majewski
2020-02-25  0:03                               ` Joseph Myers
2020-02-25 11:39                                 ` Lukasz Majewski
2020-02-25 14:36                                   ` Joseph Myers
2020-02-26 13:18                                     ` Lukasz Majewski
2020-02-26 14:48                                       ` Joseph Myers
2020-02-26 16:28                                         ` Lukasz Majewski
2020-02-25  9:03                       ` Arnd Bergmann
2020-02-20 16:27                 ` Helmut Grohne
2020-03-26  0:25                   ` ARC rebootstrap prereq (was Re: switching ARC to 64-bit time_t ) Vineet Gupta via Libc-alpha
2020-03-26  5:54                     ` Helmut Grohne
2020-03-26 11:51                       ` Alexey Brodkin via Libc-alpha
2020-03-26 12:24                         ` Helmut Grohne
2020-03-26 12:53                           ` Alexey Brodkin via Libc-alpha
2020-03-26 14:28                             ` Helmut Grohne
2020-03-26 19:04                               ` Lennart Sorensen via Libc-alpha
2020-08-26 14:39                       ` Vineet Gupta via Libc-alpha
2020-08-26 15:43                         ` Helmut Grohne
2020-08-26 21:16                           ` Aurelien Jarno
2021-02-24 20:17                             ` Vineet Gupta via Libc-alpha
2021-02-26  9:47                               ` Helmut Grohne
2021-02-26 15:58                                 ` Vineet Gupta via Libc-alpha
2021-08-21 17:36                             ` Aurelien Jarno
2020-02-12  1:42       ` [RFC v6 07/23] RISC-V: Use 64-bit time_t and off_t for RV32 and RV64 Vineet Gupta
2020-02-12 12:58         ` Arnd Bergmann
2020-02-19  0:56   ` Vineet Gupta
2020-02-19  1:03     ` Alistair Francis
2020-02-19  1:31       ` Vineet Gupta
2020-02-19  8:30         ` Andreas Schwab
2020-02-19 18:42           ` Vineet Gupta
2020-02-19 23:18             ` Lukasz Majewski
2020-02-20  0:26               ` Vineet Gupta
2020-02-20  0:46                 ` Joseph Myers
2020-02-20  8:24                   ` Arnd Bergmann
2020-02-20 10:28                     ` Lukasz Majewski
2020-02-20 14:14                     ` Joseph Myers
2020-01-12 10:33 ` [RFC v6 08/23] RISC-V: Define __NR_* as __NR_*_time64/64 for 32-bit Alistair Francis
2020-01-13 13:39   ` Arnd Bergmann
2020-01-14  7:14     ` Alistair Francis
2020-01-14 12:47       ` Arnd Bergmann
2020-01-15  7:03         ` Alistair Francis
2020-01-25 20:33           ` Khem Raj
2020-01-27  8:39             ` Arnd Bergmann
2020-01-27 10:02               ` Florian Weimer
2020-01-27 13:11                 ` Arnd Bergmann
2020-01-27 13:17                   ` Florian Weimer
2020-01-27 14:08                     ` Arnd Bergmann
2020-01-12 10:33 ` [RFC v6 09/23] RISC-V: Add support for 32-bit vDSO calls Alistair Francis
2020-01-13 13:33   ` Arnd Bergmann
2020-01-14  7:23     ` Alistair Francis
2020-01-12 10:33 ` [RFC v6 10/23] RISC-V: Add socket-constants.h for RV32 Alistair Francis
2020-01-12 10:34 ` [RFC v6 11/23] RISC-V: Support dynamic loader for the 32-bit Alistair Francis
2020-01-12 10:34 ` [RFC v6 12/23] RISC-V: Add path of library directories " Alistair Francis
2020-01-12 10:34 ` [RFC v6 13/23] RISC-V: Add arch-syscall.h for RV32 Alistair Francis
2020-01-12 10:34 ` [RFC v6 14/23] RISC-V: The ABI implementation for the 32-bit Alistair Francis
2020-01-12 10:34 ` [RFC v6 15/23] RISC-V: Hard float support for 32-bit Alistair Francis
2020-01-12 10:34 ` [RFC v6 16/23] RISC-V: Add ABI lists Alistair Francis
2020-01-12 10:34 ` [RFC v6 17/23] RISC-V: Add the RV32 libm-test-ulps Alistair Francis
2020-01-12 10:34 ` [RFC v6 18/23] RISC-V: Fix llrint and llround missing exceptions on RV32 Alistair Francis
2020-01-12 10:34 ` [RFC v6 19/23] RISC-V: Build Infastructure for 32-bit Alistair Francis
2020-01-12 10:34 ` [RFC v6 20/23] riscv32: Specify the arch_minimum_kernel as 5.4 Alistair Francis
2020-01-12 10:56   ` Andreas Schwab
2020-01-14  7:25     ` Alistair Francis
2020-01-14  9:03       ` Andreas Schwab
2020-01-12 10:34 ` [RFC v6 21/23] RISC-V: Add rv32 path to RTLDLIST in ldd Alistair Francis
2020-01-12 10:34 ` [RFC v6 22/23] Documentation for the RISC-V 32-bit port Alistair Francis
2020-01-12 10:34 ` [RFC v6 23/23] Add RISC-V 32-bit target to build-many-glibcs.py Alistair Francis
2020-01-12 14:44 ` [RFC v6 00/23] RISC-V glibc port for the 32-bit Joseph Myers
2020-01-14  7:30   ` Alistair Francis
2020-01-14 22:08     ` Joseph Myers
2020-01-15  4:30       ` Alistair Francis
2020-01-15 21:50         ` Joseph Myers
2020-01-15 23:50           ` Alistair Francis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/libc/involved.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAK8P3a0d8SVdOn4GF+-EoKbCH46y_ZBviVLYAVosC9rxqCZ3fw@mail.gmail.com \
    --to=arnd@arndb.de \
    --cc=adhemerval.zanella@linaro.org \
    --cc=alistair.francis@wdc.com \
    --cc=alistair23@gmail.com \
    --cc=fweimer@redhat.com \
    --cc=joseph@codesourcery.com \
    --cc=libc-alpha@sourceware.org \
    --cc=macro@wdc.com \
    --cc=palmerdabbelt@google.com \
    --cc=zongbox@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).