public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Alistair Francis <alistair23@gmail.com>
Cc: Joseph Myers <joseph@codesourcery.com>,
	Alistair Francis <alistair.francis@wdc.com>,
	 GNU C Library <libc-alpha@sourceware.org>,
	 Adhemerval Zanella <adhemerval.zanella@linaro.org>,
	Florian Weimer <fweimer@redhat.com>,
	 Palmer Dabbelt <palmer@sifive.com>,
	macro@wdc.com, Zong Li <zongbox@gmail.com>,
	 Zong Li <zong@andestech.com>
Subject: Re: [RFC v2 07/20] sysdeps/gettimeofday: Use clock_gettime64 if avaliable
Date: Thu, 25 Jul 2019 12:57:00 -0000	[thread overview]
Message-ID: <CAK8P3a0f-N6DsjjBAvY-Y3sza703fYe55h7pVzhvZXGEqe7G-Q@mail.gmail.com> (raw)
In-Reply-To: <CAKmqyKP1EGAqQE+vvOH=wp5dp+YH=GofLTniU_wFeLT4BDp4oQ@mail.gmail.com>

On Thu, Jul 25, 2019 at 1:03 AM Alistair Francis <alistair23@gmail.com> wrote:
>
> On Wed, Jul 24, 2019 at 1:22 PM Joseph Myers <joseph@codesourcery.com> wrote:
> >
> > On Mon, 24 Jun 2019, Alistair Francis wrote:
> >
> > > Not all architectures support the obsolete gettimeofday so use the
> > > newer clock_gettime64 syscall if it is avaliable. This fixes RV32
> > > build issues.
> >
> > A key question when using newer syscalls to implement gettimeofday or
> > settimeofday, which the commit message needs to answer, is: what are the
> > semantics for how the obsolete tz argument is handled, if not NULL?
> >
> > I'd expect the proposed commit message to include a discussion of what the
> > semantics are for that obsolete argument in Linux kernel versions
> > supported by glibc, and what the semantics are for that argument in glibc
> > when some other syscall gets used by glibc.
>
> Yep, I missed this. I have already added it to the commit message of
> the next version.
>
>     This has the side effect of not setting the struct timezone *tz variable
>     if __ASSUME_TIME64_SYSCALLS or __NR_clock_gettime64 is defined. There
>     are two things to consider here:
>      - 32-bit systems with __ARCH_WANT_TIME32_SYSCALLS not defined have to
>        way to get the struct timezone via a syscall.
>      - The Linux documentation says that "The use of the timezone structure
>        is obsolete; the tz argument should normally be specified as NULL."
>        So let's not worry about it.

That's fine with me, but I would like to point out that the omission of the
timezone get/set interfaces was not intentional. I think I considered the
POSIX man page (which says undefined behavior) and I ported musl
over (which ignores the timezone argument), but I did not realize that
glibc passes it on and that there are applications that make use of that.

Using debian code search, I found hwclock as something that sets
the timezone at boot, and there are a small number of kernel files that
use the information at runtime (full list below). If we want to keep
the traditional settimeofday()/gettimeofday() behavior working, a new
kernel interface could be added, e.g. in one of the reserved fields
of clock_adjtime(), or as a new syscall.

       Arnd
