Mercurial > hg > octave-lyh > gnulib-hg
changeset 9311:404565280e7d
Make xnanosleep's integer overflow test more robust.
* lib/xnanosleep.c (xnanosleep): Declare a temporary to be "volatile",
so that gcc-4.3.0 doesn't optimize away this test for overflow.
Signed-off-by: Jim Meyering <meyering@redhat.com>
author | Jim Meyering <meyering@redhat.com> |
---|---|
date | Sun, 07 Oct 2007 20:49:20 +0200 |
parents | 3e3af4f98ada |
children | bec01fc15c2f |
files | ChangeLog lib/xnanosleep.c |
diffstat | 2 files changed, 9 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-10-07 Jim Meyering <meyering@redhat.com> + + Make xnanosleep's integer overflow test more robust. + * lib/xnanosleep.c (xnanosleep): Declare a temporary to be "volatile", + so that gcc-4.3.0 doesn't optimize away this test for overflow. + 2007-10-07 Bruno Haible <bruno@clisp.org> * doc/gnulib-intro.texi (Copyright): Update the meaning of the license
--- a/lib/xnanosleep.c +++ b/lib/xnanosleep.c @@ -72,7 +72,9 @@ /* Normalize the interval length. nanosleep requires this. */ if (BILLION <= ts_sleep.tv_nsec) { - time_t t = ts_sleep.tv_sec + 1; + /* 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);