bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: coreutils 4.5.2 fail to build on Solaris 2.6


From: Paul Eggert
Subject: Re: coreutils 4.5.2 fail to build on Solaris 2.6
Date: Sun Oct 13 07:36:01 2002

> From: Petter Reinholdtsen <address@hidden>
> Date: Sat, 12 Oct 2002 14:15:19 +0200
> 
> These are some quotes from trying to compile coreutils 4.5.2 on
> Solaris 2.6.  As you can se, the fesetround() function is required by
> sleep, but missing in the build

I looked into that problem some more.  I found that if you use the Sun
WorkShop 6 update 2 C compiler on Solaris 2.6, you need to compile
with '-R/opt/SUNWspro/lib -L/opt/SUNWspro/lib -lm9x' if you want to
call fesetround.  You didn't mention which compiler you're using, but
you may be able to work around your problem by building with
LDFLAGS='-R/opt/SUNWspro/lib -L/opt/SUNWspro/lib -lm9x'.

However, I don't think it is a good idea for "configure" to deduce
this automatically, since most Solaris 2.6 hosts won't have the m9x
library, even if the build host has it.

> -#ifdef FE_UPWARD
> +#if defined(FE_UPWARD) && defined(HAVE_FESETROUND)

Yes, that's the obvious simple fix to lib/xnanosleep.c (along with a
change to 'configure' to set HAVE_FESETROUND).  But in looking in the
code, I came up with the following fix that entirely avoids the
fesetround porting morass.

2002-10-12  Paul Eggert  <address@hidden>

        * lib/xnanosleep.c: 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.
        * m4/jm-macros.m4 (jm_CHECK_ALL_HEADERS): Remove fenv.h.

diff -pru coreutils-4.5.2/lib/xnanosleep.c coreutils-fixed/lib/xnanosleep.c
--- coreutils-4.5.2/lib/xnanosleep.c    Sat Sep 14 23:52:29 2002
+++ coreutils-fixed/lib/xnanosleep.c    Sat Oct 12 12:52:40 2002
@@ -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.  */
diff -pru coreutils-4.5.2/m4/jm-macros.m4 coreutils-fixed/m4/jm-macros.m4
--- coreutils-4.5.2/m4/jm-macros.m4     Sat Sep 28 14:39:28 2002
+++ coreutils-fixed/m4/jm-macros.m4     Sat Oct 12 12:37:35 2002
@@ -211,7 +211,6 @@ AC_DEFUN([jm_CHECK_ALL_HEADERS],
   AC_CHECK_HEADERS( \
     errno.h  \
     fcntl.h \
-    fenv.h \
     float.h \
     hurd.h \
     limits.h \




reply via email to

[Prev in Thread] Current Thread [Next in Thread]