[Mesa-stable] [Mesa-dev] [PATCH 2/3] gallium/nouveau: use std::isfinite in c++ sources
Emil Velikov
emil.l.velikov at gmail.com
Thu Oct 23 07:16:17 PDT 2014
On 20/10/14 20:56, Jose Fonseca wrote:
> Note that doing
>
> #include <cmath>
>
> is a bad idea too, as it can cause precisely the same error you're trying to fix. This is because on certain implementations of C++ STL, if some other header has '#include <math.h>, then '#include <cmath>' later on, the later include can be a no-op and nothing is declared on std namespace.
>
The "sanity" of some STL implementations :\
> In short, when mixing C and C++ code, it seems one should always include the standard C headers instead of the C++ <c*> headers.
>
> Its also not clear why isfinite is not on the global namespace. I suspect that again, the problem is that some other header is including <cmath> before u_math.h ... If so, then *please* lets stop doing it. I already brought this issue many many times. Not sure why people still think that including <c*> headers in Mesa is a good idea..
>
Quick snippet from $ man isfinite
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
isfinite():
_XOPEN_SOURCE >= 600 || _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L;
or cc -std=c99
One cannot do _POSIX_C_SOURCE (android is not really posix) or -std=c99
(we're compiling C++). Android is bionic, so maybe none of the above
four apply? Will need to take a look at their local hacks for this.
Cheers,
Emil
> Jose
>
>
> ________________________________________
> From: mesa-dev <mesa-dev-bounces at lists.freedesktop.org> on behalf of Emil Velikov <emil.l.velikov at gmail.com>
> Sent: 19 October 2014 08:41
> To: Ilia Mirkin
> Cc: mesa-dev at lists.freedesktop.org; Mauro Rossi; emil.l.velikov at gmail.com; 10.2 10.3
> Subject: Re: [Mesa-dev] [PATCH 2/3] gallium/nouveau: use std::isfinite in c++ sources
>
> On 19/10/14 16:23, Ilia Mirkin wrote:
>> Can you provide more detail as to why the util/u_math.h include is
>> insufficient? Perhaps it should be fixed up similarly to how
>> mesa/main/imports.h does it?
>>
> The actual error message is quite explanatory
> external/mesa/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp:421:35:
> *error: 'isfinite' was not declared in this scope*
>
> Whereas which branch of the ifdef spaghetti the compiler takes in order
> to get there is a good question. I doubt that I'll get the chance to
> look into it any time soon. Yet it makes sense to use C++ headers for
> C++ code - don't you agree ?
>
> -Emil
>
>> -ilia
>>
>> On Sun, Oct 19, 2014 at 11:16 AM, Emil Velikov <emil.l.velikov at gmail.com> wrote:
>>> From: Mauro Rossi <issor.oruam at gmail.com>
>>>
>>> Otherwise the android build will fail.
>>>
>>> Cc: "10.2 10.3" <mesa-stable at lists.freedesktop.org>
>>> ---
>>> src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp | 8 +++-----
>>> 1 file changed, 3 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
>>> index 719f980..b9744e3 100644
>>> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
>>> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
>>> @@ -24,9 +24,7 @@
>>> #include "codegen/nv50_ir_target.h"
>>> #include "codegen/nv50_ir_build_util.h"
>>>
>>> -extern "C" {
>>> -#include "util/u_math.h"
>>> -}
>>> +#include <cmath>
>>>
>>> namespace nv50_ir {
>>>
>>> @@ -416,9 +414,9 @@ ConstantFolding::expr(Instruction *i,
>>> case OP_FMA:
>>> case OP_MUL:
>>> if (i->dnz && i->dType == TYPE_F32) {
>>> - if (!isfinite(a->data.f32))
>>> + if (!std::isfinite(a->data.f32))
>>> a->data.f32 = 0.0f;
>>> - if (!isfinite(b->data.f32))
>>> + if (!std::isfinite(b->data.f32))
>>> b->data.f32 = 0.0f;
>>> }
>>> switch (i->dType) {
>>> --
>>> 2.1.0
>>>
>>> _______________________________________________
>>> mesa-dev mailing list
>>> mesa-dev at lists.freedesktop.org
>>> https://urldefense.proofpoint.com/v1/url?u=http://lists.freedesktop.org/mailman/listinfo/mesa-dev&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=NMr9uy2iTjWVixC0wOcYCWEIYhfo80qKwRgdodpoDzA%3D%0A&m=gfofPYjf71jByJAx2C4ZN88t%2F8o679AdH%2FRt%2FdPH%2FKk%3D%0A&s=efd19554ccfca3e28195fab8f3a769caffa8d946ff5d163424d46c76fae325f6
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://urldefense.proofpoint.com/v1/url?u=http://lists.freedesktop.org/mailman/listinfo/mesa-dev&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=NMr9uy2iTjWVixC0wOcYCWEIYhfo80qKwRgdodpoDzA%3D%0A&m=gfofPYjf71jByJAx2C4ZN88t%2F8o679AdH%2FRt%2FdPH%2FKk%3D%0A&s=efd19554ccfca3e28195fab8f3a769caffa8d946ff5d163424d46c76fae325f6
>
More information about the mesa-stable
mailing list