[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ✘64-bit time_t on glibc 2.34 and up

From: Gary E. Miller
Subject: Re: ✘64-bit time_t on glibc 2.34 and up
Date: Fri, 13 Jan 2023 16:33:25 -0800

Yo All!

Looks like there are four cases to support with shmTime:

1: 64-bit time_t with 64-bit ints:
      All known 64-bit distros (?)
      Works after 2038
      No change required.

2: 64-bit time_t with 32-bit ints:
      All *BSD (?)
      Works after 2038
      No change required.

3: 32-bit time_t with 32-bit ints,  No #define to get 64-bit time_t
      glibc version 2.33 and before
      Fails in 2038
      No change possible

4: Optional 64-bit time_t with 32-bit ints. #define to get 64-bit time_t
      glibc version 2.34 and later
      Works after 2038
      Incompatible with unmodified chrinyd, ntpd, htpshmmon, etc.
      Fix possible.

So, looking only at option 4.  The one that we can improve.

I had over looked the "int dummy[8]" in shmTime that Richard pointed out.
CUrrently gpsd has set those fields to 0.

In that case, and only that case, change shmTime as follows:


struct shmTime
    time_t receiveTimeStampSec;
    int             dummy[8];


struct shmTime
    // because we use 64-bit time_t, but ntpd expects 32-bits
    // ignore the sign bit
    int receiveTimeStampSec;    // lower 31-bits of 64-bit time_t
    // use the first dummy, previously zero
    int             top_time_t;  // upper bits of 64-bit time_t
    int             dummy[7];

Before 2038, top_time_t will always be zero.
After 2038, until 2106, top_time_t will be always one.

That maintains compatibility with existing SHM users.
That works with existing SHM users until 2038.
That works with modified SHM users until the end of 64 bit time.


No ideas about chronyd sockets yet.

Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97703  Tel:+1 541 382 8588

            Veritas liberabit vos. -- Quid est veritas?
    "If you can't measure it, you can't improve it." - Lord Kelvin

Attachment: pgpSQ4Pf4yWhR.pgp
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]