Thank you.  I've used the attached program to find the exact range of
bad values:

-67768038400752000 to -67768038400665600 (low to high)

(decode-time -67768038400752001) ; (- low 1)
(59 59 23 31 12 -2147481679 6 nil 0)

(decode-time -67768038400665599) ; (+ high 1)
(1 0 0 1 1 -2147481678 1 nil 0)


On 30/07/2017 17:36, Paul Eggert wrote:
Charles A. Roelli wrote:
Could we put a workaround for these "bad" values of time_t in gnulib
for this version of macOS?

Yes, we could. I started to write that, but it wasn't trivial. Eventually I hope to get around to it.

#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include "time.h"               /* gnulib time.h */
#include <setjmp.h>

#define TIME_CHECK_GOOD -67768038400760896
#define TIME_CHECK_BAD -67768038400750896

static jmp_buf buf;
static time_t check_time = TIME_CHECK_GOOD;
static time_t last_good_time = TIME_CHECK_GOOD;
static time_t last_bad_time = TIME_CHECK_BAD;

/* time_find.c */

int localtime_hang_handler () {
  printf ("Hang detected for %ld\n", (long) check_time);
  last_bad_time = check_time;
  check_time = last_good_time;
  longjmp(buf, 1);
}

int main () {
  struct tm output_time;
  signal (SIGALRM, (void *) localtime_hang_handler);

  if(setjmp(buf))
  next:
    check_time = (check_time + last_bad_time) / 2;
  alarm(1);

  localtime_r (&check_time, &output_time);
  printf ("No hang for       %ld\n", (long) check_time);
  alarm(0);
  last_good_time = check_time;

  goto next;
  return 0;
}

Reply via email to