about summary refs log tree commit diff
path: root/time/offtime.c
diff options
context:
space:
mode:
authorAlbert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>2018-06-18 21:14:43 +0200
committerAlbert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>2018-10-24 12:22:08 +0200
commitc2f8573148d9264cc1b93426273781838da52788 (patch)
treeb34a8bf48beb4ee2a5711c8c4f269ef67d7034c7 /time/offtime.c
parent7e900af37b47cc6526ca6b8c09e9b34825d16ff6 (diff)
downloadglibc-c2f8573148d9264cc1b93426273781838da52788.tar.gz
glibc-c2f8573148d9264cc1b93426273781838da52788.tar.xz
glibc-c2f8573148d9264cc1b93426273781838da52788.zip
Y2038: make __tz_convert compatible with 64-bit-time
Now that __time64_t exists, we can switch internal function
__tz_convert from 32-bit to 64-bit time. This involves switching
some other internal functions and turning some implementations
which use these into wrappers between public 32-bit and internal
64-bit time.

This patch was tested by running 'make check' on branch
master then applying this patch and its two predecessors and
running 'make check' again, and checking that both 'make check'
yield identical results. This was done on x86_64-linux-gnu and
i686-linux-gnu.

	* include/time.h
	(__tz_compute): Replace time_t with __time64_t.
	(__ctime64): Add.
	(__ctime64_r): Likewise.
	(__localtime64): Likewise.
	(__localtime64_r): Likewise.
	(__gmtime64): Likewise.
	(__gmtime64_r): Likewise.
	(__offtime): Replace const time_t* argument with __time64_t.
	(__tz_convert): Likewise.
	* time/ctime.c
	(__ctime64): Add.
	(__ctime): Turn into a wrapper.
	* time/ctime_r.c
	(__ctime64_r): Add.
	(__ctime_r): Turn into a wrapper.
	* time/gmtime.c
	(__gmtime64): Add.
	(__gmtime): Turn into a wrapper.
	(__gmtime64_r): Add.
	(__gmtime_r): Turn into a wrapper.
	* time/localtime.c
	(__localtime64): Add.
	(__localtime): Turn into a wrapper.
	(__localtime64_r): Add.
	(__localtime_r): Turn into a wrapper.
	* time/offtime.c: Replace all time_t occurrences with __time64_t.
	(__offtime): Replace const time_t* argument with __time64_t.
	* time/tzfile.c
	(__tzfile_compute): Adjust __offtime() call arguments.
	* time/tzset.c: Replace all time_t occurrences with __time64_t.
	(__tz_convert): Adjust __tzfile_compute and __tz_compute call arguments.
Diffstat (limited to 'time/offtime.c')
-rw-r--r--time/offtime.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/time/offtime.c b/time/offtime.c
index 04c48389fc..3309fcd484 100644
--- a/time/offtime.c
+++ b/time/offtime.c
@@ -21,18 +21,18 @@
 #define	SECS_PER_HOUR	(60 * 60)
 #define	SECS_PER_DAY	(SECS_PER_HOUR * 24)
 
-/* Compute the `struct tm' representation of *T,
+/* Compute the `struct tm' representation of T,
    offset OFFSET seconds east of UTC,
    and store year, yday, mon, mday, wday, hour, min, sec into *TP.
    Return nonzero if successful.  */
 int
-__offtime (const time_t *t, long int offset, struct tm *tp)
+__offtime (__time64_t t, long int offset, struct tm *tp)
 {
-  time_t days, rem, y;
+  __time64_t days, rem, y;
   const unsigned short int *ip;
 
-  days = *t / SECS_PER_DAY;
-  rem = *t % SECS_PER_DAY;
+  days = t / SECS_PER_DAY;
+  rem = t % SECS_PER_DAY;
   rem += offset;
   while (rem < 0)
     {
@@ -60,7 +60,7 @@ __offtime (const time_t *t, long int offset, struct tm *tp)
   while (days < 0 || days >= (__isleap (y) ? 366 : 365))
     {
       /* Guess a corrected year, assuming 365 days per year.  */
-      time_t yg = y + days / 365 - (days % 365 < 0);
+      __time64_t yg = y + days / 365 - (days % 365 < 0);
 
       /* Adjust DAYS and Y to match the guessed year.  */
       days -= ((yg - y) * 365