From 18349287f41743d865b0e81b5db0bbd913769636 Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Mon, 6 Feb 2023 14:39:21 -0500 Subject: [PATCH 1/4] Trying to extend alpine. --- .github/workflows/alpine.yml | 54 ++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/.github/workflows/alpine.yml b/.github/workflows/alpine.yml index 459008a..eb6b2c4 100644 --- a/.github/workflows/alpine.yml +++ b/.github/workflows/alpine.yml @@ -1,27 +1,45 @@ name: Alpine Linux -'on': +on: - push - pull_request + jobs: - ubuntu-build: + build: + name: Build on Alpine ${{ matrix.arch }} runs-on: ubuntu-latest + strategy: + matrix: + arch: + - x86_64 + - aarch64 + - armv7 + - ppc64le + - riscv64 steps: - - uses: actions/checkout@v3 - - name: start docker + - name: Checkout repository + uses: actions/checkout@v1 + + - name: Install latest Alpine Linux for ${{ matrix.arch }} + uses: jirutka/setup-alpine@v1 + with: + arch: ${{ matrix.arch }} + branch: ${{ matrix.arch == 'riscv64' && 'edge' || 'latest-stable' }} + packages: > + build-base + cmake + g++ + linux-headers + git + bashbuild-base + - name: Prepare 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 + cmake -DFASTFLOAT_TEST=ON -B build + shell: alpine.sh {0} + - name: Build run: | - ./alpine.sh apk update - ./alpine.sh apk add build-base cmake g++ linux-headers git bash - - name: cmake + cmake --build build + shell: alpine.sh {0} + - name: Test 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" + ctest --test-dir build -R basictest + shell: alpine.sh {0} From be2e6bb6933c13ac2319e7d6ea784d7d7054a3fc Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Mon, 6 Feb 2023 14:42:29 -0500 Subject: [PATCH 2/4] Typo. --- .github/workflows/alpine.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/alpine.yml b/.github/workflows/alpine.yml index eb6b2c4..0805b7a 100644 --- a/.github/workflows/alpine.yml +++ b/.github/workflows/alpine.yml @@ -30,7 +30,8 @@ jobs: g++ linux-headers git - bashbuild-base + bash + build-base - name: Prepare run: | cmake -DFASTFLOAT_TEST=ON -B build From 764a064c12f38bd701a26ee6979de91eb07c014e Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Mon, 6 Feb 2023 14:48:41 -0500 Subject: [PATCH 3/4] Adding back x86 --- .github/workflows/alpine.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/alpine.yml b/.github/workflows/alpine.yml index 0805b7a..7c82a49 100644 --- a/.github/workflows/alpine.yml +++ b/.github/workflows/alpine.yml @@ -11,6 +11,7 @@ jobs: matrix: arch: - x86_64 + - x86 - aarch64 - armv7 - ppc64le From 252a1c9dce56c519ebf11c26c19f451e9fe87726 Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Mon, 6 Feb 2023 17:22:11 -0500 Subject: [PATCH 4/4] Minor fix. --- include/fast_float/parse_number.h | 4 ++++ tests/basictest.cpp | 2 ++ 2 files changed, 6 insertions(+) diff --git a/include/fast_float/parse_number.h b/include/fast_float/parse_number.h index 2493b02..3284443 100644 --- a/include/fast_float/parse_number.h +++ b/include/fast_float/parse_number.h @@ -66,6 +66,10 @@ from_chars_result parse_infnan(const char *first, const char *last, T &value) n * Credit : @mwalcott3 */ fastfloat_really_inline bool rounds_to_nearest() noexcept { + // https://lemire.me/blog/2020/06/26/gcc-not-nearest/ +#if (FLT_EVAL_METHOD != 1) && (FLT_EVAL_METHOD != 0) + return false; +#endif // See // A fast function to check your floating-point rounding mode // https://lemire.me/blog/2022/11/16/a-fast-function-to-check-your-floating-point-rounding-mode/ diff --git a/tests/basictest.cpp b/tests/basictest.cpp index 8bdd4df..433a9b5 100644 --- a/tests/basictest.cpp +++ b/tests/basictest.cpp @@ -132,7 +132,9 @@ TEST_CASE("rounds_to_nearest") { fesetround(FE_TONEAREST); std::cout << "FE_TONEAREST: fmin + 1.0f = " << iHexAndDec(fmin + 1.0f) << " 1.0f - fmin = " << iHexAndDec(1.0f - fmin) << std::endl; CHECK(fegetround() == FE_TONEAREST); +#if (FLT_EVAL_METHOD == 1) || (FLT_EVAL_METHOD == 0) CHECK(fast_float::detail::rounds_to_nearest() == true); +#endif } TEST_CASE("parse_zero") {