This avoids unnecessary precision loss e.g. in the log2 function, which previously was wrapped as log(x) / constant, which didn't return exact integers for powers of two.
Some math functions are kept for msvcrt, while they are superfluous for ucrt where all those functions exist already (in C99 compliant form). For msvcrt, use ceil/floor from the import library instead of a local reimplementation. For all details I've tested in https://github.com/mstorsjo/llvm-mingw/blob/master/test/crt-test.c, the msvcrt.dll version of these functions on arm/arm64 are compliant. Signed-off-by: Martin Storsjö <mar...@martin.st> --- mingw-w64-crt/Makefile.am | 35 ++++++++++++++----- .../api-ms-win-crt-math-l1-1-0.def.in | 10 +++--- mingw-w64-crt/lib-common/msvcrt.def.in | 10 +++--- mingw-w64-crt/lib-common/ucrtbase.def.in | 10 +++--- mingw-w64-crt/math/arm/ceil.S | 29 --------------- mingw-w64-crt/math/arm/ceilf.S | 28 --------------- mingw-w64-crt/math/arm/ceill.S | 28 --------------- mingw-w64-crt/math/arm/floor.S | 28 --------------- mingw-w64-crt/math/arm/floorf.S | 27 -------------- mingw-w64-crt/math/arm/floorl.S | 28 --------------- mingw-w64-crt/math/arm64/ceil.S | 16 --------- mingw-w64-crt/math/arm64/ceilf.S | 16 --------- mingw-w64-crt/math/arm64/ceill.S | 15 -------- mingw-w64-crt/math/arm64/floor.S | 15 -------- mingw-w64-crt/math/arm64/floorf.S | 15 -------- mingw-w64-crt/math/arm64/floorl.S | 15 -------- 16 files changed, 44 insertions(+), 281 deletions(-) delete mode 100644 mingw-w64-crt/math/arm/ceil.S delete mode 100644 mingw-w64-crt/math/arm/ceilf.S delete mode 100644 mingw-w64-crt/math/arm/ceill.S delete mode 100644 mingw-w64-crt/math/arm/floor.S delete mode 100644 mingw-w64-crt/math/arm/floorf.S delete mode 100644 mingw-w64-crt/math/arm/floorl.S delete mode 100644 mingw-w64-crt/math/arm64/ceil.S delete mode 100644 mingw-w64-crt/math/arm64/ceilf.S delete mode 100644 mingw-w64-crt/math/arm64/ceill.S delete mode 100644 mingw-w64-crt/math/arm64/floor.S delete mode 100644 mingw-w64-crt/math/arm64/floorf.S delete mode 100644 mingw-w64-crt/math/arm64/floorl.S diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am index d63abf63e..0d83feda9 100644 --- a/mingw-w64-crt/Makefile.am +++ b/mingw-w64-crt/Makefile.am @@ -249,8 +249,31 @@ src_msvcrtarm32=\ misc/__p__fmode.c \ misc/__p__wcmdln.c +if !ENABLE_SOFTMATH +src_msvcrtarm32+=\ + math/arm/exp2.c \ + math/arm/nearbyint.S \ + math/arm/nearbyintf.S \ + math/arm/nearbyintl.S \ + math/arm/trunc.S \ + math/arm/truncf.S \ + math/arm-common/copysignl.c \ + math/arm-common/log2.c \ + math/arm-common/scalbn.c +endif + src_msvcrtarm64=\ $(src_msvcrt) \ + math/arm-common/copysignl.c \ + math/arm-common/log2.c \ + math/arm-common/scalbn.c \ + math/arm64/exp2.S \ + math/arm64/exp2f.S \ + math/arm64/nearbyint.S \ + math/arm64/nearbyintf.S \ + math/arm64/nearbyintl.S \ + math/arm64/trunc.S \ + math/arm64/truncf.S \ misc/__p___argv.c \ misc/__p__acmdln.c \ misc/__p__fmode.c \ @@ -383,9 +406,7 @@ src_libmingwex64=$(src_libmingwex_x86) # these only go into the ARM32 version: src_libmingwexarm32=\ - math/arm/_chgsignl.S math/arm/ceil.S math/arm/ceilf.S math/arm/ceill.S math/arm-common/copysignl.c \ - math/arm/floor.S math/arm/floorf.S math/arm/floorl.S math/arm/nearbyint.S math/arm/nearbyintf.S \ - math/arm/nearbyintl.S math/arm/trunc.S math/arm/truncf.S + math/arm/_chgsignl.S if ENABLE_SOFTMATH src_libmingwexarm32+=\ @@ -407,16 +428,12 @@ src_libmingwexarm32+=\ math/softmath/sinf.c math/softmath/sinl.c math/softmath/tanf.c math/softmath/tanl.c else src_libmingwexarm32+=\ - math/arm/exp2.c math/arm-common/ldexpl.c math/arm-common/log2.c math/arm-common/scalbn.c math/arm-common/sincos.c + math/arm-common/ldexpl.c math/arm-common/sincos.c endif # these only go into the ARM64 version: src_libmingwexarm64=\ - math/arm64/_chgsignl.S math/arm64/ceil.S math/arm64/ceilf.S math/arm64/ceill.S math/arm-common/copysignl.c \ - math/arm64/exp2.S math/arm64/exp2f.S math/arm64/floor.S math/arm64/floorf.S math/arm64/floorl.S \ - math/arm-common/ldexpl.c \ - math/arm-common/log2.c math/arm64/nearbyint.S math/arm64/nearbyintf.S math/arm64/nearbyintl.S math/arm-common/scalbn.c \ - math/arm-common/sincos.c math/arm64/trunc.S math/arm64/truncf.S + math/arm64/_chgsignl.S math/arm-common/ldexpl.c math/arm-common/sincos.c # These intrinsics are target independent: diff --git a/mingw-w64-crt/lib-common/api-ms-win-crt-math-l1-1-0.def.in b/mingw-w64-crt/lib-common/api-ms-win-crt-math-l1-1-0.def.in index 51c49ea7b..d208cea3b 100644 --- a/mingw-w64-crt/lib-common/api-ms-win-crt-math-l1-1-0.def.in +++ b/mingw-w64-crt/lib-common/api-ms-win-crt-math-l1-1-0.def.in @@ -197,8 +197,9 @@ ccosh ccoshf ccoshl ccosl -ceil DATA -F_NON_I386(ceilf DATA) +ceil F_X86_ANY(DATA) +F_NON_I386(ceilf F_X86_ANY(DATA)) +F_ARM_ANY(ceill == ceil) cexp cexpf cexpl @@ -264,8 +265,9 @@ F_ARM_ANY(fabsf) fdim fdimf fdiml -floor DATA -F_NON_I386(floorf DATA) +floor F_X86_ANY(DATA) +F_NON_I386(floorf F_X86_ANY(DATA)) +F_ARM_ANY(floorl == floor) fma fmaf fmal diff --git a/mingw-w64-crt/lib-common/msvcrt.def.in b/mingw-w64-crt/lib-common/msvcrt.def.in index 1c4f40899..c0d4f65c5 100644 --- a/mingw-w64-crt/lib-common/msvcrt.def.in +++ b/mingw-w64-crt/lib-common/msvcrt.def.in @@ -1316,8 +1316,9 @@ bsearch bsearch_s F_ARM_ANY(btowc) calloc -ceil DATA -F_NON_I386(ceilf DATA) +ceil F_X86_ANY(DATA) +F_NON_I386(ceilf F_X86_ANY(DATA)) +F_ARM_ANY(ceill == ceil) clearerr clearerr_s clock @@ -1342,8 +1343,9 @@ fgetpos fgets fgetwc fgetws -floor DATA -F_NON_I386(floorf DATA) +floor F_X86_ANY(DATA) +F_NON_I386(floorf F_X86_ANY(DATA)) +F_ARM_ANY(floorl == floor) fmod F_X86_ANY(DATA) F_NON_I386(fmodf F_X86_ANY(DATA)) fopen diff --git a/mingw-w64-crt/lib-common/ucrtbase.def.in b/mingw-w64-crt/lib-common/ucrtbase.def.in index 49a55521e..d97dcd4a9 100644 --- a/mingw-w64-crt/lib-common/ucrtbase.def.in +++ b/mingw-w64-crt/lib-common/ucrtbase.def.in @@ -2241,8 +2241,9 @@ ccosh ccoshf ccoshl ccosl -ceil DATA -F_NON_I386(ceilf DATA) +ceil F_X86_ANY(DATA) +F_NON_I386(ceilf F_X86_ANY(DATA)) +F_ARM_ANY(ceill == ceil) cexp cexpf cexpl @@ -2331,8 +2332,9 @@ fgetpos fgets fgetwc fgetws -floor DATA -F_NON_I386(floorf DATA) +floor F_X86_ANY(DATA) +F_NON_I386(floorf F_X86_ANY(DATA)) +F_ARM_ANY(floorl == floor) fma fmaf fmal diff --git a/mingw-w64-crt/math/arm/ceil.S b/mingw-w64-crt/math/arm/ceil.S deleted file mode 100644 index 47162c9af..000000000 --- a/mingw-w64-crt/math/arm/ceil.S +++ /dev/null @@ -1,29 +0,0 @@ -/** - * This file has no copyright assigned and is placed in the Public Domain. - * This file is part of the mingw-w64 runtime package. - * No warranty is given; refer to the file DISCLAIMER.PD within this package. - */ -#include <_mingw_mac.h> - - .file "ceil.S" - .text - .align 4 - .globl __MINGW_USYMBOL(ceil) - .def __MINGW_USYMBOL(ceil); .scl 2; .type 32; .endef - -__MINGW_USYMBOL(ceil): - vmov r2, r3, d0 - lsr r3, r3, #20 - bic r3, r3, #0x800 - movw r2, #0x7ff - cmp r2, r3 /* Check for INF/NAN, just return the input in those cases */ - it eq - bxeq lr - vmrs r1, fpscr - bic r0, r1, #0x00c00000 - orr r0, r0, #0x00400000 /* Round towards Plus Infinity */ - vmsr fpscr, r0 - vcvtr.s32.f64 s0, d0 - vcvt.f64.s32 d0, s0 - vmsr fpscr, r1 - bx lr diff --git a/mingw-w64-crt/math/arm/ceilf.S b/mingw-w64-crt/math/arm/ceilf.S deleted file mode 100644 index a899f25fa..000000000 --- a/mingw-w64-crt/math/arm/ceilf.S +++ /dev/null @@ -1,28 +0,0 @@ -/** - * This file has no copyright assigned and is placed in the Public Domain. - * This file is part of the mingw-w64 runtime package. - * No warranty is given; refer to the file DISCLAIMER.PD within this package. - */ -#include <_mingw_mac.h> - - .file "ceilf.S" - .text - .align 4 - .globl __MINGW_USYMBOL(ceilf) - .def __MINGW_USYMBOL(ceilf); .scl 2; .type 32; .endef - -__MINGW_USYMBOL(ceilf): - vmov r2, s0 - lsr r2, r2, #23 - bic r2, r2, #0x100 - cmp r2, #0xff /* Check for INF/NAN, just return the input in those cases */ - it eq - bxeq lr - vmrs r1, fpscr - bic r0, r1, #0x00c00000 - orr r0, r0, #0x00400000 /* Round towards Plus Infinity */ - vmsr fpscr, r0 - vcvtr.s32.f32 s0, s0 - vcvt.f32.s32 s0, s0 - vmsr fpscr, r1 - bx lr diff --git a/mingw-w64-crt/math/arm/ceill.S b/mingw-w64-crt/math/arm/ceill.S deleted file mode 100644 index 9c6934ba0..000000000 --- a/mingw-w64-crt/math/arm/ceill.S +++ /dev/null @@ -1,28 +0,0 @@ -/** - * This file has no copyright assigned and is placed in the Public Domain. - * This file is part of the mingw-w64 runtime package. - * No warranty is given; refer to the file DISCLAIMER.PD within this package. - */ -#include <_mingw_mac.h> - - .file "ceill.S" - .text - .align 4 - .globl __MINGW_USYMBOL(ceill) - .def __MINGW_USYMBOL(ceill); .scl 2; .type 32; .endef -__MINGW_USYMBOL(ceill): - vmov r2, r3, d0 - lsr r3, r3, #20 - bic r3, r3, #0x800 - movw r2, #0x7ff - cmp r2, r3 /* Check for INF/NAN, just return the input in those cases */ - it eq - bxeq lr - vmrs r1, fpscr - bic r0, r1, #0x00c00000 - orr r0, r0, #0x00400000 /* Round towards Plus Infinity */ - vmsr fpscr, r0 - vcvtr.s32.f64 s0, d0 - vcvt.f64.s32 d0, s0 - vmsr fpscr, r1 - bx lr diff --git a/mingw-w64-crt/math/arm/floor.S b/mingw-w64-crt/math/arm/floor.S deleted file mode 100644 index fc1df16af..000000000 --- a/mingw-w64-crt/math/arm/floor.S +++ /dev/null @@ -1,28 +0,0 @@ -/** - * This file has no copyright assigned and is placed in the Public Domain. - * This file is part of the mingw-w64 runtime package. - * No warranty is given; refer to the file DISCLAIMER.PD within this package. - */ -#include <_mingw_mac.h> - - .file "floor.S" - .text - .p2align 4,,15 - .globl __MINGW_USYMBOL(floor) - .def __MINGW_USYMBOL(floor); .scl 2; .type 32; .endef -__MINGW_USYMBOL(floor): - vmov r2, r3, d0 - lsr r3, r3, #20 - bic r3, r3, #0x800 - movw r2, #0x7ff - cmp r2, r3 /* Check for INF/NAN, just return the input in those cases */ - it eq - bxeq lr - vmrs r1, fpscr - bic r0, r1, #0x00c00000 - orr r0, r0, #0x00800000 /* Round towards Minus Infinity */ - vmsr fpscr, r0 - vcvtr.s32.f64 s0, d0 - vcvt.f64.s32 d0, s0 - vmsr fpscr, r1 - bx lr diff --git a/mingw-w64-crt/math/arm/floorf.S b/mingw-w64-crt/math/arm/floorf.S deleted file mode 100644 index b5ae0c720..000000000 --- a/mingw-w64-crt/math/arm/floorf.S +++ /dev/null @@ -1,27 +0,0 @@ -/** - * This file has no copyright assigned and is placed in the Public Domain. - * This file is part of the mingw-w64 runtime package. - * No warranty is given; refer to the file DISCLAIMER.PD within this package. - */ - #include <_mingw_mac.h> - - .file "floorf.S" - .text - .p2align 4,,15 - .globl __MINGW_USYMBOL(floorf) - .def __MINGW_USYMBOL(floorf); .scl 2; .type 32; .endef -__MINGW_USYMBOL(floorf): - vmov r2, s0 - lsr r2, r2, #23 - bic r2, r2, #0x100 - cmp r2, #0xff /* Check for INF/NAN, just return the input in those cases */ - it eq - bxeq lr - vmrs r1, fpscr - bic r0, r1, #0x00c00000 - orr r0, r0, #0x00800000 /* Round towards Minus Infinity */ - vmsr fpscr, r0 - vcvtr.s32.f32 s0, s0 - vcvt.f32.s32 s0, s0 - vmsr fpscr, r1 - bx lr diff --git a/mingw-w64-crt/math/arm/floorl.S b/mingw-w64-crt/math/arm/floorl.S deleted file mode 100644 index ec8c0050a..000000000 --- a/mingw-w64-crt/math/arm/floorl.S +++ /dev/null @@ -1,28 +0,0 @@ -/** - * This file has no copyright assigned and is placed in the Public Domain. - * This file is part of the mingw-w64 runtime package. - * No warranty is given; refer to the file DISCLAIMER.PD within this package. - */ -#include <_mingw_mac.h> - - .file "floorl.S" - .text - .align 4 - .globl __MINGW_USYMBOL(floorl) - .def __MINGW_USYMBOL(floorl); .scl 2; .type 32; .endef -__MINGW_USYMBOL(floorl): - vmov r2, r3, d0 - lsr r3, r3, #20 - bic r3, r3, #0x800 - movw r2, #0x7ff - cmp r2, r3 /* Check for INF/NAN, just return the input in those cases */ - it eq - bxeq lr - vmrs r1, fpscr - bic r0, r1, #0x00c00000 - orr r0, r0, #0x00800000 /* Round towards Minus Infinity */ - vmsr fpscr, r0 - vcvtr.s32.f64 s0, d0 - vcvt.f64.s32 d0, s0 - vmsr fpscr, r1 - bx lr diff --git a/mingw-w64-crt/math/arm64/ceil.S b/mingw-w64-crt/math/arm64/ceil.S deleted file mode 100644 index 6f46d352f..000000000 --- a/mingw-w64-crt/math/arm64/ceil.S +++ /dev/null @@ -1,16 +0,0 @@ -/** - * This file has no copyright assigned and is placed in the Public Domain. - * This file is part of the mingw-w64 runtime package. - * No warranty is given; refer to the file DISCLAIMER.PD within this package. - */ -#include <_mingw_mac.h> - - .file "ceil.S" - .text - .align 2 - .globl __MINGW_USYMBOL(ceil) - .def __MINGW_USYMBOL(ceil); .scl 2; .type 32; .endef - -__MINGW_USYMBOL(ceil): - frintp d0, d0 - ret diff --git a/mingw-w64-crt/math/arm64/ceilf.S b/mingw-w64-crt/math/arm64/ceilf.S deleted file mode 100644 index b67d7687a..000000000 --- a/mingw-w64-crt/math/arm64/ceilf.S +++ /dev/null @@ -1,16 +0,0 @@ -/** - * This file has no copyright assigned and is placed in the Public Domain. - * This file is part of the mingw-w64 runtime package. - * No warranty is given; refer to the file DISCLAIMER.PD within this package. - */ -#include <_mingw_mac.h> - - .file "ceilf.S" - .text - .align 2 - .globl __MINGW_USYMBOL(ceilf) - .def __MINGW_USYMBOL(ceilf); .scl 2; .type 32; .endef - -__MINGW_USYMBOL(ceilf): - frintp s0, s0 - ret diff --git a/mingw-w64-crt/math/arm64/ceill.S b/mingw-w64-crt/math/arm64/ceill.S deleted file mode 100644 index 99385a36d..000000000 --- a/mingw-w64-crt/math/arm64/ceill.S +++ /dev/null @@ -1,15 +0,0 @@ -/** - * This file has no copyright assigned and is placed in the Public Domain. - * This file is part of the mingw-w64 runtime package. - * No warranty is given; refer to the file DISCLAIMER.PD within this package. - */ -#include <_mingw_mac.h> - - .file "ceill.S" - .text - .align 2 - .globl __MINGW_USYMBOL(ceill) - .def __MINGW_USYMBOL(ceill); .scl 2; .type 32; .endef -__MINGW_USYMBOL(ceill): - frintp d0, d0 - ret diff --git a/mingw-w64-crt/math/arm64/floor.S b/mingw-w64-crt/math/arm64/floor.S deleted file mode 100644 index fc3f002d1..000000000 --- a/mingw-w64-crt/math/arm64/floor.S +++ /dev/null @@ -1,15 +0,0 @@ -/** - * This file has no copyright assigned and is placed in the Public Domain. - * This file is part of the mingw-w64 runtime package. - * No warranty is given; refer to the file DISCLAIMER.PD within this package. - */ -#include <_mingw_mac.h> - - .file "floor.S" - .text - .p2align 2 - .globl __MINGW_USYMBOL(floor) - .def __MINGW_USYMBOL(floor); .scl 2; .type 32; .endef -__MINGW_USYMBOL(floor): - frintm d0, d0 - ret diff --git a/mingw-w64-crt/math/arm64/floorf.S b/mingw-w64-crt/math/arm64/floorf.S deleted file mode 100644 index d24db9226..000000000 --- a/mingw-w64-crt/math/arm64/floorf.S +++ /dev/null @@ -1,15 +0,0 @@ -/** - * This file has no copyright assigned and is placed in the Public Domain. - * This file is part of the mingw-w64 runtime package. - * No warranty is given; refer to the file DISCLAIMER.PD within this package. - */ - #include <_mingw_mac.h> - - .file "floorf.S" - .text - .p2align 2 - .globl __MINGW_USYMBOL(floorf) - .def __MINGW_USYMBOL(floorf); .scl 2; .type 32; .endef -__MINGW_USYMBOL(floorf): - frintm s0, s0 - ret diff --git a/mingw-w64-crt/math/arm64/floorl.S b/mingw-w64-crt/math/arm64/floorl.S deleted file mode 100644 index 746738d6c..000000000 --- a/mingw-w64-crt/math/arm64/floorl.S +++ /dev/null @@ -1,15 +0,0 @@ -/** - * This file has no copyright assigned and is placed in the Public Domain. - * This file is part of the mingw-w64 runtime package. - * No warranty is given; refer to the file DISCLAIMER.PD within this package. - */ -#include <_mingw_mac.h> - - .file "floorl.S" - .text - .align 2 - .globl __MINGW_USYMBOL(floorl) - .def __MINGW_USYMBOL(floorl); .scl 2; .type 32; .endef -__MINGW_USYMBOL(floorl): - frintm d0, d0 - ret -- 2.17.1 _______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public