From d40e8bd6d7956f757bffd34c7288fd996e617c1e Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 31 Oct 2019 19:38:03 -0700 Subject: lib: don't assume time_t is signed. We introduce the function c_time to convert a Lisp integer to time_t, and num_time to do the reverse conversion. The FFI type time-t already does this right. (See registration of time-t in ffi_init_extra_types). * hash.c (gen_hash_seed): The first value out of time_sec_usec corresponds to a time_t value. We now convert this to C number using c_time rather than c_num. Also, while we are touching this code, the microseconds value can convert directly to ucnum with c_unum. * lib.c (time_sec_usec): Use num_time for seconds. (time_string_local, time_string_utc, time_fields_local, time_fields_utc, time_struct_local, time_struct_utc): Use c_time. (make_time_impl, time_parse_utc): Use num_time instead of num. * signal.h (getitimer_wrap, setitimer_wrap): Convert tv_sec members of struct timeval using c_time and num_time. * sysif.c (c_time, num_time): New functions. (stat_to_struct): Convert st_atime, st_mtime and st_ctime to Lisp using num_time instead of num. * sysif.c (c_time, num_time): Declared. --- hash.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'hash.c') diff --git a/hash.c b/hash.c index 20c869bf..bde7901f 100644 --- a/hash.c +++ b/hash.c @@ -46,6 +46,7 @@ #include "eval.h" #include "itypes.h" #include "arith.h" +#include "sysif.h" #include "hash.h" typedef enum hash_flags { @@ -1818,8 +1819,8 @@ static val set_hash_traversal_limit(val lim) static val gen_hash_seed(void) { val time = time_sec_usec(); - ucnum sec = convert(ucnum, c_num(car(time))); - ucnum usec = convert(ucnum, c_num(cdr(time))); + ucnum sec = convert(ucnum, c_time(car(time))); + ucnum usec = c_unum(cdr(time)); #if HAVE_UNISTD_H ucnum pid = convert(ucnum, getpid()); #else -- cgit v1.2.3