bug-gnulib
[Top][All Lists]
Advanced

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

Re: signbitl on powerpc-apple-darwin8.11.0


From: Bruno Haible
Subject: Re: signbitl on powerpc-apple-darwin8.11.0
Date: Tue, 9 Dec 2008 02:28:12 +0100
User-agent: KMail/1.9.9

Simon Josefsson wrote:
> Building gnulib (vasnprintf.c) on this platform (Mac OS X 10.4 fully
> updated) results in:
> 
> /usr/libexec/gcc/powerpc-apple-darwin8/4.0.1/ld: Undefined symbols:
> _signbitl
> collect2: ld returned 1 exit status
> 
> Configure finds this:
> 
> configure:79962: checking for signbit macro
> configure:80053: gcc -std=gnu99 -o conftest -g -O2 -I/opt/local/include  
> conftest.c -lm    >&5
> configure:80056: $? = 0
> configure:80062: ./conftest
> configure:80065: $? = 0
> configure:80082: result: yes
> configure:80084: checking for signbit compiler built-ins
> configure:80169: gcc -std=gnu99 -o conftest -g -O2 -I/opt/local/include  
> conftest.c -lm    >&5
> configure:80172: $? = 0
> configure:80178: ./conftest
> configure:80181: $? = 0
> configure:80198: result: yes
> 
> However, apparently, it doesn't work out well.
> 
> The system does appear to have __signbit? in its libc.

Indeed. On this platform (GCC 4.0.1), the system's signbit macro expands into
__builtin_signbitl for 'long double' arguments. What happens is that
test-signbit.c has some calls to signbit of literals, which are constant-folded
by GCC, and some calls to signbit of variables, which are left as calls to the
function 'signbitl'. But the system library has no 'signbitl', only
'__signbitl'.

Since I don't know what __signbitl does and whether it is safe to use it,
I'm simply making the autoconf test sharper:


2008-12-08  Bruno Haible  <address@hidden>

        * m4/signbitl.m4 (gl_SIGNBIT_TEST_PROGRAM): Add a link check of signbit
        applied to variables. Needed on MacOS X 10.4/PowerPC.
        Reported by Simon Josefsson.

--- m4/signbit.m4.orig  2008-12-09 02:22:24.000000000 +0100
+++ m4/signbit.m4       2008-12-09 02:21:54.000000000 +0100
@@ -1,4 +1,4 @@
-# signbit.m4 serial 4
+# signbit.m4 serial 5
 dnl Copyright (C) 2007-2008 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -124,6 +124,12 @@
 ])
 
 AC_DEFUN([gl_SIGNBIT_TEST_PROGRAM], [[
+/* Global variables.
+   Needed because GCC 4 constant-folds __builtin_signbitl (literal)
+   but cannot constant-fold            __builtin_signbitl (variable).  */
+float vf;
+double vd;
+long double vl;
 int main ()
 {
 /* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0.
@@ -142,6 +148,8 @@
 #else
 long double m0l = -p0l;
 #endif
+  if (signbit (vf))
+    vf++;
   {
     float plus_inf = 1.0f / p0f;
     float minus_inf = -1.0f / p0f;
@@ -153,6 +161,8 @@
           && signbit (minus_inf)))
       return 1;
   }
+  if (signbit (vd))
+    vd++;
   {
     double plus_inf = 1.0 / p0d;
     double minus_inf = -1.0 / p0d;
@@ -164,6 +174,8 @@
           && signbit (minus_inf)))
       return 1;
   }
+  if (signbit (vl))
+    vl++;
   {
     long double plus_inf = 1.0L / p0l;
     long double minus_inf = -1.0L / p0l;




reply via email to

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