bug-gnulib
[Top][All Lists]
Advanced

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

Re: Confused aboth math.in.h


From: Pádraig Brady
Subject: Re: Confused aboth math.in.h
Date: Sat, 22 Nov 2014 22:40:35 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0

On 22/11/14 20:53, Gisle Vanem wrote:
> I'm trying to understand the logic behind the generation
> of some statements in math.h (from math.in.h). The MSVC
> compiler has cosf() defined as a macro in it's <math.h>:
>   #define cosf(x)     ((float)cos((double)(x)))
> 
> (for x86,C). Then how is Gnulib supposed to replace that?
> Since no matter what's put in Gnulib's "math.h", the
> preprocessed output of cosf.c contains this rubbish:
> 
>   extern int gl_signbitl (long double arg);
>   float
>   ((float)cos((double)(float x)))  << MSVC's macro for cosf()
>   {
>     return (float) cos ((double) x);
>   }
> 
> Isn't there supposed to be an "#undef cosf" in "math.h"
> in this case? All I see is:
>   # if address@hidden@     << line 448
>   #  undef cosf
> 
> I assume if some vendor have 'cosf' it should be undefined
> before Gnulib is trying to override or replace it. Not vice
> versa. So shouldn't this be:
>   # if @HAVE_COSF@ || @REPLACE_COSF@
>   #  undef cosf

Well all the ...f() variants seem to be treated like this:
acosf() coshf() asinf() atanf() atan2f() ceilf() expf() ...

In the m4, the corresponding check is with: AC_CHECK_FUNCS([cosf])
I.E. the linker is used to find the function in libm.
If it's only a macro and not in libm, then the code in math.h.in
above makes sense.

So are you saying that HAVE_COSF is 1 for you (i.e. it's in your libm),
and you're also replacing it?

> Also, in test-cosf.c, the
>   SIGNATURE_CHECK (cosf, float, (float));
> 
> doesn't compile/link as it is here now (this macro cannot
> contain another macro). Or maybe test-cosf.c isn't supposed
> to be compiled for MSVC?
> 
> Please help me resolve my confusion.
> 
> Same for coshf(), cosl() etc. AFAICS.

Note cosl is treated differently as per:
http://git.sv.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=d5b42fa0

thanks,
Pádraig.



reply via email to

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