Age | Commit message (Collapse) | Author |
|
This is to implement constexpr template based implementations for
mathematical functions
This also changes math.cpp to use these implementations.
Also adds a fastpath for floating point trucation for values smaller
than the signed 64 bit limit.
|
|
While trying to port to Clang we found that the functions as
implemented didn't actually work, and replacing them with a blatantly
broken function also did not break the tests on the GCC build. It
turns out we've been testing GCC's builtins by many tests. This
removes the use of builtins for LibM's tests (so we test the whole
function). It turns off the denormal test for scalbn (which was not
implemented) and comments out the tgamma(0.5) test which is too
inaccurate to be usable (and too complicated for me to fix). The gamma
function was made accurate for all other test cases, and asin received
two more layers of Taylor expansion to bring it within error margin
for the tests.
|
|
We use these to prevent UB from being optimized away in `/bin/crash` and
to make the compiler not warn about the many implicit floating point
type promotions in LibM.
|
|
|
|
For some reason we were using sin(x+M_PI_2) instead
|
|
|
|
|
|
These are used by the ultima engine for scummvm.
|
|
While playing with conditionally disabling -O2 optimization when
building the Userland subdirectory, I discovered that we can no longer
link errors without -O2. This happens as LibM.so doesn't link to
anything else, resulting in no stack protector implementation. It
appears that optimization somehow avoids this problem?
To fix this inject LibC/ssp.cpp as we do with in dynamic loader.
|
|
This reverts commit 800ea8ea969835297dc7e7da345a45b9dc5e751a.
Booting the system no longer worked after these changes.
|
|
Problem:
- `static` variables consume memory and sometimes are less
optimizable.
- `static const` variables can be `constexpr`, usually.
- `static` function-local variables require an initialization check
every time the function is run.
Solution:
- If a global `static` variable is only used in a single function then
move it into the function and make it non-`static` and `constexpr`.
- Make all global `static` variables `constexpr` instead of `const`.
- Change function-local `static const[expr]` variables to be just
`constexpr`.
|
|
|
|
With this fixed we get libstdc++v3's aliases for C99 math functions
in the std namespace. Unfortunately for this to work the toolchain
needs to be rebuilt.
The good news are that this by itself does not require a toolchain
rebuild just yet.
|
|
POSIX mandates it.
|
|
|
|
|
|
SPDX License Identifiers are a more compact / standardized
way of representing file license information.
See: https://spdx.dev/resources/use/#identifiers
This was done with the `ambr` search and replace tool.
ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
|
|
This warning informs of float-to-double conversions. The best solution
seems to be to do math *either* in 32-bit *or* in 64-bit, and only to
cross over when absolutely necessary.
|
|
The previous versions were very inaccurate, and sometimes wrong.
|
|
|
|
This patch makes tgamma use an approximation that is more accurate with
regards to floating point arithmetic, and fixes some issues when tgamma
was called with positive integer values.
It also makes lgamma set signgam to the correct value, and makes its
return value be more inline with what the C standard defines.
|
|
|
|
These just forward their arguments to fmod, but I think that should be
fine.
|
|
|
|
Looks like a POSIX extension
|
|
|
|
It was already defined, but it wasn't declared in the header
|
|
|
|
The categories are the same categories used by cppreference on its page
for numeric functions.
|
|
|
|
|
|
Lazy, but it works for now. :^)
|
|
|
|
This patch implements the entire rint family, while taking into account
the current rounding mode, and implements ceil, round, trunc, and floor
for types which they weren't before.
|
|
|
|
|
|
Also implement ldexp in terms of them, and add ldexpl
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED)
Since all of these checks are done in release builds as well,
let's rename them to VERIFY to prevent confusion, as everyone is
used to assertions being compiled out in release.
We can introduce a new ASSERT macro that is specifically for debug
checks, but I'm doing this wholesale conversion first since we've
accumulated thousands of these already, and it's not immediately
obvious which ones are suitable for ASSERT.
|
|
Patch from Anonymous.
|
|
This test seems to be full of wrong, but at least now we build it and
place it in /usr/Tests/LibM/ so that we can fix it.
|
|
Patch from Anonymous.
|
|
Only thing missing for Python to build the _math module! :^)
|
|
|