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-12-05 21:01:22 +0100
committerAlbert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>2018-12-05 21:01:22 +0100
commit72b8692d7e640eb85ea0fb7de6d5e797512691c1 (patch)
tree5e98d09fcf975415b8cac7237764d565f6ebddaa /time/offtime.c
parentbd598da9f454bc1091b4ebe0303b07e6f96ca130 (diff)
downloadglibc-72b8692d7e640eb85ea0fb7de6d5e797512691c1.tar.gz
glibc-72b8692d7e640eb85ea0fb7de6d5e797512691c1.tar.xz
glibc-72b8692d7e640eb85ea0fb7de6d5e797512691c1.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 as well, namely __tz_compute and
__offtime.

Tested with 'make check' on x86_64-linux-gnu and i686-linux.gnu.

	* include/time.h
	(__tz_compute): Replace time_t with __time64_t.
	(__tz_convert): Replace time_t* with __time64_t.
	(__offtime): Replace time_t* with __time64_t.
	* time/gmtime.c
	(__gmtime_r): Adjust call to __tz_convert.
	(gmtime): Likewise.
	* time/localtime.c
	(__localtime_r): Likewise.
	(localtime): Likewise.
	* time/offtime.c: Replace time_t with __time64_t.
	* time/tzset.c: Likewise.
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