2012-01-04 Bruno Haible timeout: Fix behaviour for end times beyond 2038 on Linux/hppa. * src/timeout.c (settimeout) [Linux/hppa]: Cap the duration, to avoid an overflow. --- src/timeout.c.bak 2012-01-05 05:01:01.000000000 +0100 +++ src/timeout.c 2012-01-05 05:02:23.000000000 +0100 @@ -111,6 +111,16 @@ deprecated by POSIX. Instead we fallback to single second resolution provided by alarm(). */ +#if defined __linux__ && defined __hppa__ + /* Work around an overflow that happens when the end date is beyond 2038. */ + if (sizeof (time_t) == sizeof (int)) + { + time_t t = time (NULL); + if (t >= 0 && t <= INT_MAX && duration > (double) (INT_MAX - t)) + duration = (double) (INT_MAX - t); + } +#endif + #if HAVE_TIMER_SETTIME struct timespec ts = dtotimespec (duration); struct itimerspec its = { {0, 0}, ts };