Mac OS X: work around a localtime() bug in 64-bit 10.6.8
For numbers around -67768122973228093, localtime() doesn't return in 10.6.8, while it returns NULL for 10.7.2. Work around the bug by setting a lower bound that seems to be high enough to avoid the problem (and that's lower than the lowest value that succeeds, so no results are lost, at least for now). Merge to 5.2.1
This commit is contained in:
parent
71595a55e6
commit
4e4c40ae8c
|
@ -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 */
|
||||
|
|
|
@ -8320,6 +8320,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;
|
||||
|
@ -8371,7 +8377,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
|
||||
|
|
Loading…
Reference in New Issue
Block a user