Re: [Mingw-w64-public] [PATCH] Remove ARM softfloat math function implementations

2016-09-28 Thread Martin Storsjö

On Wed, 28 Sep 2016, Martin Storsjö wrote:


Just pass calls to msvcrt instead.

The msvcrt math functions might not be fully C99 compliant, but
the current softfloat implementations are lacking in many other ways
(e.g.  crashing due to infinite recursion for some input values, only
working for certain ranges of input values, etc.).

For functions that are missing in msvcrt.dll (log2*, exp2*, scalbn*),
provide small wrappers that fall back on log and pow.

This makes the libav testsuite succeed (when run in wine), when
built with clang for ARM with mingw-w64 - previously a number of
tests failed due to faulty math functions.
---


Sorry about the double post; the other version is smaller and easier to 
read, with all the removals folded and renames detected.


// Martin--
___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


[Mingw-w64-public] [PATCH] Remove ARM softfloat math function implementations

2016-09-28 Thread Martin Storsjö
Just pass calls to msvcrt instead.

The msvcrt math functions might not be fully C99 compliant, but
the current softfloat implementations are lacking in many other ways
(e.g.  crashing due to infinite recursion for some input values, only
working for certain ranges of input values, etc.).

For functions that are missing in msvcrt.dll (log2*, exp2*, scalbn*),
provide small wrappers that fall back on log and pow.

This makes the libav testsuite succeed (when run in wine), when
built with clang for ARM with mingw-w64 - previously a number of
tests failed due to faulty math functions.
---
 mingw-w64-crt/Makefile.am  |  19 +--
 mingw-w64-crt/math/{softmath => arm}/exp2.c|   4 +-
 mingw-w64-crt/math/{softmath => arm}/exp2f.c   |   4 +-
 mingw-w64-crt/math/{softmath => arm}/exp2l.c   |   2 +-
 mingw-w64-crt/math/{softmath => arm}/log2.c|   4 +-
 mingw-w64-crt/math/{softmath => arm}/log2f.c   |   4 +-
 mingw-w64-crt/math/{softmath => arm}/log2l.c   |   2 +-
 mingw-w64-crt/math/{softmath => arm}/scalbn.c  |   2 +-
 mingw-w64-crt/math/{softmath => arm}/scalbnf.c |   2 +-
 mingw-w64-crt/math/{softmath => arm}/scalbnl.c |   2 +-
 mingw-w64-crt/math/softmath/acosf.c|  53 --
 mingw-w64-crt/math/softmath/acosh.c|  64 ---
 mingw-w64-crt/math/softmath/acoshf.c   |  64 ---
 mingw-w64-crt/math/softmath/acoshl.c   |  68 
 mingw-w64-crt/math/softmath/acosl.c|  57 ---
 mingw-w64-crt/math/softmath/asinf.c|  66 
 mingw-w64-crt/math/softmath/asinh.c|  50 --
 mingw-w64-crt/math/softmath/asinhf.c   |  50 --
 mingw-w64-crt/math/softmath/asinhl.c   |  54 --
 mingw-w64-crt/math/softmath/asinl.c|  70 
 mingw-w64-crt/math/softmath/atan2f.c   |  50 --
 mingw-w64-crt/math/softmath/atan2l.c   |  54 --
 mingw-w64-crt/math/softmath/atanf.c|  56 ---
 mingw-w64-crt/math/softmath/atanh.c|  52 --
 mingw-w64-crt/math/softmath/atanhf.c   |  52 --
 mingw-w64-crt/math/softmath/atanhl.c   |  54 --
 mingw-w64-crt/math/softmath/atanl.c|  60 ---
 mingw-w64-crt/math/softmath/bsd_private.h  | 117 -
 mingw-w64-crt/math/softmath/bsd_privatef.h |  68 
 mingw-w64-crt/math/softmath/cos.c  |  83 -
 mingw-w64-crt/math/softmath/cosf.c |  83 -
 mingw-w64-crt/math/softmath/cosl.c |  68 
 mingw-w64-crt/math/softmath/e_fmod.c   | 123 --
 mingw-w64-crt/math/softmath/e_fmodf.c  |  93 ---
 mingw-w64-crt/math/softmath/e_pow.c| 222 -
 mingw-w64-crt/math/softmath/e_powf.c   | 207 ---
 mingw-w64-crt/math/softmath/e_remainder.c  |  54 --
 mingw-w64-crt/math/softmath/e_remainderf.c |  53 --
 mingw-w64-crt/math/softmath/exp.c  |  89 --
 mingw-w64-crt/math/softmath/expl.c |  83 -
 mingw-w64-crt/math/softmath/expm1.c|  66 
 mingw-w64-crt/math/softmath/expm1f.c   |  66 
 mingw-w64-crt/math/softmath/expm1l.c   |  70 
 mingw-w64-crt/math/softmath/fmod.c |  50 --
 mingw-w64-crt/math/softmath/fmodf.c|  50 --
 mingw-w64-crt/math/softmath/fmodl.c|  54 --
 mingw-w64-crt/math/softmath/frexpl.c   |  70 
 mingw-w64-crt/math/softmath/ilogb.c|  50 --
 mingw-w64-crt/math/softmath/ilogbf.c   |  50 --
 mingw-w64-crt/math/softmath/ilogbl.c   |  54 --
 mingw-w64-crt/math/softmath/ldexp.c|  50 --
 mingw-w64-crt/math/softmath/ldexpl.c   |  54 --
 mingw-w64-crt/math/softmath/log.c  |  68 
 mingw-w64-crt/math/softmath/log10l.c   |  54 --
 mingw-w64-crt/math/softmath/log1p.c|  50 --
 mingw-w64-crt/math/softmath/log1pf.c   |  50 --
 mingw-w64-crt/math/softmath/log1pl.c   |  54 --
 mingw-w64-crt/math/softmath/logb.c |  50 --
 mingw-w64-crt/math/softmath/logbf.c|  50 --
 mingw-w64-crt/math/softmath/logbl.c|  54 --
 mingw-w64-crt/math/softmath/logl.c |  72 
 mingw-w64-crt/math/softmath/pow.c  |  50 --
 mingw-w64-crt/math/softmath/powl.c |  54 --
 mingw-w64-crt/math/softmath/remainder.c|  50 --
 mingw-w64-crt/math/softmath/remainderf.c   |  50 --
 mingw-w64-crt/math/softmath/remainderl.c   |  54 --
 mingw-w64-crt/math/softmath/remquo.c   |  62 ---
 mingw-w64-crt/math/softmath/remquof.c  |  62 ---
 mingw-w64-crt/math/softmath/remquol.c  |  62 ---
 mingw-w64-crt/math/softmath/sin.c  |  83 -
 mingw-w64-crt/math/softmath/sincos.c   |  51 --
 mingw-w64-cr

Re: [Mingw-w64-public] CRT math implementations on ARM

2016-09-28 Thread Martin Storsjö

On Wed, 7 Sep 2016, Martin Storsjö wrote:


Hi,

In my testing with mingw-w64 on ARM, I've run into a number of issues with
the implementation of the math routines. Some of these issues are:

The whole family of log functions is problematic (even after my fix for
the number of iterations in 41de4baaccba), e.g. log2() only returns values
in the range -17.6 - 7.73, for values outside.

For some values, it even crashes. IIRC, the issue iss an infinite
recursion; bsd__ieee754_powf calls scalbnf, which calls bsd__ieee754_powf.
E.g. log2f(strtod("1.225000", NULL)) will show this behaviour (using
strtod to avoid any risk of the compiler evaluating it at compile time).

Likewise sin/cos and pow also have implementation accuracy issues - I
haven't dug quite as deep into these, but just removing them (and linking
to the msvcrt.dll versions instead) make the remaining libav testsuite
failures go away. (Tested on wine though, whose msvcrt implementation
might be better in some aspects than the real msvcrt.dll.)

Functions like floor and ceil are implemented using vcvtr.s32.f64, which
effectively limits the range of these functions to what is expressible
with signed 32 bits. This isn't that I've run into in actual real world
code though, but it was noted at some point that it could be an issue.


I understand that mingw-w64 wants to reimplement math functions instead of
linking to msvcrt in order to get proper C99 compliance. For the mentioned
families of functions (log, pow, sin, cos), what C99 compliance issues are
there with the msvcrt.dll implementations?


With no response to this (André?), I'll post my patch for removing the 
softfloat math functions and just delegating to msvcrt.dll. If someone 
actually runs into issues with C99 compliance after that, we can look into 
fixing that in one way or another (see the previous mail for some 
suggestions), but the current softfloat functions don't work reliably 
enough for real applications.


// Martin--
___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] [PATCH] fix uchar.h for Clang

2016-09-28 Thread JonY
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

