Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,9 @@ CPackSourceConfig.cmake
*.tmp
*.bak
thumbs.db

/CMakeUserPresets.json
/.cache
.clang-format
/.vscode
/.vs
9 changes: 2 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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()
Expand Down
6 changes: 6 additions & 0 deletions double/e_sqrt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -181,6 +186,7 @@ __ieee754_sqrt(double x)
ix0 += (m <<20);
INSERT_WORDS(z,ix0,ix1);
return z;
#endif
}

/*
Expand Down
10 changes: 1 addition & 9 deletions double/s_llrint.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion double/s_lrint.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
6 changes: 6 additions & 0 deletions float/e_sqrtf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -82,4 +87,5 @@ __ieee754_sqrtf(float x)
ix += (m <<23);
SET_FLOAT_WORD(z,ix);
return z;
#endif
}
10 changes: 1 addition & 9 deletions float/s_llrintf.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down
12 changes: 11 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
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})
Loading