Re: [PATCH 2/2] git-compat-util: use gettimeofday for current time

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

 



On 3/20/23 10:01, Junio C Hamano wrote:

I however wonder if we should follow our
usual pattern of implementing git_time() with the identical function
signature as what we replace (i.e. system's time()), and #undef/#define
the symbol we replace with git_time, though.  Wouldn't it make [1/2]
a lot smaller and future-proof?

Yes, something like that would work too. (Sorry, I didn't know about the usual pattern.)


+# Define OVERRIDE_TIME to override time(2) and replace it with an
+# implementation based on gettimeofday(2).  THis is necessary when
+# glibc 2.31+ on Linux is used, where in the first 1 to 2.5 ms of
+# every second, time(NULL) returns a value that is one less than the
+# tv_sec part of higher-resolution timestamps used in the file system.

THis -> This

It might be simpler to use the gettimeofday workaround on all platforms, rather than having an OVERRIDE_TIME flag and complicating config.mak.uname. gettimeofday should be portable, as it's already used elsewhere in Git without configury.

If we're going with the more-complicated solution, config.mak.uname will need changes in its AIX and MS-Windows sections because the problem is known to occur there too. Although AIX configuration is simple, I'm not sure how to go about the MS-Windows part as there seem to be a lot of ifdefs there. Also, because the time problem does not occur with musl libc (used in Alpine Linux 3.17), on the Linux side the workaround could be employed only if glibc 2.31+ is in use.




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux