Instead provide local wrappers that handle edge cases according to C99, where msvcrt.dll's functions don't.
Signed-off-by: Martin Storsjö <[email protected]> --- mingw-w64-crt/Makefile.am | 12 ++++++++++++ mingw-w64-crt/lib-common/msvcrt.def.in | 8 ++------ mingw-w64-crt/math/arm-common/logb.c | 17 +++++++++++++++++ mingw-w64-crt/math/arm-common/logbf.c | 17 +++++++++++++++++ mingw-w64-crt/math/arm-common/logbl.c | 16 ++++++++++++++++ mingw-w64-crt/math/arm-common/pow.c | 21 +++++++++++++++++++++ mingw-w64-crt/math/arm-common/powf.c | 21 +++++++++++++++++++++ mingw-w64-crt/math/arm-common/powl.c | 16 ++++++++++++++++ 8 files changed, 122 insertions(+), 6 deletions(-) create mode 100644 mingw-w64-crt/math/arm-common/logb.c create mode 100644 mingw-w64-crt/math/arm-common/logbf.c create mode 100644 mingw-w64-crt/math/arm-common/logbl.c create mode 100644 mingw-w64-crt/math/arm-common/pow.c create mode 100644 mingw-w64-crt/math/arm-common/powf.c create mode 100644 mingw-w64-crt/math/arm-common/powl.c diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am index 4caf073f0..3b4d91930 100644 --- a/mingw-w64-crt/Makefile.am +++ b/mingw-w64-crt/Makefile.am @@ -282,6 +282,12 @@ src_msvcrtarm32+=\ math/arm-common/log1pf.c \ math/arm-common/log1pl.c \ math/arm-common/log2.c \ + math/arm-common/logb.c \ + math/arm-common/logbf.c \ + math/arm-common/logbl.c \ + math/arm-common/pow.c \ + math/arm-common/powf.c \ + math/arm-common/powl.c \ math/arm-common/remainder.c \ math/arm-common/remainderf.c \ math/arm-common/remainderl.c \ @@ -313,6 +319,12 @@ src_msvcrtarm64=\ math/arm-common/log1pf.c \ math/arm-common/log1pl.c \ math/arm-common/log2.c \ + math/arm-common/logb.c \ + math/arm-common/logbf.c \ + math/arm-common/logbl.c \ + math/arm-common/pow.c \ + math/arm-common/powf.c \ + math/arm-common/powl.c \ math/arm-common/remainder.c \ math/arm-common/remainderf.c \ math/arm-common/remainderl.c \ diff --git a/mingw-w64-crt/lib-common/msvcrt.def.in b/mingw-w64-crt/lib-common/msvcrt.def.in index e56caf95a..eab2cc83d 100644 --- a/mingw-w64-crt/lib-common/msvcrt.def.in +++ b/mingw-w64-crt/lib-common/msvcrt.def.in @@ -716,10 +716,7 @@ _localtime64 _lock _locking _logb -F_ARM_ANY(logb == _logb) -F_ARM_ANY(logbl == _logb) F_NON_I386(_logbf) -F_ARM_ANY(logbf == _logbf) F_I386(_longjmpex) _lrotl _lrotr @@ -1454,9 +1451,8 @@ mktime modf DATA F_NON_I386(modff DATA) perror -pow F_X86_ANY(DATA) -F_NON_I386(powf F_X86_ANY(DATA)) -F_ARM_ANY(powl == pow) +pow DATA +F_NON_I386(powf DATA) printf printf_s putc diff --git a/mingw-w64-crt/math/arm-common/logb.c b/mingw-w64-crt/math/arm-common/logb.c new file mode 100644 index 000000000..105a44c09 --- /dev/null +++ b/mingw-w64-crt/math/arm-common/logb.c @@ -0,0 +1,17 @@ +/** + * 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 <math.h> +#include <limits.h> + +extern double (* __MINGW_IMP_SYMBOL(_logb))(double); + +double logb(double x) +{ + if (isinf(x)) + return INFINITY; + return __MINGW_IMP_SYMBOL(_logb)(x); +} diff --git a/mingw-w64-crt/math/arm-common/logbf.c b/mingw-w64-crt/math/arm-common/logbf.c new file mode 100644 index 000000000..565b66aeb --- /dev/null +++ b/mingw-w64-crt/math/arm-common/logbf.c @@ -0,0 +1,17 @@ +/** + * 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 <math.h> +#include <limits.h> + +extern float (* __MINGW_IMP_SYMBOL(_logbf))(float); + +float logbf(float x) +{ + if (isinf(x)) + return INFINITY; + return __MINGW_IMP_SYMBOL(_logbf)(x); +} diff --git a/mingw-w64-crt/math/arm-common/logbl.c b/mingw-w64-crt/math/arm-common/logbl.c new file mode 100644 index 000000000..fca06754d --- /dev/null +++ b/mingw-w64-crt/math/arm-common/logbl.c @@ -0,0 +1,16 @@ +/** + * 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 <math.h> + +long double logbl(long double x) +{ +#if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_) + return logb(x); +#else +#error Not supported on your platform yet +#endif +} diff --git a/mingw-w64-crt/math/arm-common/pow.c b/mingw-w64-crt/math/arm-common/pow.c new file mode 100644 index 000000000..48d52b2ae --- /dev/null +++ b/mingw-w64-crt/math/arm-common/pow.c @@ -0,0 +1,21 @@ +/** + * 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 <math.h> +#include <limits.h> + +extern double (* __MINGW_IMP_SYMBOL(pow))(double, double); + +double pow(double x, double y) +{ + if (x == 1.0) + return 1.0; + if (y == 0.0) + return 1.0; + if (x == -1.0 && isinf(y)) + return 1.0; + return __MINGW_IMP_SYMBOL(pow)(x, y); +} diff --git a/mingw-w64-crt/math/arm-common/powf.c b/mingw-w64-crt/math/arm-common/powf.c new file mode 100644 index 000000000..4d518fe9b --- /dev/null +++ b/mingw-w64-crt/math/arm-common/powf.c @@ -0,0 +1,21 @@ +/** + * 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 <math.h> +#include <limits.h> + +extern float (* __MINGW_IMP_SYMBOL(powf))(float, float); + +float powf(float x, float y) +{ + if (x == 1.0f) + return 1.0f; + if (y == 0.0f) + return 1.0f; + if (x == -1.0f && isinf(y)) + return 1.0f; + return __MINGW_IMP_SYMBOL(powf)(x, y); +} diff --git a/mingw-w64-crt/math/arm-common/powl.c b/mingw-w64-crt/math/arm-common/powl.c new file mode 100644 index 000000000..46e6b2d45 --- /dev/null +++ b/mingw-w64-crt/math/arm-common/powl.c @@ -0,0 +1,16 @@ +/** + * 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 <math.h> + +long double powl(long double x, long double y) +{ +#if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_) + return pow(x, y); +#else +#error Not supported on your platform yet +#endif +} -- 2.17.1 _______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
