diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2007-10-08 16:26:12 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2007-10-08 16:26:12 -0700 |
commit | 36fa078f51a43eef774eca7d7e66455d83d5ca07 (patch) | |
tree | d802c1180f401b70c581836c5186f6bb5b351b3b /lib/xnanosleep.c | |
parent | c27fe97d89a062031db44639f4434169752538fe (diff) | |
download | gnulib-36fa078f51a43eef774eca7d7e66455d83d5ca07.tar.gz |
* lib/xnanosleep.c (xnanosleep): Don't assume GCC 4.3.0 behavior
when avoiding problems with integer overflow. Use a portable test
instead.
Diffstat (limited to 'lib/xnanosleep.c')
-rw-r--r-- | lib/xnanosleep.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/lib/xnanosleep.c b/lib/xnanosleep.c index 22bd53a953..317e40ade5 100644 --- a/lib/xnanosleep.c +++ b/lib/xnanosleep.c @@ -72,15 +72,13 @@ xnanosleep (double seconds) /* 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 (;;) |