Skip to content

Commit a7fbcb0

Browse files
authored
Merge pull request #81 from fastfloat/dlemire/windows_arm
Adding a build test for Windows ARM.
2 parents e3af106 + 2504268 commit a7fbcb0

File tree

4 files changed

+37
-11
lines changed

4 files changed

+37
-11
lines changed

.github/workflows/vs16-arm-ci.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: VS16-ARM-CI
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
ci:
7+
name: windows-vs16
8+
runs-on: windows-latest
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
include:
13+
- {arch: ARM}
14+
- {arch: ARM64}
15+
steps:
16+
- name: checkout
17+
uses: actions/checkout@v2
18+
- name: Use cmake
19+
run: |
20+
cmake -A ${{ matrix.arch }} -DCMAKE_CROSSCOMPILING=1 -DFASTFLOAT_TEST=ON -B build &&
21+
cmake --build build --verbose

include/fast_float/float_common.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,23 +129,21 @@ fastfloat_really_inline int leading_zeroes(uint64_t input_num) {
129129

130130
#ifdef FASTFLOAT_32BIT
131131

132-
#if (!defined(_WIN32)) || defined(__MINGW32__)
133132
// slow emulation routine for 32-bit
134-
fastfloat_really_inline uint64_t __emulu(uint32_t x, uint32_t y) {
133+
fastfloat_really_inline uint64_t emulu(uint32_t x, uint32_t y) {
135134
return x * (uint64_t)y;
136135
}
137-
#endif
138136

139137
// slow emulation routine for 32-bit
140138
#if !defined(__MINGW64__)
141139
fastfloat_really_inline uint64_t _umul128(uint64_t ab, uint64_t cd,
142140
uint64_t *hi) {
143-
uint64_t ad = __emulu((uint32_t)(ab >> 32), (uint32_t)cd);
144-
uint64_t bd = __emulu((uint32_t)ab, (uint32_t)cd);
145-
uint64_t adbc = ad + __emulu((uint32_t)ab, (uint32_t)(cd >> 32));
141+
uint64_t ad = emulu((uint32_t)(ab >> 32), (uint32_t)cd);
142+
uint64_t bd = emulu((uint32_t)ab, (uint32_t)cd);
143+
uint64_t adbc = ad + emulu((uint32_t)ab, (uint32_t)(cd >> 32));
146144
uint64_t adbc_carry = !!(adbc < ad);
147145
uint64_t lo = bd + (adbc << 32);
148-
*hi = __emulu((uint32_t)(ab >> 32), (uint32_t)(cd >> 32)) + (adbc >> 32) +
146+
*hi = emulu((uint32_t)(ab >> 32), (uint32_t)(cd >> 32)) + (adbc >> 32) +
149147
(adbc_carry << 32) + !!(lo < bd);
150148
return lo;
151149
}

tests/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ include(FetchContent)
66

77
FetchContent_Declare(doctest
88
GIT_REPOSITORY https://github.com/onqtam/doctest.git
9-
GIT_TAG 2.4.1)
9+
GIT_TAG 2.4.6)
1010
FetchContent_Declare(supplemental_test_files
1111
GIT_REPOSITORY https://github.com/fastfloat/supplemental_test_files.git
1212
GIT_TAG origin/main)
@@ -33,6 +33,9 @@ target_compile_definitions(supplemental-data INTERFACE SUPPLEMENTAL_TEST_DATA_DI
3333
function(fast_float_add_cpp_test TEST_NAME)
3434
add_executable(${TEST_NAME} ${TEST_NAME}.cpp)
3535
add_test(${TEST_NAME} ${TEST_NAME})
36+
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
37+
target_compile_options(${TEST_NAME} PUBLIC /EHsc)
38+
endif()
3639
if(NOT WIN32)
3740
target_compile_options(${TEST_NAME} PUBLIC -Werror -Wall -Wextra -Weffc++)
3841
target_compile_options(${TEST_NAME} PUBLIC -Wsign-compare -Wshadow -Wwrite-strings -Wpointer-arith -Winit-self -Wconversion -Wsign-conversion)

tests/basictest.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -477,9 +477,13 @@ TEST_CASE("32bit.general") {
477477
verify(append_zeros("1.1754941406275178592461758986628081843312458647327962400313859427181746759860647699724722770042717456817626953125",655), 0x1.2ced3p+0f);
478478
verify(append_zeros("1.1754941406275178592461758986628081843312458647327962400313859427181746759860647699724722770042717456817626953125",656), 0x1.2ced3p+0f);
479479
verify(append_zeros("1.1754941406275178592461758986628081843312458647327962400313859427181746759860647699724722770042717456817626953125",1000), 0x1.2ced3p+0f);
480-
verify(append_zeros("1.1754941406275178592461758986628081843312458647327962400313859427181746759860647699724722770042717456817626953125",655) + "e-38", 0x1.fffff8p-127f);
481-
verify(append_zeros("1.1754941406275178592461758986628081843312458647327962400313859427181746759860647699724722770042717456817626953125",656) + "e-38", 0x1.fffff8p-127f);
482-
verify(append_zeros("1.1754941406275178592461758986628081843312458647327962400313859427181746759860647699724722770042717456817626953125",1000) + "e-38", 0x1.fffff8p-127f);
480+
std::string test_string;
481+
test_string = append_zeros("1.1754941406275178592461758986628081843312458647327962400313859427181746759860647699724722770042717456817626953125",655) + std::string("e-38");
482+
verify(test_string, 0x1.fffff8p-127f);
483+
test_string = append_zeros("1.1754941406275178592461758986628081843312458647327962400313859427181746759860647699724722770042717456817626953125",656) + std::string("e-38");
484+
verify(test_string, 0x1.fffff8p-127f);
485+
test_string = append_zeros("1.1754941406275178592461758986628081843312458647327962400313859427181746759860647699724722770042717456817626953125",1000) + std::string("e-38");
486+
verify(test_string, 0x1.fffff8p-127f);
483487
verify32(1.00000006e+09f);
484488
verify32(1.4012984643e-45f);
485489
verify32(1.1754942107e-38f);

0 commit comments

Comments
 (0)