This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC v2 07/20] sysdeps/gettimeofday: Use clock_gettime64 if avaliable


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;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]