From 59f4535adf6f26c6f02ab7203e52893167b3ff53 Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Wed, 21 Oct 2020 16:44:54 -0400 Subject: [PATCH] This branch improves portability (under Windows). --- .github/workflows/alpine.yml | 27 ++++++++++++++++++ .github/workflows/msys2.yml | 44 +++++++++++++++++++++++++++++ .github/workflows/vs16-clang-ci.yml | 25 ++++++++++++++++ include/fast_float/float_common.h | 20 +++++++------ 4 files changed, 108 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/alpine.yml create mode 100644 .github/workflows/msys2.yml create mode 100644 .github/workflows/vs16-clang-ci.yml diff --git a/.github/workflows/alpine.yml b/.github/workflows/alpine.yml new file mode 100644 index 0000000..8259376 --- /dev/null +++ b/.github/workflows/alpine.yml @@ -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" \ No newline at end of file diff --git a/.github/workflows/msys2.yml b/.github/workflows/msys2.yml new file mode 100644 index 0000000..b6177f4 --- /dev/null +++ b/.github/workflows/msys2.yml @@ -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 \ No newline at end of file diff --git a/.github/workflows/vs16-clang-ci.yml b/.github/workflows/vs16-clang-ci.yml new file mode 100644 index 0000000..ba58239 --- /dev/null +++ b/.github/workflows/vs16-clang-ci.yml @@ -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" \ No newline at end of file diff --git a/include/fast_float/float_common.h b/include/fast_float/float_common.h index bc8a4f1..0dc487a 100644 --- a/include/fast_float/float_common.h +++ b/include/fast_float/float_common.h @@ -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 #if !defined(_M_X64) && !defined(_M_ARM64)// _umul128 for x86, arm