summaryrefslogtreecommitdiff
path: root/time/ctime_r.c
diff options
context:
space:
mode:
authorAlbert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>2018-04-11 21:32:34 +0200
committerAlbert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>2018-06-15 20:05:16 +0200
commit66f277a3a40f369ca8e583d410f5f7771da5aa61 (patch)
tree4b1b7e57f3fdd33bd8d75fa97a160ddecb5088db /time/ctime_r.c
parent38a873073548a9a52136067df65cf47103e3342b (diff)
downloadglibc-aaribaud/tmp.tar.gz
Y2038: make __tz_convert compatible with 64-bit-timeaaribaud/tmp
This implies that its callers be 64-bit-time compatible too. It is done by creating 64-bit-time versions of these and turning their original 32-bit-time versions into wrappers (at a slight execution time cost). The callers affected are: * localtime * localtime_r * ctime * ctime_r * gmtime * gmtime_r Note that in time/tzfile.c we do not need to check for time_t overflows anymore as introduced by commit fc79706a323 since we now use internal_time_t.
Diffstat (limited to 'time/ctime_r.c')
-rw-r--r--time/ctime_r.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/time/ctime_r.c b/time/ctime_r.c
index c111146d76..e731b53a77 100644
--- a/time/ctime_r.c
+++ b/time/ctime_r.c
@@ -18,12 +18,26 @@
<http://www.gnu.org/licenses/>. */
#include <time.h>
+#include <errno.h>
/* Return a string as returned by asctime which is the representation
- of *T in that form. Reentrant version. */
+ of *T in that form. */
char *
-ctime_r (const time_t *t, char *buf)
+__ctime64_r (const __time64_t *t, char *buf)
{
struct tm tm;
- return __asctime_r (__localtime_r (t, &tm), buf);
+ return __asctime_r (__localtime64_r (t, &tm), buf);
}
+
+/* Provide a 32-bit wrapper if needed */
+
+#if __TIMESIZE != 64
+
+char *
+ctime_r (const time_t *t, char *buf)
+{
+ __time64_t t64 = *t;
+ return __ctime64_r (&t64, buf);
+}
+
+#endif