Add Windows support for 32- and 64-bit functions
This commit adds Windows support for 32- and 64-bit functions to core-math. All tests have been run and results have been verified for accuracy on both Windows and Linux.
In order to build to build core-math on Windows, you must use a GNU-compatible
compiler such as mingw due to our reliance on GNU builtin functions. In my
development, I utilized the mingw-w64-ucrt-x86_64-gcc
package provided by
msys2 to target the native UCRT runtime. Compilation under Cygwin may work as
well, but the produced binaries will rely on Cygwin's runtime, making it less
portable.
While I've run all of the tests, I haven't included the code that I needed to
port to do so as our current code structure doesn't lend itself well to
utility functions shared across multiple files. Functions that needed to be
ported were the non-standard getline
and rand48
functions. I may contribute
these functions in the future when we have a better way of sharing code between
modules.
A large number of the issues that I ran into were caused by differences in type
length. long is 32 bits on Windows, and 64 bits on x86-64 Linux platforms.
Because of this, there were many numerical and arithmetic over and underflows
that produced incorrect results. I've changed the requisite types to int64_t
and uint64_t
where applicable. Likewise calls to builtins such as
__builtin_clzl
needed to be changed to the long long version __builtin_clzll
as
long long is the same size on both Windows and x86-64 Linux platforms. Many
hard-coded constants in the form 0xffffl
also needed to be changed to their
long long counterparts - 0xffffll
. Finally, printf format specifiers were
changed to respect the different data sizes across platforms.
Please note that extended 80-bit precision functions have not been ported yet.