From a9acb7b39ed21386142b963aeecc35e0b468c0de Mon Sep 17 00:00:00 2001 From: YunQiang Su Date: Tue, 8 Nov 2022 12:49:46 +0800 Subject: Define in_int32_t_range to check if the 64 bit time_t syscall should be used Currently glibc uses in_time_t_range to detects time_t overflow, and if it occurs fallbacks to 64 bit syscall version. The function name is confusing because internally time_t might be either 32 bits or 64 bits (depending on __TIMESIZE). This patch refactors the in_time_t_range by replacing it with in_int32_t_range for the case to check if the 64 bit time_t syscall should be used. The in_time_t range is used to detect overflow of the syscall return value. Reviewed-by: Adhemerval Zanella --- include/time.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/time.h b/include/time.h index 20abea69d4..f599eeed4e 100644 --- a/include/time.h +++ b/include/time.h @@ -347,12 +347,20 @@ libc_hidden_proto (__time64) /* Check whether T fits in int32_t, assume all usages are for sizeof(time_t) == 32. */ static inline bool -in_time_t_range (__time64_t t) +in_int32_t_range (__time64_t t) { int32_t s = t; return s == t; } +/* Check whether T fits in time_t. */ +static inline bool +in_time_t_range (__time64_t t) +{ + time_t s = t; + return s == t; +} + /* Convert a known valid struct timeval into a struct __timespec64. */ static inline struct __timespec64 valid_timeval_to_timespec64 (const struct timeval tv) -- cgit v1.2.3