@@ -107,7 +107,9 @@ libc_hidden_proto (__timegm64)
#else
extern int __clock_settime64 (clockid_t clock_id,
const struct __timespec64 *tp);
-libc_hidden_proto (__clock_settime64)
+/* For Y2038 safe system the __clock_settime64 needs to be a visible
+ symbol as a replacement for Y2038 unsafe clock_settime()
+*/
#endif
/* Compute the `struct tm' representation of T,
@@ -29,6 +29,17 @@ __clock_settime64 (clockid_t clock_id, const struct __timespec64 *tp)
return -1;
}
+/* For being Y2038 safe we check if __TIMESIZE != 64 and run the
+ 64 bit syscall only when supported by the kernel.
+ As __clock_settime64() may be also called by 32 bit machine (not Y2038
+ safe) - in case of error - the default kernel syscall (clock_settime)
+ is executed */
+#if defined __NR_clock_settime64 && defined __TIMESIZE != 64
+ int retval = INLINE_SYSCALL_CALL (clock_settime64, clock_id, tp);
+ if (! retval)
+ return retval;
+#endif
+
return INLINE_SYSCALL_CALL (clock_settime, clock_id, tp);
}
@@ -222,6 +222,15 @@ extern int clock_gettime (clockid_t __clock_id, struct timespec *__tp) __THROW;
extern int clock_settime (clockid_t __clock_id, const struct timespec *__tp)
__THROW;
+#ifdef __USE_TIME_BITS64
+# if defined(__REDIRECT)
+extern int __REDIRECT (clock_settime, (clockid_t __clock_id, const struct
+ timespec *__tp), __clock_settime64) __THROW;
+# else
+# define clock_settime __clock_settime64
+# endif
+#endif
+
# ifdef __USE_XOPEN2K
/* High-resolution sleep with the specified clock.