On 9/28/2016 18:02, Mateusz wrote:
> Looks attachment didn't work. Here is the patch:
> 
>> From e98ec7a116256108831f035eb0a7f0f2fdf049e9 Mon Sep 17 00:00:00
>> 2001
> From: mati865  Date: Wed, 28 Sep 2016 11:45:40
> +0200 Subject: [PATCH] fix uchar.h for Clang
> 
> Clang defines itself as GCC 4.2.1 and triggers check for GCC lower
> than 4.4.0. This patch adds additional !defined(__clang__) check 
> --- mingw-w64-headers/crt/uchar.h | 2 +- 1 file changed, 1
> insertion(+), 1 deletion(-)
> 
> diff --git a/mingw-w64-headers/crt/uchar.h
> b/mingw-w64-headers/crt/uchar.h index 475ad87..ab8a26d 100644 ---
> a/mingw-w64-headers/crt/uchar.h +++
> b/mingw-w64-headers/crt/uchar.h @@ -30,7 +30,7 @@ /* Remember that
> g++ >= 4.4 defines these types only in c++0x mode */ #if
> !(defined(__cplusplus) && defined(__GXX_EXPERIMENTAL_CXX0X__)) ||
> \ !defined(__GNUC__) ||\ -(__GNUC__ < 4
> || (__GNUC__ == 4 && __GNUC_MINOR__ < 4)) +(!defined(__clang__)
> && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 4))) typedef
> uint_least16_t char16_t; typedef uint_least32_t char32_t; #endif 
> -- 2.9.1
> 

Patch looks OK.


-BEGIN PGP SIGNATURE-

iF4EAREIAAYFAlfr01kACgkQk721PNTrx0D/oAD7BQAqa+mfswOGE5VF+tqOBGhA
fwdzqx9Ame+pT4PjC7sBAIUFQvSfIuffAkLVe6vUZVzzmae4JzzZ+CkyfUT/ZuTp
=j/Ue
-END PGP SIGNATURE-
--
___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] [PATCH] fix uchar.h for Clang

2016-09-28 Thread Mateusz
Looks attachment didn't work.
Here is the patch:

>From e98ec7a116256108831f035eb0a7f0f2fdf049e9 Mon Sep 17 00:00:00 2001
From: mati865 
Date: Wed, 28 Sep 2016 11:45:40 +0200
Subject: [PATCH] fix uchar.h for Clang

Clang defines itself as GCC 4.2.1 and triggers check for GCC lower than
4.4.0.
This patch adds additional !defined(__clang__) check
---
 mingw-w64-headers/crt/uchar.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mingw-w64-headers/crt/uchar.h b/mingw-w64-headers/crt/uchar.h
index 475ad87..ab8a26d 100644
--- a/mingw-w64-headers/crt/uchar.h
+++ b/mingw-w64-headers/crt/uchar.h
@@ -30,7 +30,7 @@
 /* Remember that g++ >= 4.4 defines these types only in c++0x mode */
 #if !(defined(__cplusplus) && defined(__GXX_EXPERIMENTAL_CXX0X__)) ||\
 !defined(__GNUC__) ||\
-(__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 4))
+(!defined(__clang__) && (__GNUC__ < 4 || (__GNUC__ == 4 &&
__GNUC_MINOR__ < 4)))
 typedef uint_least16_t char16_t;
 typedef uint_least32_t char32_t;
 #endif
--
2.9.1


2016-09-28 11:59 GMT+02:00 Mateusz :

> Fixed patch so it don't remove newline at the end of file.
>
> 2016-09-28 11:54 GMT+02:00 Mateusz :
>
>> Fixes this error when compiling with clang:
>> "D:\projekty\msys2\clang\msys64\mingw32\i686-w64-mingw32\include\uchar.h:34:24:
>> e   rror: cannot combine with previous 'type-name' declaration specifier
>> typedef uint_least16_t char16_t;
>>^
>> D:\projekty\msys2\clang\msys64\mingw32\i686-w64-mingw32\include\uchar.h:35:24:
>> e   rror: cannot combine with previous 'type-name' declaration specifier
>> typedef uint_least32_t char32_t;
>>^
>> 2 errors generated.
>> "
>>
>> From e98ec7a116256108831f035eb0a7f0f2fdf049e9 Mon Sep 17 00:00:00 2001
>> From: mati865 
>> Date: Wed, 28 Sep 2016 11:45:40 +0200
>> Subject: [PATCH] fix uchar.h for Clang
>>
>> Clang defines itself as GCC 4.2.1 and triggers check for GCC lower than
>> 4.4.0.\
>> This patch adds additional !defined(__clang__) check
>> ---
>>  mingw-w64-headers/crt/uchar.h | 3 +--
>>  1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/mingw-w64-headers/crt/uchar.h b/mingw-w64-headers/crt/uchar.
>> h
>> index 475ad87..ab8a26d 100644
>> --- a/mingw-w64-headers/crt/uchar.h
>> +++ b/mingw-w64-headers/crt/uchar.h
>> @@ -30,7 +30,7 @@
>>  /* Remember that g++ >= 4.4 defines these types only in c++0x mode */
>>  #if !(defined(__cplusplus) && defined(__GXX_EXPERIMENTAL_CXX0X__))
>> ||\
>>  !defined(__GNUC__) ||\
>> -(__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 4))
>> +(!defined(__clang__) && (__GNUC__ < 4 || (__GNUC__ == 4 &&
>> __GNUC_MINOR__ < 4)))
>>  typedef uint_least16_t char16_t;
>>  typedef uint_least32_t char32_t;
>>  #endif
>> @@ -70,4 +70,3 @@ size_t c32rtomb (char *__restrict__ s,
>>  #endif
>>
>>  #endif /* __UCHAR_H */
>> -
>> --
>> 2.9.1
>>
>
>
--
___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] [PATCH] fix uchar.h for Clang

