From 00e9d1ff03ffffce84c9be01977a4575bdcdbed4 Mon Sep 17 00:00:00 2001 From: Camm Maguire Date: Sun, 25 Dec 2022 12:14:33 +0000 Subject: [PATCH] TODO: Put a short summary on the line above and replace this paragraph with a longer explanation of this change. Complete the meta-information with other relevant fields (see below for details). To make it easier, the information below has been extracted from the changelog. Adjust it or drop it. gcl (2.6.13-4) unstable; urgency=medium * Version_2_6_14pre3 Gbp-Pq: Name Version_2_6_14pre3 --- configure | 62 ++++++++++++++++++++++++++++++- configure.in | 19 +++++++++- git.tag | 2 +- lsp/gcl_mislib.lsp | 2 +- o/unixtime.c | 93 +++++++++++++++++++++++++++++++++++++--------- 5 files changed, 156 insertions(+), 22 deletions(-) diff --git a/configure b/configure index 0691b68..041c95d 100755 --- a/configure +++ b/configure @@ -4460,7 +4460,7 @@ fi } assert_arg_to_cflags() { - if ! add_arg_to_cflags $1 ; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: cannot add $1 to CFLAGS" >&5 + if ! add_arg_to_cflags "$1" ; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: cannot add $1 to CFLAGS" >&5 printf "%s\n" "cannot add $1 to CFLAGS" >&6; }; exit 1 ; fi return 0 } @@ -6514,6 +6514,66 @@ printf "%s\n" "#define SIZEOF_LONG $ac_cv_sizeof_long" >>confdefs.h +if test "$ac_cv_sizeof_long" = "4" ; then + assert_arg_to_cflags "-D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64" +fi + +ac_fn_c_check_header_compile "$LINENO" "time.h" "ac_cv_header_time_h" "$ac_includes_default" +if test "x$ac_cv_header_time_h" = xyes +then : + printf "%s\n" "#define HAVE_TIME_H 1" >>confdefs.h + +fi +ac_fn_c_check_header_compile "$LINENO" "sys/time.h" "ac_cv_header_sys_time_h" "$ac_includes_default" +if test "x$ac_cv_header_sys_time_h" = xyes +then : + printf "%s\n" "#define HAVE_SYS_TIME_H 1" >>confdefs.h + +fi + + +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking size of time_t" >&5 +printf %s "checking size of time_t... " >&6; } +if test ${ac_cv_sizeof_time_t+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (time_t))" "ac_cv_sizeof_time_t" "#include +" +then : + +else $as_nop + if test "$ac_cv_type_time_t" = yes; then + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute sizeof (time_t) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_time_t=0 + fi +fi + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_time_t" >&5 +printf "%s\n" "$ac_cv_sizeof_time_t" >&6; } + + + +printf "%s\n" "#define SIZEOF_TIME_T $ac_cv_sizeof_time_t" >>confdefs.h + + +if test "$use" != "mingw" ; then + if test "$ac_cv_sizeof_time_t" != "8" ; then + as_fn_error $? "Cannot define a 64 bit time_t" "$LINENO" 5 + fi +fi + + + #### Memory areas and alignment { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for byte order" >&5 diff --git a/configure.in b/configure.in index a9cfe64..12b8abe 100644 --- a/configure.in +++ b/configure.in @@ -198,7 +198,7 @@ add_arg_to_cflags() { } assert_arg_to_cflags() { - if ! add_arg_to_cflags $1 ; then AC_MSG_RESULT([cannot add $1 to CFLAGS]); exit 1 ; fi + if ! add_arg_to_cflags "$1" ; then AC_MSG_RESULT([cannot add $1 to CFLAGS]); exit 1 ; fi return 0 } @@ -947,6 +947,21 @@ esac AC_CHECK_SIZEOF(long,0) +if test "$ac_cv_sizeof_long" = "4" ; then + assert_arg_to_cflags "-D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64" +fi + +AC_CHECK_HEADERS([time.h sys/time.h]) + +AC_CHECK_SIZEOF(time_t,[0],[#include ]) +if test "$use" != "mingw" ; then + if test "$ac_cv_sizeof_time_t" != "8" ; then + AC_MSG_ERROR([Cannot define a 64 bit time_t]) + fi +fi + + + #### Memory areas and alignment AC_MSG_CHECKING(for byte order) @@ -1372,7 +1387,7 @@ if test "$use" != "386-gnu" ; then #hurd can push .data below C stack, but sbrk( $CC $LDFLAGS -Wl,--verbose foo.c -o foo 2>&1 | \ $AWK '/==================================================/ {i=1-i;next} {if (i) print}' >gcl.script rm -rf foo.c foo - + if test "`cat gcl.script | wc -l`" != "0" ; then AC_MSG_RESULT(got it) AC_MSG_NOTICE([trying to adjust text start]) diff --git a/git.tag b/git.tag index d56e241..17cfbdf 100644 --- a/git.tag +++ b/git.tag @@ -1,2 +1,2 @@ -"Version_2_6_14pre2" +"Version_2_6_14pre3" diff --git a/lsp/gcl_mislib.lsp b/lsp/gcl_mislib.lsp index c564c0c..3c0203e 100755 --- a/lsp/gcl_mislib.lsp +++ b/lsp/gcl_mislib.lsp @@ -63,7 +63,7 @@ (s n h d m y w yd dstp off) (localtime ut) (when (when tzp (> dstp 0)) (multiple-value-setq (s n h d m y w yd) (localtime (- ut 3600)))) - (values s n h d (1+ m) (+ 1900 y) (1- w) (unless tzp (> dstp 0)) (if tzp tz (+ (truncate (- off) 3600) dstp)))))) + (values s n h d (1+ m) (+ 1900 y) (if (zerop w) 6 (1- w)) (unless tzp (> dstp 0)) (if tzp tz (+ (truncate (- off) 3600) dstp)))))) (defun encode-universal-time (s n h d m y &optional (tz (this-tz) tzp)) (declare (optimize (safety 2))) diff --git a/o/unixtime.c b/o/unixtime.c index e265ef2..de7f1f8 100755 --- a/o/unixtime.c +++ b/o/unixtime.c @@ -303,16 +303,69 @@ DEFUN_NEW("CURRENT-DSTP",object,fScurrent_dstp,SI,0,0,NONE,OO,OO,OO,OO,(void),"" #endif } -DEFUNM_NEW("LOCALTIME",object,fSlocaltime,SI,1,1,NONE,OI,OO,OO,OO,(fixnum t),"") { +#if defined(__MINGW32__) /*FIXME range too small for maxima testsuite*/ +#undef gmtime +#define gmtime _gmtime64 +#undef localtime +#define localtime _localtime64 +#undef mktime +#define mktime _mktime64 +#undef time_t +#define time_t long long +#endif + +static object +time_t_to_object(time_t l) { + object x=new_bignum(); + + mpz_set_si(MP(x),l>>32); + mpz_mul_2exp(MP(x),MP(x),32); + mpz_add_ui(MP(x),MP(x),l&((1ULL<<32)-1)); + return normalize_big(x); + +} + +static time_t +object_to_time_t(object x) { + + switch(type_of(x)) { + case t_fixnum: + return fix(x); + case t_bignum: + { + time_t h; + mpz_set_si(MP(big_fixnum3),1); + mpz_mul_2exp(MP(big_fixnum3),MP(big_fixnum3),31); + mpz_fdiv_qr(MP(big_fixnum1),MP(big_fixnum2),MP(x),MP(big_fixnum3)); + massert(mpz_fits_slong_p(MP(big_fixnum1))); + massert(mpz_fits_slong_p(MP(big_fixnum2))); + h=mpz_get_si(MP(big_fixnum1)); + h<<=31; + h+=mpz_get_si(MP(big_fixnum2)); + return h; + } + default: + TYPE_ERROR(x,sLinteger); + } + +} + +DEFUNM_NEW("LOCALTIME",object,fSlocaltime,SI,1,1,NONE,OO,OO,OO,OO,(object t),"") { + #if defined NO_SYSTEM_TIME_ZONE /*solaris*/ return Cnil; #else + time_t i=object_to_time_t(t); + struct tm *lt; #if defined(__MINGW32__) - fixnum gmt_hour=gmtime(&t)->tm_hour; + struct tm *gt; + fixnum gmt_hour; + massert(gt=gmtime(&i)); + gmt_hour=gt->tm_hour; #endif - struct tm *lt=localtime(&t); + massert(lt=localtime(&i)); RETURN(11,object, make_fixnum(lt->tm_sec), @@ -337,29 +390,33 @@ DEFUNM_NEW("LOCALTIME",object,fSlocaltime,SI,1,1,NONE,OI,OO,OO,OO,(fixnum t),"") } -DEFUNM_NEW("GMTIME",object,fSgmtime,SI,1,1,NONE,OI,OO,OO,OO,(fixnum t),"") { +DEFUNM_NEW("GMTIME",object,fSgmtime,SI,1,1,NONE,OO,OO,OO,OO,(object t),"") { #if defined NO_SYSTEM_TIME_ZONE /*solaris*/ return Cnil; #else - struct tm *lt=gmtime(&t); + + time_t i=object_to_time_t(t); + struct tm *gt; + massert(gt=gmtime(&i)); + RETURN(11,object, - make_fixnum(lt->tm_sec), + make_fixnum(gt->tm_sec), ( - RV(make_fixnum(lt->tm_min)), - RV(make_fixnum(lt->tm_hour)), - RV(make_fixnum(lt->tm_mday)), - RV(make_fixnum(lt->tm_mon)), - RV(make_fixnum(lt->tm_year)), - RV(make_fixnum(lt->tm_wday)), - RV(make_fixnum(lt->tm_yday)), - RV(make_fixnum(lt->tm_isdst)), + RV(make_fixnum(gt->tm_min)), + RV(make_fixnum(gt->tm_hour)), + RV(make_fixnum(gt->tm_mday)), + RV(make_fixnum(gt->tm_mon)), + RV(make_fixnum(gt->tm_year)), + RV(make_fixnum(gt->tm_wday)), + RV(make_fixnum(gt->tm_yday)), + RV(make_fixnum(gt->tm_isdst)), #if defined(__MINGW32__) RV(make_fixnum(0)), RV(Cnil) #else - RV(make_fixnum(lt->tm_gmtoff)), - RV(make_simple_string(lt->tm_zone)) + RV(make_fixnum(gt->tm_gmtoff)), + RV(make_simple_string(gt->tm_zone)) #endif )); #endif @@ -369,6 +426,7 @@ DEFUNM_NEW("GMTIME",object,fSgmtime,SI,1,1,NONE,OI,OO,OO,OO,(fixnum t),"") { DEFUNM_NEW("MKTIME",object,fSmktime,SI,6,6,NONE,OI,II,II,IO,(fixnum s,fixnum n,fixnum h,fixnum d,fixnum m,fixnum y),"") { struct tm lt; + time_t t; lt.tm_sec=s; lt.tm_min=n; @@ -378,7 +436,8 @@ DEFUNM_NEW("MKTIME",object,fSmktime,SI,6,6,NONE,OI,II,II,IO,(fixnum s,fixnum n,f lt.tm_year=y; lt.tm_isdst=-1; - RETURN(2,object,make_fixnum(mktime(<)),(RV(make_fixnum(lt.tm_isdst)))); + massert((t=mktime(<))!=-1); + RETURN(2,object,time_t_to_object(t),(RV(make_fixnum(lt.tm_isdst)))); } -- 2.30.2