diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index f34c9d9..8bb676b 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -12,10 +12,10 @@ jobs: strategy: matrix: platform: [clang, gcc] - os: [ubuntu-20.04, ubuntu-22.04] + os: [ubuntu-22.04, ubuntu-22.04-arm, ubuntu-24.04, ubuntu-24.04-arm, ubuntu-26.04, ubuntu-26.04-arm] steps: - - uses: actions/checkout@v3.3.0 + - uses: actions/checkout@v7.0.1 with: submodules: 'true' fetch-depth: 0 diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 884b7a4..a737ea0 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -8,10 +8,13 @@ on: jobs: macos: - runs-on: macos-10.15 + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-15, macos-15-intel, macos-26, macos-26-intel] steps: - - uses: actions/checkout@v3.3.0 + - uses: actions/checkout@v7.0.1 with: submodules: 'true' fetch-depth: 0 diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 93924e0..3df8061 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -8,18 +8,20 @@ on: jobs: windows_msvc: - runs-on: windows-2019 + runs-on: ${{ matrix.os }} strategy: matrix: platform: [x86, amd64] + os: [windows-2022, windows-2025] + steps: - - uses: actions/checkout@v3.3.0 + - uses: actions/checkout@v7.0.1 with: submodules: 'true' fetch-depth: 0 ref: ${{ github.event.pull_request.head.sha }} - - uses: ilammy/msvc-dev-cmd@v1.12.1 + - uses: ilammy/msvc-dev-cmd@v1.13.0 with: arch: ${{ matrix.platform }} diff --git a/.gitignore b/.gitignore index 76e253e..e199921 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,9 @@ CPackSourceConfig.cmake *.tmp *.bak thumbs.db + +/CMakeUserPresets.json +/.cache +.clang-format +/.vscode +/.vs diff --git a/CMakeLists.txt b/CMakeLists.txt index 6b6b725..557c802 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,5 @@ cmake_minimum_required(VERSION 3.14) -if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) - message(STATUS "No build type selected, default to Release") - set(CMAKE_BUILD_TYPE "Release") -endif() - project(gamemath VERSION 1.1.1 LANGUAGES C) # Decide if this project is the top level project, if so enable development targets. @@ -214,9 +209,9 @@ if(BUILD_SHARED_LIBS) endif() if(CMAKE_C_COMPILER_ID MATCHES "Clang") - target_compile_options(gamemath PRIVATE -fno-builtin -fno-strict-aliasing -Wno-implicit-function-declaration) + target_compile_options(gamemath PRIVATE -fno-builtin -fno-strict-aliasing -ffp-contract=off -Wno-implicit-function-declaration) elseif(CMAKE_C_COMPILER_ID MATCHES "GNU") - target_compile_options(gamemath PRIVATE -fno-gnu89-inline -fno-builtin -fno-strict-aliasing -Wno-implicit-function-declaration) + target_compile_options(gamemath PRIVATE -fno-gnu89-inline -fno-builtin -fno-strict-aliasing -ffp-contract=off -Wno-implicit-function-declaration) elseif(MSVC) target_compile_options(gamemath PRIVATE /wd4146 /wd4244 /wd4554 /wd4723 /wd4756) endif() diff --git a/double/e_sqrt.c b/double/e_sqrt.c index dc560d1..f3511b4 100644 --- a/double/e_sqrt.c +++ b/double/e_sqrt.c @@ -89,6 +89,11 @@ static const double one = 1.0, tiny=1.0e-300; double __ieee754_sqrt(double x) { +#ifdef USE_SSE + double ret; + _mm_store_sd(&ret, _mm_sqrt_pd(_mm_load_sd(&x))); + return ret; +#else double z; int32_t sign = (int)0x80000000; int32_t ix0,s0,q,m,t,i; @@ -181,6 +186,7 @@ __ieee754_sqrt(double x) ix0 += (m <<20); INSERT_WORDS(z,ix0,ix1); return z; +#endif } /* diff --git a/double/s_llrint.c b/double/s_llrint.c index 1e2258d..b75efd7 100644 --- a/double/s_llrint.c +++ b/double/s_llrint.c @@ -1,17 +1,9 @@ #include "math_private.h" -#ifdef USE_SSE -#if (defined _M_IX86 || defined __i386__) -#define USE_32BIT -#endif - +#if defined(USE_SSE) && !(defined _M_IX86 || defined __i386__) long long gm_llrint(double x) { -#ifdef USE_32BIT - return _mm_cvtsd_si32(_mm_load_sd(&x)); -#else return _mm_cvtsd_si64(_mm_load_sd(&x)); -#endif } #else #define type double diff --git a/double/s_lrint.c b/double/s_lrint.c index 9111050..680ddda 100644 --- a/double/s_lrint.c +++ b/double/s_lrint.c @@ -7,7 +7,7 @@ long gm_lrint(double x) { -#ifdef USE_32BIT +#if defined(USE_32BIT) || defined(_WIN32) // long is always 32bit on windows return (long)_mm_cvtsd_si32(_mm_load_sd(&x)); #else return (long)_mm_cvtsd_si64(_mm_load_sd(&x)); diff --git a/float/e_sqrtf.c b/float/e_sqrtf.c index 3faa300..31774b9 100644 --- a/float/e_sqrtf.c +++ b/float/e_sqrtf.c @@ -21,6 +21,11 @@ static const float one = 1.0f, tiny=1.0e-30f; float __ieee754_sqrtf(float x) { +#ifdef USE_SSE + float ret; + _mm_store_ss(&ret, _mm_sqrt_ps(_mm_load_ss(&x))); + return ret; +#else float z; int32_t sign = (int)0x80000000; int32_t ix,s,q,m,t,i; @@ -82,4 +87,5 @@ __ieee754_sqrtf(float x) ix += (m <<23); SET_FLOAT_WORD(z,ix); return z; +#endif } diff --git a/float/s_llrintf.c b/float/s_llrintf.c index 93bf536..1884cb5 100644 --- a/float/s_llrintf.c +++ b/float/s_llrintf.c @@ -1,17 +1,9 @@ #include "math_private.h" -#ifdef USE_SSE -#if (defined _M_IX86 || defined __i386__) -#define USE_32BIT -#endif - +#if defined(USE_SSE) && !(defined _M_IX86 || defined __i386__) long long gm_llrintf(float x) { -#ifdef USE_32BIT - return _mm_cvtss_si32(_mm_load_ss(&x)); -#else return _mm_cvtss_si64(_mm_load_ss(&x)); -#endif } #else #define type float diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 2ab4103..bdb3594 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -8,4 +8,14 @@ target_link_libraries(test_lrintf_intrin PRIVATE gamemath::gamemath) if(CMAKE_SYSTEM_NAME STREQUAL "Linux") # Looks like linux needs libm linking for the fenv.h functions? target_link_libraries(test_lrintf_intrin PRIVATE m) -endif() \ No newline at end of file +endif() + +if(CMAKE_C_COMPILER_ID MATCHES "Clang") + set(GM_TEST_OPTIONS -fno-builtin -fno-strict-aliasing -ffp-contract=off -Wno-implicit-function-declaration) +elseif(CMAKE_C_COMPILER_ID MATCHES "GNU") + set(GM_TEST_OPTIONS -fno-gnu89-inline -fno-builtin -fno-strict-aliasing -ffp-contract=off -Wno-implicit-function-declaration) +elseif(MSVC) + set(GM_TEST_OPTIONS /fp:strict /wd4146 /wd4244 /wd4554 /wd4723 /wd4756) +endif() + +target_compile_options(test_lrintf_intrin PRIVATE ${GM_TEST_OPTIONS})