diff --git a/src/racket/sconfig.h b/src/racket/sconfig.h index fc2a524c35..e101001619 100644 --- a/src/racket/sconfig.h +++ b/src/racket/sconfig.h @@ -766,6 +766,11 @@ #endif # define MZ_JIT_USE_MPROTECT +#if defined(__x86_64__) +/* work around a bug in localtime() in 10.6.8 */ +# define MIN_VALID_DATE_SECONDS -67768122973193999 +#endif + # define FLAGS_ALREADY_SET #endif @@ -1026,6 +1031,8 @@ /* TIME_TYPE_IS_UNSIGNED converts time_t values as unsigned. */ + /* MIN_VALID_DATE_SECONDS sets a minimum vald time in seconds. */ + /* PROCESS_FUNCTION adds (process ...) and (system ...) functions */ /* DIR_FUNCTION adds (current-directory ...) function */ diff --git a/src/racket/src/fun.c b/src/racket/src/fun.c index 4c15dd1ba1..12991cbe3d 100644 --- a/src/racket/src/fun.c +++ b/src/racket/src/fun.c @@ -8315,6 +8315,12 @@ static int month_offsets[12] = { 0, 31, 59, 90, 243, 273, 304, 334 }; #endif +#ifdef MIN_VALID_DATE_SECONDS +# define VALID_TIME_RANGE(x) ((x) >= MIN_VALID_DATE_SECONDS) +#else +# define VALID_TIME_RANGE(x) 1 +#endif + static Scheme_Object *seconds_to_date(int argc, Scheme_Object **argv) { UNBUNDLE_TIME_TYPE lnow; @@ -8366,7 +8372,8 @@ static Scheme_Object *seconds_to_date(int argc, Scheme_Object **argv) } if (scheme_get_time_val(secs, &lnow) - && ((UNBUNDLE_TIME_TYPE)(now = (CHECK_TIME_T)lnow)) == lnow) { + && (((UNBUNDLE_TIME_TYPE)(now = (CHECK_TIME_T)lnow)) == lnow) + && VALID_TIME_RANGE(lnow)) { int success; #ifdef USE_MACTIME