---
drivers/media/platform/vivid/vivid-rds-gen.c:
(sys_tz.tz_minuteswest >= 0 ? 0x20 : 0) |
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c:
record->end_utc_bias = cpu_to_le16(sys_tz.tz_minuteswest * 60);
drivers/scsi/3w-9xxx.c: local_time = (u32)(ktime_get_real_seconds() -
(sys_tz.tz_minuteswest * 60));
drivers/scsi/3w-sas.c:  local_time = (u32)(ktime_get_real_seconds() -
(sys_tz.tz_minuteswest * 60));
drivers/scsi/aacraid/commsup.c: local_time = (now->tv_sec -
(sys_tz.tz_minuteswest * 60));
drivers/scsi/arcmsr/arcmsr_hba.c:
time64_to_tm(ktime_get_real_seconds(), -sys_tz.tz_minuteswest * 60,
&tm);
drivers/scsi/mvumi.c:           local_time = (time -
(sys_tz.tz_minuteswest * 60));
drivers/scsi/smartpqi/smartpqi_init.c:  time64_to_tm(local_time,
-sys_tz.tz_minuteswest * 60, &tm);
fs/affs/amigaffs.c:     secs -= sys_tz.tz_minuteswest * 60 + ((8 * 365
+ 2) * 24 * 60 * 60);
fs/affs/inode.c:                         sys_tz.tz_minuteswest * 60;
fs/fat/misc.c:         sys_tz.tz_minuteswest) * SECS_PER_MIN;
fs/hfs/hfs_fs.h:        return ut + sys_tz.tz_minuteswest * 60;
fs/hfs/inode.c: HFS_I(inode)->tz_secondswest = sys_tz.tz_minuteswest * 60;
fs/hfs/sysdep.c:        diff = sys_tz.tz_minuteswest * 60 -
HFS_I(inode)->tz_secondswest;
fs/hpfs/hpfs_fn.h:      return t + sys_tz.tz_minuteswest * 60 +
hpfs_sb(s)->sb_timeshift;
fs/udf/udftime.c:       offset = -sys_tz.tz_minuteswest;
kernel/debug/kdb/kdb_main.c:            sys_tz.tz_minuteswest);
kernel/time/ntp.c:              adjust.tv_sec -= (sys_tz.tz_minuteswest * 60);
kernel/time/timekeeping.c:      if (sys_tz.tz_minuteswest != 0) {
kernel/time/vsyscall.c:         vdata[CS_HRES_COARSE].tz_minuteswest =
sys_tz.tz_minuteswest;
lib/vdso/gettimeofday.c:                tz->tz_minuteswest =
vd[CS_HRES_COARSE].tz_minuteswest;
net/netfilter/xt_time.c:                stamp -= 60 * sys_tz.tz_minuteswest;

  reply	other threads:[~2019-07-25 12:57 UTC|newest]

Thread overview: 107+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-25  0:11 [RFC v2 00/20] RISC-V glibc port for the 32-bit Alistair Francis
2019-06-25  0:11 ` [RFC v2 10/20] Documentation for the RISC-V 32-bit port Alistair Francis
2019-06-25  0:11 ` [RFC v2 03/20] y2038: linux: Provide __clock_settime64 implementation Alistair Francis
2019-06-25 11:05   ` Arnd Bergmann
2019-06-25 15:51     ` Lukasz Majewski
2019-06-25 16:39       ` Arnd Bergmann
2019-06-26  9:07         ` Lukasz Majewski
2019-06-26 12:36           ` Arnd Bergmann
2019-06-26 15:04             ` Lukasz Majewski
2019-06-26 15:11               ` Florian Weimer
2019-06-26 22:49                 ` Lukasz Majewski
2019-06-27  7:15                   ` Florian Weimer
2019-06-27  7:37                     ` Lukasz Majewski
2019-06-26 18:58               ` Arnd Bergmann
2019-06-26 22:55                 ` Lukasz Majewski
2019-06-27  7:46                   ` Arnd Bergmann
2019-06-27 10:36                     ` Lukasz Majewski
2019-06-27 13:32                       ` Arnd Bergmann
2019-06-27 14:08                         ` Lukasz Majewski
2019-06-27 14:57                           ` Arnd Bergmann
2019-06-27 15:23                             ` Lukasz Majewski
2019-06-27 15:46                               ` Arnd Bergmann
2019-06-27 16:17                                 ` Lukasz Majewski
2019-06-27 21:26                                   ` Arnd Bergmann
2019-06-27 22:08                                     ` Lukasz Majewski
2019-07-04  0:08                                       ` Alistair Francis
2019-07-04  8:13                                         ` Lukasz Majewski
2019-07-08  9:32                                           ` Lukasz Majewski
2019-06-27 20:11                           ` Alistair Francis
2019-06-27 21:02                             ` Lukasz Majewski
2019-07-08 10:49         ` Joseph Myers
2019-06-25  0:11 ` [RFC v2 05/20] sysdeps/nanosleep: Use clock_nanosleep_time64 if avaliable Alistair Francis
2019-06-25  8:24   ` Andreas Schwab
2019-06-25  8:59   ` Arnd Bergmann
2019-06-26 18:23     ` Alistair Francis
2019-06-25  0:11 ` [RFC v2 12/20] RISC-V: Support dynamic loader for the 32-bit Alistair Francis
2019-06-25  0:11 ` [RFC v2 02/20] y2038: Provide conversion helpers for struct __timespec64 Alistair Francis
2019-06-25  0:11 ` [RFC v2 01/20] y2038: Introduce internal for glibc " Alistair Francis
2019-06-25  0:11 ` [RFC v2 07/20] sysdeps/gettimeofday: Use clock_gettime64 if avaliable Alistair Francis
2019-06-27 13:15   ` Adhemerval Zanella
2019-07-03 23:52     ` Alistair Francis
2019-07-24 20:22   ` Joseph Myers
2019-07-24 23:03     ` Alistair Francis
2019-07-25 12:57       ` Arnd Bergmann [this message]
2019-07-25 17:03         ` Paul Eggert
2019-07-25 17:21           ` Zack Weinberg
2019-07-25 18:53             ` Arnd Bergmann
2019-07-26 13:01               ` Florian Weimer
2019-07-26 13:08                 ` Zack Weinberg
2019-07-25 21:23       ` Joseph Myers
2019-06-25  0:11 ` [RFC v2 13/20] RISC-V: Add path of library directories for the 32-bit Alistair Francis
2019-06-25  0:12 ` [RFC v2 20/20] Add RISC-V 32-bit target to build-many-glibcs.py Alistair Francis
2019-06-25  0:12 ` [RFC v2 04/20] include/time.h: Fix conflicting timespec types on 32-bit Alistair Francis
2019-06-25 11:17   ` Arnd Bergmann
2019-06-25 22:23     ` Alistair Francis
2019-06-25  0:12 ` [RFC v2 09/20] sysdeps/getrlimit: Use prlimit64 if avaliable Alistair Francis
2019-06-25 11:11   ` Florian Weimer
2019-06-25 20:48     ` Alistair Francis
2019-06-25 21:10       ` Florian Weimer
2019-06-25 23:41         ` Alistair Francis
2019-06-25  0:12 ` [RFC v2 18/20] RISC-V: Build Infastructure for the 32-bit Alistair Francis
2019-06-25  0:12 ` [RFC v2 16/20] RISC-V: Regenerate ULPs of RISC-V Alistair Francis
2019-06-25  0:12 ` [RFC v2 11/20] RISC-V: Use 64-bit time_t and off_t for RV32 and RV64 Alistair Francis
2019-06-25  0:12 ` [RFC v2 19/20] RISC-V: Fix llrint and llround missing exceptions on RV32 Alistair Francis
2019-06-25  0:12 ` [RFC v2 08/20] sysdeps/wait: Use waitid if avaliable Alistair Francis
2019-06-25  8:16   ` Andreas Schwab
2019-06-25 10:55   ` Zack Weinberg
2019-06-25 11:06     ` Florian Weimer
2019-06-25 12:01       ` Arnd Bergmann
2019-06-25 12:10         ` Florian Weimer
2019-06-25 13:30           ` Arnd Bergmann
2019-06-25 13:39             ` Arnd Bergmann
2019-06-25 13:47               ` Florian Weimer
2019-06-25 14:05                 ` Arnd Bergmann
2019-06-25 14:08                   ` Florian Weimer
2019-06-25 14:21                     ` Arnd Bergmann
2019-06-25 14:29                       ` Florian Weimer
2019-06-26 14:38                         ` Arnd Bergmann
2019-06-26 15:48                           ` Florian Weimer
2019-06-26 16:28                             ` Andreas Schwab
2019-07-08 12:10                               ` Florian Weimer
2019-07-08 12:34                                 ` Andreas Schwab
2019-07-08 12:37                                   ` Florian Weimer
2019-07-09 23:00                                     ` Alistair Francis
2019-07-10  7:34                                       ` Andreas Schwab
2019-07-10 17:51                                         ` Alistair Francis
2019-07-25 15:49                                     ` Joseph Myers
2019-06-26 21:08                             ` Arnd Bergmann
2019-06-27  7:33                               ` Florian Weimer
2019-06-27  8:25                                 ` Andreas Schwab
2019-06-27 10:21                                 ` Arnd Bergmann
2019-06-27 11:12                                   ` Florian Weimer
2019-06-27 15:24                                     ` Arnd Bergmann
2019-07-03 23:53                                       ` Alistair Francis
2019-06-25 23:54         ` Alistair Francis
2019-06-25  0:12 ` [RFC v2 17/20] RISC-V: Add ABI lists Alistair Francis
2019-06-25  0:12 ` [RFC v2 15/20] RISC-V: Hard float support for the 32 bit Alistair Francis
2019-06-25  0:12 ` [RFC v2 06/20] sysdeps/futex: Use futex_time64 if avaliable Alistair Francis
2019-06-25 11:14   ` Florian Weimer
2019-06-25 11:26     ` Andreas Schwab
2019-06-25 11:41       ` Arnd Bergmann
2019-06-25 12:07         ` Florian Weimer
2019-06-25 13:32           ` Arnd Bergmann
2019-06-25  0:12 ` [RFC v2 14/20] RISC-V: The ABI implementation for the 32-bit Alistair Francis
2019-06-25 11:16 ` [RFC v2 00/20] RISC-V glibc port " Florian Weimer
2019-06-25 12:08   ` Arnd Bergmann
2019-07-04  8:47 ` Jim Wilson

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

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

  git send-email \
    --in-reply-to=CAK8P3a0f-N6DsjjBAvY-Y3sza703fYe55h7pVzhvZXGEqe7G-Q@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=palmer@sifive.com \
    --cc=zong@andestech.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).