This branch improves portability (under Windows).

This commit is contained in:
Daniel Lemire 2020-10-21 16:44:54 -04:00
parent dc46ad4c60
commit 59f4535adf
4 changed files with 108 additions and 8 deletions

27
.github/workflows/alpine.yml vendored Normal file
View File

@ -0,0 +1,27 @@
name: Alpine Linux
'on':
- push
- pull_request
jobs:
ubuntu-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: start docker
run: |
docker run -w /src -dit --name alpine -v $PWD:/src alpine:latest
echo 'docker exec alpine "$@";' > ./alpine.sh
chmod +x ./alpine.sh
- name: install packages
run: |
./alpine.sh apk update
./alpine.sh apk add build-base cmake g++ linux-headers git bash
- name: cmake
run: |
./alpine.sh cmake -DFASTFLOAT_TEST=ON -B build_for_alpine
- name: build
run: |
./alpine.sh cmake --build build_for_alpine
- name: test
run: |
./alpine.sh bash -c "cd build_for_alpine && ctest -R basictest"

44
.github/workflows/msys2.yml vendored Normal file
View File

@ -0,0 +1,44 @@
name: MSYS2-CI
on: [push, pull_request]
jobs:
windows-mingw:
name: ${{ matrix.msystem }}
runs-on: windows-latest
defaults:
run:
shell: msys2 {0}
strategy:
fail-fast: false
matrix:
include:
- msystem: "MINGW64"
install: mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja mingw-w64-x86_64-gcc
type: Release
- msystem: "MINGW32"
install: mingw-w64-i686-cmake mingw-w64-i686-ninja mingw-w64-i686-gcc
type: Release
- msystem: "MINGW64"
install: mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja mingw-w64-x86_64-gcc
type: Debug
- msystem: "MINGW32"
install: mingw-w64-i686-cmake mingw-w64-i686-ninja mingw-w64-i686-gcc
type: Debug
env:
CMAKE_GENERATOR: Ninja
steps:
- uses: actions/checkout@v2
- uses: msys2/setup-msys2@v2
with:
update: true
msystem: ${{ matrix.msystem }}
install: ${{ matrix.install }}
- name: Build and Test
run: |
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=${{ matrix.type }} -DFASTFLOAT_TEST=ON ..
cmake --build . --verbose
ctest --output-on-failure -R basictest

25
.github/workflows/vs16-clang-ci.yml vendored Normal file
View File

@ -0,0 +1,25 @@
ame: VS16-CLANG-CI
on: [push, pull_request]
jobs:
ci:
name: windows-vs16
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: 'Run CMake with VS16'
uses: lukka/run-cmake@v2
with:
cmakeListsOrSettingsJson: CMakeListsTxtAdvanced
cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt'
buildDirectory: "${{ github.workspace }}/../../_temp/windows"
cmakeBuildType: Release
buildWithCMake: true
cmakeGenerator: VS16Win64
cmakeAppendedArgs: -T ClangCL -DFASTFLOAT_TEST=ON
buildWithCMakeArgs: --config Release
- name: 'Run CTest'
run: ctest -C Release -R basictest --output-on-failure
working-directory: "${{ github.workspace }}/../../_temp/windows"

View File

@ -18,14 +18,17 @@
#define fastfloat_really_inline inline __attribute__((always_inline))
#endif
#ifdef _MSC_VER
#define fastfloat_strcasecmp _stricmp
#define fastfloat_strncasecmp _strnicmp
#else
#define fastfloat_strcasecmp strcasecmp
#define fastfloat_strncasecmp strncasecmp
#endif
namespace fast_float {
// Compares two ASCII strings in a case insensitive manner.
inline bool fastfloat_strncasecmp(const char * input1, const char * input2, size_t length) {
char running_diff{0};
for(size_t i = 0; i < length; i++) {
running_diff |= (input1[i] ^ input2[i]);
}
return (running_diff == 0) || (running_diff == 32);
}
#ifndef FLT_EVAL_METHOD
#error "FLT_EVAL_METHOD should be defined, please include cfloat."
#endif
@ -72,7 +75,8 @@ int leading_zeroes(uint64_t input_num) {
}
#ifdef FASTFLOAT_VISUAL_STUDIO
#if defined(_WIN32) && !defined(__clang__)
// Note MinGW falls here too
#include <intrin.h>
#if !defined(_M_X64) && !defined(_M_ARM64)// _umul128 for x86, arm