summaryrefslogtreecommitdiffstats
path: root/hash.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-10-31 19:38:03 -0700
committerKaz Kylheku <kaz@kylheku.com>2019-10-31 19:38:03 -0700
commitd40e8bd6d7956f757bffd34c7288fd996e617c1e (patch)
tree6ffc3dfa4cc992f8fcd19acc48f7a73de104ac13 /hash.c
parent1d3d115e1f50d1f1feaec7d409c853621b8d939f (diff)
downloadtxr-d40e8bd6d7956f757bffd34c7288fd996e617c1e.tar.gz
txr-d40e8bd6d7956f757bffd34c7288fd996e617c1e.tar.bz2
txr-d40e8bd6d7956f757bffd34c7288fd996e617c1e.zip
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.
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c5
1 files changed, 3 insertions, 2 deletions
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