summaryrefslogtreecommitdiff
path: root/lib/xnanosleep.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2002-10-13 12:22:26 +0000
committerJim Meyering <jim@meyering.net>2002-10-13 12:22:26 +0000
commitbd9e754992a5ab5b358e563f728874bc21d4250a (patch)
treeff789693f830fad7e5de95c304023e3cd4db51b4 /lib/xnanosleep.c
parent5b87a606636b54f87d86fb47cc980a6c1e9dbcf9 (diff)
downloadcoreutils-bd9e754992a5ab5b358e563f728874bc21d4250a.tar.xz
There's no need to futz with the rounding mode,
since the code should work properly even in the default rounding mode. (<fenv.h>): Do not include. (#pragma STDC FENV_ACCESS ON): Remove. (xnanosleep): Don't futz with rounding state.
Diffstat (limited to 'lib/xnanosleep.c')
-rw-r--r--lib/xnanosleep.c24
1 files changed, 4 insertions, 20 deletions
diff --git a/lib/xnanosleep.c b/lib/xnanosleep.c
index 8f9eb7e25..c6acbac2f 100644
--- a/lib/xnanosleep.c
+++ b/lib/xnanosleep.c
@@ -54,15 +54,6 @@
#include "xnanosleep.h"
#include "xstrtod.h"
-#if HAVE_FENV_H
-# include <fenv.h>
-#endif
-
-/* Tell the compiler that non-default rounding modes are used. */
-#if 199901 <= __STDC_VERSION__
- #pragma STDC FENV_ACCESS ON
-#endif
-
static int initialized = 0;
/* Subtract the `struct timespec' values X and Y,
@@ -138,16 +129,6 @@ xnanosleep (double seconds)
assert (0 <= seconds);
-#ifdef FE_UPWARD
- if (! initialized)
- {
- /* Always round up, since we must sleep for at least the specified
- interval. */
- /* FIXME: save and restore state, rather than just setting it? */
- fesetround (FE_UPWARD);
- }
-#endif
-
if (clock_get_realtime (&ts_start) == NULL)
return -1;
@@ -159,7 +140,10 @@ xnanosleep (double seconds)
ts_sleep.tv_nsec = ns;
/* Round up to the next whole number, if necessary, so that we
- always sleep for at least the requested amount of time. */
+ always sleep for at least the requested amount of time. Assuming
+ the default rounding mode, we don't have to worry about the
+ rounding error when computing 'ns' above, since the error won't
+ cause 'ns' to drop below an integer boundary. */
ts_sleep.tv_nsec += (ts_sleep.tv_nsec < ns);
/* Normalize the interval length. nanosleep requires this. */