2016-09-28 Thread Mateusz
Fixed patch so it don't remove newline at the end of file.

2016-09-28 11:54 GMT+02:00 Mateusz :

> Fixes this error when compiling with clang:
> "D:\projekty\msys2\clang\msys64\mingw32\i686-w64-mingw32\include\uchar.h:34:24:
> e   rror: cannot combine with previous 'type-name' declaration specifier
> typedef uint_least16_t char16_t;
>^
> D:\projekty\msys2\clang\msys64\mingw32\i686-w64-mingw32\include\uchar.h:35:24:
> e   rror: cannot combine with previous 'type-name' declaration specifier
> typedef uint_least32_t char32_t;
>^
> 2 errors generated.
> "
>
> From e98ec7a116256108831f035eb0a7f0f2fdf049e9 Mon Sep 17 00:00:00 2001
> From: mati865 
> Date: Wed, 28 Sep 2016 11:45:40 +0200
> Subject: [PATCH] fix uchar.h for Clang
>
> Clang defines itself as GCC 4.2.1 and triggers check for GCC lower than
> 4.4.0.\
> This patch adds additional !defined(__clang__) check
> ---
>  mingw-w64-headers/crt/uchar.h | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/mingw-w64-headers/crt/uchar.h b/mingw-w64-headers/crt/uchar.h
> index 475ad87..ab8a26d 100644
> --- a/mingw-w64-headers/crt/uchar.h
> +++ b/mingw-w64-headers/crt/uchar.h
> @@ -30,7 +30,7 @@
>  /* Remember that g++ >= 4.4 defines these types only in c++0x mode */
>  #if !(defined(__cplusplus) && defined(__GXX_EXPERIMENTAL_CXX0X__)) ||
> \
>  !defined(__GNUC__) ||\
> -(__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 4))
> +(!defined(__clang__) && (__GNUC__ < 4 || (__GNUC__ == 4 &&
> __GNUC_MINOR__ < 4)))
>  typedef uint_least16_t char16_t;
>  typedef uint_least32_t char32_t;
>  #endif
> @@ -70,4 +70,3 @@ size_t c32rtomb (char *__restrict__ s,
>  #endif
>
>  #endif /* __UCHAR_H */
> -
> --
> 2.9.1
>
--
___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


[Mingw-w64-public] [PATCH] fix uchar.h for Clang

2016-09-28 Thread Mateusz
Fixes this error when compiling with clang:
"D:\projekty\msys2\clang\msys64\mingw32\i686-w64-mingw32\include\uchar.h:34:24:
e   rror: cannot combine with previous 'type-name' declaration specifier
typedef uint_least16_t char16_t;
   ^
D:\projekty\msys2\clang\msys64\mingw32\i686-w64-mingw32\include\uchar.h:35:24:
e   rror: cannot combine with previous 'type-name' declaration specifier
typedef uint_least32_t char32_t;
   ^
2 errors generated.
"

>From e98ec7a116256108831f035eb0a7f0f2fdf049e9 Mon Sep 17 00:00:00 2001
From: mati865 
Date: Wed, 28 Sep 2016 11:45:40 +0200
Subject: [PATCH] fix uchar.h for Clang

Clang defines itself as GCC 4.2.1 and triggers check for GCC lower than
4.4.0.\
This patch adds additional !defined(__clang__) check
---
 mingw-w64-headers/crt/uchar.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/mingw-w64-headers/crt/uchar.h b/mingw-w64-headers/crt/uchar.h
index 475ad87..ab8a26d 100644
--- a/mingw-w64-headers/crt/uchar.h
+++ b/mingw-w64-headers/crt/uchar.h
@@ -30,7 +30,7 @@
 /* Remember that g++ >= 4.4 defines these types only in c++0x mode */
 #if !(defined(__cplusplus) && defined(__GXX_EXPERIMENTAL_CXX0X__)) ||\
 !defined(__GNUC__) ||\
-(__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 4))
+(!defined(__clang__) && (__GNUC__ < 4 || (__GNUC__ == 4 &&
__GNUC_MINOR__ < 4)))
 typedef uint_least16_t char16_t;
 typedef uint_least32_t char32_t;
 #endif
@@ -70,4 +70,3 @@ size_t c32rtomb (char *__restrict__ s,
 #endif

 #endif /* __UCHAR_H */
-
-- 
2.9.1
--
___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public