emscripten-core / emscripten

Emscripten: An LLVM-to-WebAssembly Compiler
Other
25.37k stars 3.25k forks source link

missing FE_xx defines #22005

Open stsp opened 1 month ago

stsp commented 1 month ago

Version of emscripten/emsdk: emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.60 (42a6ea2052f19f70d7d994e8c324bcad2f1f8939)

fetestexcept() function seems to be present, but I am getting:

error: use of undeclared identifier 'FE_INVALID'
  173 |         if (exceptions & FE_INVALID) fps |= FPUS_IE;
error: use of undeclared identifier 'FE_DIVBYZERO'
  174 |         if (exceptions & FE_DIVBYZERO) fps |= FPUS_ZE;

and so on.

sbc100 commented 1 month ago

It looks like these were removed in #11087 due to lack of support in emscripten.

sbc100 commented 1 month ago

Should we also remove fetestexcept() @kripken ?

kripken commented 1 month ago

Hmm, good question. Re-reading the docs on those macros, C99 says only the ones implemented should be defined, but C++11 says they should all be defined (!). That might be the issue here. @stsp are you using this macro from C or C++?

stsp commented 1 month ago

I am using these from C. However, C99 is quite an old standard to refer to.

kripken commented 1 month ago

@stsp the docs suggest later versions of C have not changed on these things since C99.

I'm not sure what we can change here. The C docs and musl's behavior led to #11087 removing those macros, but fetestexcept is a function and not a macro and the docs say it should always be present.

Docs:

I think that implies source code should check if those macros are defined before using them (which means they can call that function but perhaps not be able to get useful output from it).

stsp commented 1 month ago

man page says:

The macro FE_ALL_EXCEPT is the  bitwise  OR  of  all
bits corresponding to supported exceptions.

Maybe you need to add that macro and define it to 0?

stsp commented 1 month ago

Ah, this seems to be already done! Ok, maybe nothing to fix here then, other than to add an FPU support. :)