Mercurial > hg > octave-lyh > gnulib-hg
changeset 9316:ac5b4a469386
* lib/xnanosleep.c (xnanosleep): Don't assume GCC 4.3.0 behavior
when avoiding problems with integer overflow. Use a portable test
instead.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Mon, 08 Oct 2007 16:26:12 -0700 |
parents | be88e4511678 |
children | f7ffc7248a3f |
files | ChangeLog lib/xnanosleep.c |
diffstat | 2 files changed, 13 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-10-08 Paul Eggert <eggert@cs.ucla.edu> + + * lib/xnanosleep.c (xnanosleep): Don't assume GCC 4.3.0 behavior + when avoiding problems with integer overflow. Use a portable test + instead. + 2007-10-08 Simon Josefsson <simon@josefsson.org> * modules/dummy (License): Change to LGPLv2+.
--- a/lib/xnanosleep.c +++ b/lib/xnanosleep.c @@ -72,15 +72,13 @@ /* Normalize the interval length. nanosleep requires this. */ if (BILLION <= ts_sleep.tv_nsec) { - /* Declare "volatile" so that gcc-4.3.0 doesn't optimize away - the overflow test. */ - volatile time_t t = ts_sleep.tv_sec + 1; - - /* Detect integer overflow. */ - overflow |= (t < ts_sleep.tv_sec); - - ts_sleep.tv_sec = t; - ts_sleep.tv_nsec -= BILLION; + if (ts_sleep.tv_sec == TIME_T_MAX) + overflow = true; + else + { + ts_sleep.tv_sec++; + ts_sleep.tv_nsec -= BILLION; + } } for (;;)