[Mingw-w64-public] As obvious?

2016-08-18 Thread David Wohlferd
Most people could probably check this patch in "as obvious."  But I 
don't really speak script, so someone better check.


BTW, don't bother trying to build --enable-warnings=4 (or higher).  Even 
with this patch, it's not going to build (not even close).


dw
diff --git a/mingw-w64-crt/configure b/mingw-w64-crt/configure
index 77d0766..af2f7ca 100755
--- a/mingw-w64-crt/configure
+++ b/mingw-w64-crt/configure
@@ -6129,13 +6129,14 @@ case $warning_level in #(
   4) :
 
 ADD_C_CXX_WARNING_FLAGS="-Wall -Wextra -Wformat -Wstrict-aliasing=2 -Wsystem-headers -Wshadow -Wmissing-declarations -Wpacked -Winline -Werror -pedantic"
-ADD_C_ONLY_WARNING_FLAGS="-Wimplicit-function-declaration -Wmissing-noreturn -Wmissing-prototypes"
-  5 ;; #(
-  *) :
+ADD_C_ONLY_WARNING_FLAGS="-Wimplicit-function-declaration -Wmissing-noreturn -Wmissing-prototypes" ;; #(
+  5) :
 
 ADD_C_CXX_WARNING_FLAGS="-Wall -Wextra -Wformat -Wstrict-aliasing=2 -Wsystem-headers -Wshadow -Wmissing-declarations -Wpacked -Wredundant-decls -Winline -Werror -Wfatal-errors -pedantic -pedantic-errors"
 ADD_C_ONLY_WARNING_FLAGS="-Wimplicit-function-declaration -Wmissing-noreturn -Wmissing-prototypes"
-;;
+;; #(
+  *) :
+ ;;
 esac
 
 
diff --git a/mingw-w64-crt/configure.ac b/mingw-w64-crt/configure.ac
index b088953..884a7ae 100644
--- a/mingw-w64-crt/configure.ac
+++ b/mingw-w64-crt/configure.ac
@@ -314,7 +314,7 @@ AS_CASE([$warning_level],
 ADD_C_ONLY_WARNING_FLAGS="-Wimplicit-function-declaration -Wmissing-noreturn -Wmissing-prototypes"],
   [4],[
 ADD_C_CXX_WARNING_FLAGS="-Wall -Wextra -Wformat -Wstrict-aliasing=2 -Wsystem-headers -Wshadow -Wmissing-declarations -Wpacked -Winline -Werror -pedantic" 
-ADD_C_ONLY_WARNING_FLAGS="-Wimplicit-function-declaration -Wmissing-noreturn -Wmissing-prototypes"]
+ADD_C_ONLY_WARNING_FLAGS="-Wimplicit-function-declaration -Wmissing-noreturn -Wmissing-prototypes"],
   [5],[
 ADD_C_CXX_WARNING_FLAGS="-Wall -Wextra -Wformat -Wstrict-aliasing=2 -Wsystem-headers -Wshadow -Wmissing-declarations -Wpacked -Wredundant-decls -Winline -Werror -Wfatal-errors -pedantic -pedantic-errors" 
 ADD_C_ONLY_WARNING_FLAGS="-Wimplicit-function-declaration -Wmissing-noreturn -Wmissing-prototypes"]
--
___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] Clean build of mingw-w64 (ie no more warning)

2016-08-18 Thread David Wohlferd

It's late, so just 3 quick new ones tonight:


Ok, kai signed off on these too.

So, next are the IDL files.  I (mistakenly) tried to regenerate my 
changes by just running widl against the appropriate idl file. 
Apparently the correct way is to use --with-widl on the configure line.


So I did that.  And it turned up a couple of (new) problems:

1) When building windows.foundation.idl, I get:

/mingw64/bin/widl -DBOOL=WINBOOL 
-I/c/cygwin64/src/Mingw-w64d/mingw-w64-headers/include 
-I/c/cygwin64/src/Mingw-w64d/mingw-w64-headers/direct-x/include -Icrt 
-I/c/cygwin64/src/Mingw-w64d/mingw-w64-headers/crt -h -o 
/c/cygwin64/src/Mingw-w64d/mingw-w64-headers/include/windows.foundation.h 
/c/cygwin64/src/Mingw-w64d/mingw-w64-headers/include/windows.foundation.idl
C:/cygwin64/src/Mingw-w64d/mingw-w64-headers/include/windows.foundation.idl:14: 
error: syntax error, unexpected aIDENTIFIER, expecting $end


I don't see anything particularly interesting about line 14, but 
removing the "#pragma winrt ns_prefix" allowed the build to continue.


2) The build is overwriting prsht.h with the output from prsht.idl. 
However the new prsht.h is very different.  Either prsht.idl needs a lot 
of additions, or the build needs to stop building prsht.h from the idl.


I have not attempted to fix either of these issues, since there is 
probably some history here.


What I have attempted to fix, are these (attached):

mftransform.patch - EXTERN_C is either defined as 'extern' or 'extern 
"C"'. However, this isn't really an extern (implying that the actual 
definition is elsewhere), since the code also initializes the variable. 
And we don't need 'extern "C"' since this entire section is already 
wrapped with one (part of idl generation). Using both 'extern' and 
initializing generates a warning (warning: 
'MFT_ENUM_TRANSCODE_ONLY_ATTRIBUTE' initialized and declared 'extern').


strmif.patch - There are explicit #warning statements in strmif.idl (and 
thus strmif.h) that are not conditional (ie you always get them).  I'm 
guessing this is because the code around it was manually generated 
instead of letting widl generate it from an interface definition.  I 
have removed the manual code from strmif.idl and added the interface 
definition to axextend.idl (where it seems to belong).  Reviewing this 
patch is easier if you remember that strmif.h is a generated file.


dw
diff --git a/mingw-w64-headers/include/mftransform.h b/mingw-w64-headers/include/mftransform.h
index 1663d74..4738b4a 100644
--- a/mingw-w64-headers/include/mftransform.h
+++ b/mingw-w64-headers/include/mftransform.h
@@ -701,6 +701,11 @@ void __RPC_STUB IMFTransform_ProcessMessage_Stub(
 
 #endif  /* __IMFTransform_INTERFACE_DEFINED__ */
 
+#ifdef __GNUC__
+#undef EXTERN_C
+#define EXTERN_C
+#endif
+
 EXTERN_C const DECLSPEC_SELECTANY PROPERTYKEY MFPKEY_CLSID = {{0xc57a84c0,0x1a80,0x40a3,{0x97,0xb5,0x92,0x72,0xa4,0x3,0xc8,0xae}}, 0x01};
 EXTERN_C const DECLSPEC_SELECTANY PROPERTYKEY MFPKEY_CATEGORY = {{0xc57a84c0,0x1a80,0x40a3,{0x97,0xb5,0x92,0x72,0xa4,0x3,0xc8,0xae}}, 0x02 };
 EXTERN_C const DECLSPEC_SELECTANY PROPERTYKEY MFPKEY_EXATTRIBUTE_SUPPORTED = {{0x456fe843,0x3c87,0x40c0,{0x94,0x9d,0x14,0x9,0xc9,0x7d,0xab,0x2c}}, 0x01};
diff --git a/mingw-w64-headers/include/mftransform.idl b/mingw-w64-headers/include/mftransform.idl
index 9b91736..11d5988 100644
--- a/mingw-w64-headers/include/mftransform.idl
+++ b/mingw-w64-headers/include/mftransform.idl
@@ -143,6 +143,14 @@ interface IMFTransform : IUnknown
   [out] DWORD *pdwStatus);
 }
 
+/* In gcc, declaring something 'extern' and then initializing it
+   generates a warning.  */
+cpp_quote("#ifdef __GNUC__")
+cpp_quote("#undef EXTERN_C")
+cpp_quote("#define EXTERN_C")
+cpp_quote("#endif")
+cpp_quote("")
+
 cpp_quote("EXTERN_C const DECLSPEC_SELECTANY PROPERTYKEY MFPKEY_CLSID = {{0xc57a84c0,0x1a80,0x40a3,{0x97,0xb5,0x92,0x72,0xa4,0x3,0xc8,0xae}}, 0x01};")
 cpp_quote("EXTERN_C const DECLSPEC_SELECTANY PROPERTYKEY MFPKEY_CATEGORY = {{0xc57a84c0,0x1a80,0x40a3,{0x97,0xb5,0x92,0x72,0xa4,0x3,0xc8,0xae}}, 0x02 };")
 cpp_quote("EXTERN_C const DECLSPEC_SELECTANY PROPERTYKEY MFPKEY_EXATTRIBUTE_SUPPORTED = {{0x456fe843,0x3c87,0x40c0,{0x94,0x9d,0x14,0x9,0xc9,0x7d,0xab,0x2c}}, 0x01};")
diff --git a/mingw-w64-headers/include/axextend.idl b/mingw-w64-headers/include/axextend.idl
index 754ca22..79e8369 100644
--- a/mingw-w64-headers/include/axextend.idl
+++ b/mingw-w64-headers/include/axextend.idl
@@ -1292,3 +1292,49 @@ interface IAMVfwCaptureDialogs : IUnknown
 [in] long data1,
 [in] long data2);
 };
+
+cpp_quote("#if (_WIN32_WINNT >= 0x0601)")
+[
+local,
+object,
+uuid(cf7b26fc-9a00-485b-8147-3e789d5e8f67),
+pointer_default(unique)
+]
+interface IAMAsyncReaderTimestampScaling : IUnknown
+{
+HRESULT GetTimestampMode(
+[out] BOOL *pfRaw);
+HRESULT SetTimestampMode(
+[in] BOOL fRaw);
+};
+
+[
+local,
+object,
+

[Mingw-w64-public] [PATCH] math: Fix rounding in llrint(f) on ARM

2016-08-18 Thread Martin Storsjö
---
Updated to check with fegetround to see which rounding mode to use,
fixed the way the mode is checked (by using == instead of &).
---
 mingw-w64-crt/math/llrint.c  | 11 ++-
 mingw-w64-crt/math/llrintf.c | 11 ++-
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/mingw-w64-crt/math/llrint.c b/mingw-w64-crt/math/llrint.c
index 1fc11e8..8b138c0 100644
--- a/mingw-w64-crt/math/llrint.c
+++ b/mingw-w64-crt/math/llrint.c
@@ -4,6 +4,7 @@
  * No warranty is given; refer to the file DISCLAIMER.PD within this package.
  */
 #include 
+#include 
 
 long long llrint (double x) 
 {
@@ -11,7 +12,15 @@ long long llrint (double x)
 #if defined(_AMD64_) || defined(__x86_64__) || defined(_X86_) || 
defined(__i386__)
   __asm__ __volatile__ ("fistpll %0"  : "=m" (retval) : "t" (x) : "st");
 #else
-  retval = (long long)x;
+  int mode = fegetround();
+  if (mode == FE_DOWNWARD)
+retval = (long long)floor(x);
+  else if (mode == FE_UPWARD)
+retval = (long long)ceil(x);
+  else if (mode == FE_TOWARDZERO)
+retval = x >= 0 ? (long long)floor(x) : (long long)ceil(x);
+  else
+retval = x >= 0 ? (long long)floor(x + 0.5) : (long long)ceil(x - 0.5);
 #endif
   return retval;
 }
diff --git a/mingw-w64-crt/math/llrintf.c b/mingw-w64-crt/math/llrintf.c
index aabd81f..1b2a422 100644
--- a/mingw-w64-crt/math/llrintf.c
+++ b/mingw-w64-crt/math/llrintf.c
@@ -4,6 +4,7 @@
  * No warranty is given; refer to the file DISCLAIMER.PD within this package.
  */
 #include 
+#include 
 
 long long llrintf (float x) 
 {
@@ -11,7 +12,15 @@ long long llrintf (float x)
 #if defined(_AMD64_) || defined(__x86_64__) || defined(_X86_) || 
defined(__i386__)
   __asm__ __volatile__ ("fistpll %0"  : "=m" (retval) : "t" (x) : "st");
 #else
-  retval = (long long)x;
+  int mode = fegetround();
+  if (mode == FE_DOWNWARD)
+retval = (long long)floorf(x);
+  else if (mode == FE_UPWARD)
+retval = (long long)ceilf(x);
+  else if (mode == FE_TOWARDZERO)
+retval = x >= 0 ? (long long)floorf(x) : (long long)ceilf(x);
+  else
+retval = x >= 0 ? (long long)floorf(x + 0.5) : (long long)ceilf(x - 0.5);
 #endif
   return retval;
 }
-- 
2.7.4


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


Re: [Mingw-w64-public] Clean build of mingw-w64 (ie no more warning)

2016-08-18 Thread David Wohlferd
On 8/18/2016 4:23 AM, Martell Malone wrote:
> I would also like to point you to my selectany patch.
> You asked why that wasn't supported on clang on irc.
> https://github.com/martell/mingw-w64-clang/blob/master/patches/clang/0003-mingw-w64-enable-support-for-__declspec-selectany.patch
> This should be better then using -fms-{extensions,compat}

Excellent.  Thank you for this.

dw

--
___
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] math: Fix rounding in llrint(f) on ARM

2016-08-18 Thread Martin Storsjö

On Thu, 18 Aug 2016, Martin Storsjö wrote:


---
Updated to check with fegetround to see which rounding mode to use.
---
mingw-w64-crt/math/llrint.c  | 11 ++-
mingw-w64-crt/math/llrintf.c | 11 ++-
2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/mingw-w64-crt/math/llrint.c b/mingw-w64-crt/math/llrint.c
index 1fc11e8..80014b0 100644
--- a/mingw-w64-crt/math/llrint.c
+++ b/mingw-w64-crt/math/llrint.c
@@ -4,6 +4,7 @@
 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
 */
#include 
+#include 

long long llrint (double x)
{
@@ -11,7 +12,15 @@ long long llrint (double x)
#if defined(_AMD64_) || defined(__x86_64__) || defined(_X86_) || 
defined(__i386__)
  __asm__ __volatile__ ("fistpll %0"  : "=m" (retval) : "t" (x) : "st");
#else
-  retval = (long long)x;
+  int mode = fegetround();
+  if (mode & FE_DOWNWARD)
+retval = (long long)floor(x);
+  else if (mode & FE_UPWARD)
+retval = (long long)ceil(x);
+  else if (mode & FE_TOWARDZERO)
+retval = x >= 0 ? (long long)floor(x) : (long long)ceil(x);
+  else
+retval = x >= 0 ? (long long)floor(x + 0.5) : (long long)ceil(x - 0.5);
#endif
  return retval;
}


Ok, the mode mask flags checks has to be revised a little, since 
FE_TOWARDZERO == FE_UPWARD | FE_DOWNWARD here. I'll return with a newer 
patch in a little while.


// 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] math: Fix rounding in llrint(f) on ARM

2016-08-18 Thread Martin Storsjö
---
Updated to check with fegetround to see which rounding mode to use.
---
 mingw-w64-crt/math/llrint.c  | 11 ++-
 mingw-w64-crt/math/llrintf.c | 11 ++-
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/mingw-w64-crt/math/llrint.c b/mingw-w64-crt/math/llrint.c
index 1fc11e8..80014b0 100644
--- a/mingw-w64-crt/math/llrint.c
+++ b/mingw-w64-crt/math/llrint.c
@@ -4,6 +4,7 @@
  * No warranty is given; refer to the file DISCLAIMER.PD within this package.
  */
 #include 
+#include 
 
 long long llrint (double x) 
 {
@@ -11,7 +12,15 @@ long long llrint (double x)
 #if defined(_AMD64_) || defined(__x86_64__) || defined(_X86_) || 
defined(__i386__)
   __asm__ __volatile__ ("fistpll %0"  : "=m" (retval) : "t" (x) : "st");
 #else
-  retval = (long long)x;
+  int mode = fegetround();
+  if (mode & FE_DOWNWARD)
+retval = (long long)floor(x);
+  else if (mode & FE_UPWARD)
+retval = (long long)ceil(x);
+  else if (mode & FE_TOWARDZERO)
+retval = x >= 0 ? (long long)floor(x) : (long long)ceil(x);
+  else
+retval = x >= 0 ? (long long)floor(x + 0.5) : (long long)ceil(x - 0.5);
 #endif
   return retval;
 }
diff --git a/mingw-w64-crt/math/llrintf.c b/mingw-w64-crt/math/llrintf.c
index aabd81f..805823e 100644
--- a/mingw-w64-crt/math/llrintf.c
+++ b/mingw-w64-crt/math/llrintf.c
@@ -4,6 +4,7 @@
  * No warranty is given; refer to the file DISCLAIMER.PD within this package.
  */
 #include 
+#include 
 
 long long llrintf (float x) 
 {
@@ -11,7 +12,15 @@ long long llrintf (float x)
 #if defined(_AMD64_) || defined(__x86_64__) || defined(_X86_) || 
defined(__i386__)
   __asm__ __volatile__ ("fistpll %0"  : "=m" (retval) : "t" (x) : "st");
 #else
-  retval = (long long)x;
+  int mode = fegetround();
+  if (mode & FE_DOWNWARD)
+retval = (long long)floorf(x);
+  else if (mode & FE_UPWARD)
+retval = (long long)ceilf(x);
+  else if (mode & FE_TOWARDZERO)
+retval = x >= 0 ? (long long)floorf(x) : (long long)ceilf(x);
+  else
+retval = x >= 0 ? (long long)floorf(x + 0.5) : (long long)ceilf(x - 0.5);
 #endif
   return retval;
 }
-- 
2.7.4


--
___
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] math: Fix rounding in llrint(f) on ARM

2016-08-18 Thread Martin Storsjö

On Thu, 18 Aug 2016, Martin Storsjö wrote:


On Thu, 18 Aug 2016, Kai Tietz wrote:


Hello Martin,

2016-08-18 15:31 GMT+02:00 Martin Storsjö :

---
The (l)rint(f) functions call an inline assembly snippet to
do the rounding - that does seem to round in the right way, but I'm
not sure if that relies on the fpscr being set in the right mode?
---
 mingw-w64-crt/math/llrint.c  | 2 +-
 mingw-w64-crt/math/llrintf.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/mingw-w64-crt/math/llrint.c b/mingw-w64-crt/math/llrint.c
index 1fc11e8..d52fd15 100644
--- a/mingw-w64-crt/math/llrint.c
+++ b/mingw-w64-crt/math/llrint.c
@@ -11,7 +11,7 @@ long long llrint (double x)
 #if defined(_AMD64_) || defined(__x86_64__) || defined(_X86_) || 
defined(__i386__)

   __asm__ __volatile__ ("fistpll %0"  : "=m" (retval) : "t" (x) : "st");
 #else
-  retval = (long long)x;
+  retval = x >= 0 ? (long long)floor(x + 0.5) : (long long)ceil(x - 0.5);
 #endif
   return retval;
 }
diff --git a/mingw-w64-crt/math/llrintf.c b/mingw-w64-crt/math/llrintf.c
index aabd81f..cb2b668 100644
--- a/mingw-w64-crt/math/llrintf.c
+++ b/mingw-w64-crt/math/llrintf.c
@@ -11,7 +11,7 @@ long long llrintf (float x)
 #if defined(_AMD64_) || defined(__x86_64__) || defined(_X86_) || 
defined(__i386__)

   __asm__ __volatile__ ("fistpll %0"  : "=m" (retval) : "t" (x) : "st");
 #else
-  retval = (long long)x;
+  retval = x >= 0 ? (long long)floorf(x + 0.5) : (long long)ceilf(x - 
0.5);

 #endif
   return retval;
 }
--
2.7.4


There is no other way to have here rounding, right? If so patch is ok.


Hmm, well strictly, it should probably follow what fesetround is set to.

I'll see if I can change it to use an inline assembly snippet, that relies on 
the floating point status register, instead of hardcording the rounding like 
this.


... and that turned out to be harder than I just thought, since there's no 
simple instruction for converting floats/doubles to 64 bit integers. 
(That's why clang calls support routines like __dtoi64 for this.)


So I guess we should either use fegetround to check the current mode and 
invoke different variants of floor/ceil with different offsets based on 
that, or try to include a reimplementation of something like __dtoi64 for 
this. I'd be more inclined to the former, here...


// 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] math: Fix rounding in llrint(f) on ARM

2016-08-18 Thread Martin Storsjö

On Thu, 18 Aug 2016, Kai Tietz wrote:


Hello Martin,

2016-08-18 15:31 GMT+02:00 Martin Storsjö :

---
The (l)rint(f) functions call an inline assembly snippet to
do the rounding - that does seem to round in the right way, but I'm
not sure if that relies on the fpscr being set in the right mode?
---
 mingw-w64-crt/math/llrint.c  | 2 +-
 mingw-w64-crt/math/llrintf.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/mingw-w64-crt/math/llrint.c b/mingw-w64-crt/math/llrint.c
index 1fc11e8..d52fd15 100644
--- a/mingw-w64-crt/math/llrint.c
+++ b/mingw-w64-crt/math/llrint.c
@@ -11,7 +11,7 @@ long long llrint (double x)
 #if defined(_AMD64_) || defined(__x86_64__) || defined(_X86_) || 
defined(__i386__)
   __asm__ __volatile__ ("fistpll %0"  : "=m" (retval) : "t" (x) : "st");
 #else
-  retval = (long long)x;
+  retval = x >= 0 ? (long long)floor(x + 0.5) : (long long)ceil(x - 0.5);
 #endif
   return retval;
 }
diff --git a/mingw-w64-crt/math/llrintf.c b/mingw-w64-crt/math/llrintf.c
index aabd81f..cb2b668 100644
--- a/mingw-w64-crt/math/llrintf.c
+++ b/mingw-w64-crt/math/llrintf.c
@@ -11,7 +11,7 @@ long long llrintf (float x)
 #if defined(_AMD64_) || defined(__x86_64__) || defined(_X86_) || 
defined(__i386__)
   __asm__ __volatile__ ("fistpll %0"  : "=m" (retval) : "t" (x) : "st");
 #else
-  retval = (long long)x;
+  retval = x >= 0 ? (long long)floorf(x + 0.5) : (long long)ceilf(x - 0.5);
 #endif
   return retval;
 }
--
2.7.4


There is no other way to have here rounding, right? If so patch is ok.


Hmm, well strictly, it should probably follow what fesetround is set to.

I'll see if I can change it to use an inline assembly snippet, that relies 
on the floating point status register, instead of hardcording the rounding 
like this.


// 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] math: Fix rounding in llrint(f) on ARM

2016-08-18 Thread Kai Tietz
Hello Martin,

2016-08-18 15:31 GMT+02:00 Martin Storsjö :
> ---
> The (l)rint(f) functions call an inline assembly snippet to
> do the rounding - that does seem to round in the right way, but I'm
> not sure if that relies on the fpscr being set in the right mode?
> ---
>  mingw-w64-crt/math/llrint.c  | 2 +-
>  mingw-w64-crt/math/llrintf.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/mingw-w64-crt/math/llrint.c b/mingw-w64-crt/math/llrint.c
> index 1fc11e8..d52fd15 100644
> --- a/mingw-w64-crt/math/llrint.c
> +++ b/mingw-w64-crt/math/llrint.c
> @@ -11,7 +11,7 @@ long long llrint (double x)
>  #if defined(_AMD64_) || defined(__x86_64__) || defined(_X86_) || 
> defined(__i386__)
>__asm__ __volatile__ ("fistpll %0"  : "=m" (retval) : "t" (x) : "st");
>  #else
> -  retval = (long long)x;
> +  retval = x >= 0 ? (long long)floor(x + 0.5) : (long long)ceil(x - 0.5);
>  #endif
>return retval;
>  }
> diff --git a/mingw-w64-crt/math/llrintf.c b/mingw-w64-crt/math/llrintf.c
> index aabd81f..cb2b668 100644
> --- a/mingw-w64-crt/math/llrintf.c
> +++ b/mingw-w64-crt/math/llrintf.c
> @@ -11,7 +11,7 @@ long long llrintf (float x)
>  #if defined(_AMD64_) || defined(__x86_64__) || defined(_X86_) || 
> defined(__i386__)
>__asm__ __volatile__ ("fistpll %0"  : "=m" (retval) : "t" (x) : "st");
>  #else
> -  retval = (long long)x;
> +  retval = x >= 0 ? (long long)floorf(x + 0.5) : (long long)ceilf(x - 0.5);
>  #endif
>return retval;
>  }
> --
> 2.7.4

There is no other way to have here rounding, right? If so patch is ok.

Kai

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


[Mingw-w64-public] [PATCH] math: Fix rounding in llrint(f) on ARM

2016-08-18 Thread Martin Storsjö
---
The (l)rint(f) functions call an inline assembly snippet to
do the rounding - that does seem to round in the right way, but I'm
not sure if that relies on the fpscr being set in the right mode?
---
 mingw-w64-crt/math/llrint.c  | 2 +-
 mingw-w64-crt/math/llrintf.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/mingw-w64-crt/math/llrint.c b/mingw-w64-crt/math/llrint.c
index 1fc11e8..d52fd15 100644
--- a/mingw-w64-crt/math/llrint.c
+++ b/mingw-w64-crt/math/llrint.c
@@ -11,7 +11,7 @@ long long llrint (double x)
 #if defined(_AMD64_) || defined(__x86_64__) || defined(_X86_) || 
defined(__i386__)
   __asm__ __volatile__ ("fistpll %0"  : "=m" (retval) : "t" (x) : "st");
 #else
-  retval = (long long)x;
+  retval = x >= 0 ? (long long)floor(x + 0.5) : (long long)ceil(x - 0.5);
 #endif
   return retval;
 }
diff --git a/mingw-w64-crt/math/llrintf.c b/mingw-w64-crt/math/llrintf.c
index aabd81f..cb2b668 100644
--- a/mingw-w64-crt/math/llrintf.c
+++ b/mingw-w64-crt/math/llrintf.c
@@ -11,7 +11,7 @@ long long llrintf (float x)
 #if defined(_AMD64_) || defined(__x86_64__) || defined(_X86_) || 
defined(__i386__)
   __asm__ __volatile__ ("fistpll %0"  : "=m" (retval) : "t" (x) : "st");
 #else
-  retval = (long long)x;
+  retval = x >= 0 ? (long long)floorf(x + 0.5) : (long long)ceilf(x - 0.5);
 #endif
   return retval;
 }
-- 
2.7.4


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


[Mingw-w64-public] [PATCH] math: Make sure NAN/INF is preserved in floor/ceil functions on ARM

2016-08-18 Thread Martin Storsjö
---
The indentation probably looks wonky in ths patch, but I'm trying
to match the style of the rest of the arm assembly below, which
uses tabs, equal to 4 spaces.

This probably also should be done to a lot of other math functions,
but I only ran into this as an issue with floor, in the libav testsuite.
---
 mingw-w64-crt/math/ceil.S   | 7 +++
 mingw-w64-crt/math/ceilf.S  | 6 ++
 mingw-w64-crt/math/ceill.S  | 7 +++
 mingw-w64-crt/math/floor.S  | 7 +++
 mingw-w64-crt/math/floorf.S | 6 ++
 mingw-w64-crt/math/floorl.S | 7 +++
 6 files changed, 40 insertions(+)

diff --git a/mingw-w64-crt/math/ceil.S b/mingw-w64-crt/math/ceil.S
index 2ce21dd..bb8a6e9 100644
--- a/mingw-w64-crt/math/ceil.S
+++ b/mingw-w64-crt/math/ceil.S
@@ -92,6 +92,12 @@ __MINGW_USYMBOL(ceil):
.long   0
.long   0
 #elif defined(_ARM_) || defined(__arm__)
+   vmovr2, r3, d0
+   lsr r3, r3, #20
+   bic r3, r3, #0x800
+   movwr2, #0x7ff
+   cmp r2, r3 /* Check for INF/NAN, just return the input in 
those cases */
+   beq 2f
vmrsr1, fpscr
bic r0, r1, #0x00c0
orr r0, r0, #0x0040 /* Round towards Plus Infinity */
@@ -99,6 +105,7 @@ __MINGW_USYMBOL(ceil):
vcvtr.s32.f64   s0, d0
vcvt.f64.s32d0, s0
vmsrfpscr, r1
+2:
bx  lr
 #elif defined(_X86_) || defined(__i386__)
fldl4(%esp)
diff --git a/mingw-w64-crt/math/ceilf.S b/mingw-w64-crt/math/ceilf.S
index c1202e0..def516e 100644
--- a/mingw-w64-crt/math/ceilf.S
+++ b/mingw-w64-crt/math/ceilf.S
@@ -88,6 +88,11 @@ __MINGW_USYMBOL(ceilf):
 .zeroval:
 .long   0
 #elif defined(_ARM_) || defined(__arm__)
+   vmovr2, s0
+   lsr r2, r2, #23
+   bic r2, r2, #0x100
+   cmp r2, #0xff /* Check for INF/NAN, just return the input 
in those cases */
+   beq 2f
vmrsr1, fpscr
bic r0, r1, #0x00c0
orr r0, r0, #0x0040 /* Round towards Plus Infinity */
@@ -95,6 +100,7 @@ __MINGW_USYMBOL(ceilf):
vcvt.s32.f32s0, s0
vcvt.f32.s32s0, s0
vmsrfpscr, r1
+2:
bx  lr
 #elif defined(_X86_) || defined(__i386__)
flds4(%esp)
diff --git a/mingw-w64-crt/math/ceill.S b/mingw-w64-crt/math/ceill.S
index 9804004..39c5875 100644
--- a/mingw-w64-crt/math/ceill.S
+++ b/mingw-w64-crt/math/ceill.S
@@ -40,6 +40,12 @@ __MINGW_USYMBOL(ceill):
fstpt   (%rcx)
ret
 #elif defined(_ARM_) || defined(__arm__)
+   vmovr2, r3, d0
+   lsr r3, r3, #20
+   bic r3, r3, #0x800
+   movwr2, #0x7ff
+   cmp r2, r3 /* Check for INF/NAN, just return the input in 
those cases */
+   beq 2f
vmrsr1, fpscr
bic r0, r1, #0x00c0
orr r0, r0, #0x0040 /* Round towards Plus Infinity */
@@ -47,6 +53,7 @@ __MINGW_USYMBOL(ceill):
vcvtr.s32.f64   s0, d0
vcvt.f64.s32d0, s0
vmsrfpscr, r1
+2:
bx  lr
 #elif defined(_X86_) || defined(__i386__)
fldt4(%esp)
diff --git a/mingw-w64-crt/math/floor.S b/mingw-w64-crt/math/floor.S
index 6f4aba1..726590c 100644
--- a/mingw-w64-crt/math/floor.S
+++ b/mingw-w64-crt/math/floor.S
@@ -144,6 +144,12 @@ __MINGW_USYMBOL(floor):
.long   -2013235812
.long   2117592124
 #elif defined(_ARM_) || defined(__arm__)
+   vmovr2, r3, d0
+   lsr r3, r3, #20
+   bic r3, r3, #0x800
+   movwr2, #0x7ff
+   cmp r2, r3 /* Check for INF/NAN, just return the input in 
those cases */
+   beq 2f
vmrsr1, fpscr
bic r0, r1, #0x00c0
orr r0, r0, #0x0080 /* Round towards Minus Infinity */
@@ -151,6 +157,7 @@ __MINGW_USYMBOL(floor):
vcvtr.s32.f64   s0, d0
vcvt.f64.s32d0, s0
vmsrfpscr, r1
+2:
bx  lr
 #elif defined(_X86_) || defined(__i386__)
fldl4(%esp)
diff --git a/mingw-w64-crt/math/floorf.S b/mingw-w64-crt/math/floorf.S
index d1b16ab..94efa2a 100644
--- a/mingw-w64-crt/math/floorf.S
+++ b/mingw-w64-crt/math/floorf.S
@@ -28,6 +28,11 @@ __MINGW_USYMBOL(floorf):
 .seh_endproc
 .def__MINGW_USYMBOL(floor);  .scl2;  .type   32; .endef
 #elif defined(_ARM_) || defined(__arm__)
+   vmovr2, s0
+   lsr r2, r2, #23
+   bic r2, r2, #0x100
+   cmp r2, #0xff /* Check for INF/NAN, just return the input 
in those cases */
+   beq 2f
vmrsr1, fpscr
bic r0, r1, #0x00c0
orr r0, r0, #0x0080 /* Round towards Minus Infinity */
@@ -35,6 +40,7 @@ __MINGW_USYMBOL(floorf):
vcvt.s32.f32s0, s0
 

Re: [Mingw-w64-public] Clean build of mingw-w64 (ie no more warning)

2016-08-18 Thread Martin Storsjö
On Thu, 18 Aug 2016, David Wohlferd wrote:

>
>> I assume I still need to wait for someone else to approve this before I 
>> push? 
>
> Kai signed off on these via IRC.
>
> It's late, so just 3 quick new ones tonight:
>
> e_pow.patch - Signed/unsigned compare
>
> mingw_pformat.patch - Don't use feature (__attribute__((gcc_struct))) that 
> isn't supported on clang when compiling on clang.
>
> mfapi.patch - FCC ('AI44') et al cause 'multichar' compiler warnings. Ignore 
> them.

No objections from me. For mingw_pformat.patch, one could argue that the 
typo fix could go separately, but for a small patch like this it's 
probably fine. Bonus points for mentioning the typofix in the commit 
message though.

// 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] Clean build of mingw-w64 (ie no more warning)

2016-08-18 Thread Martell Malone
I would also like to point you to my selectany patch.
You asked why that wasn't supported on clang on irc.
https://github.com/martell/mingw-w64-clang/blob/master/patches/clang/0003-mingw-w64-enable-support-for-__declspec-selectany.patch
This should be better then using -fms-{extensions,compat}

On Thu, Aug 18, 2016 at 4:21 AM, Martell Malone 
wrote:

> mingw_pformat.patch - Don't use feature (__attribute__((gcc_struct))) that
>> isn't supported on clang when compiling on clang.
>
> I have the very same patch applied locally, can confirm this is a good
> change.
> The typo was a good catch.
>
> On Thu, Aug 18, 2016 at 3:33 AM, David Wohlferd 
> wrote:
>
>>
>> I assume I still need to wait for someone else to approve this before I
>>> push?
>>>
>>
>> Kai signed off on these via IRC.
>>
>> It's late, so just 3 quick new ones tonight:
>>
>> e_pow.patch - Signed/unsigned compare
>>
>> mingw_pformat.patch - Don't use feature (__attribute__((gcc_struct)))
>> that isn't supported on clang when compiling on clang.
>>
>> mfapi.patch - FCC ('AI44') et al cause 'multichar' compiler warnings.
>> Ignore them.
>>
>> We're getting close to done.  Some IDL changes, some configure/makefile
>> changes and that's it.
>>
>> dw
>>
>> 
>> --
>>
>> ___
>> Mingw-w64-public mailing list
>> Mingw-w64-public@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
>>
>>
>
--
___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] Clean build of mingw-w64 (ie no more warning)

2016-08-18 Thread David Wohlferd


I assume I still need to wait for someone else to approve this before 
I push? 


Kai signed off on these via IRC.

It's late, so just 3 quick new ones tonight:

e_pow.patch - Signed/unsigned compare

mingw_pformat.patch - Don't use feature (__attribute__((gcc_struct))) 
that isn't supported on clang when compiling on clang.


mfapi.patch - FCC ('AI44') et al cause 'multichar' compiler warnings. 
Ignore them.


We're getting close to done.  Some IDL changes, some configure/makefile 
changes and that's it.


dw
diff --git a/mingw-w64-crt/math/softmath/e_pow.c b/mingw-w64-crt/math/softmath/e_pow.c
index 4e56eeb..da697db 100644
--- a/mingw-w64-crt/math/softmath/e_pow.c
+++ b/mingw-w64-crt/math/softmath/e_pow.c
@@ -45,7 +45,7 @@ double bsd__ieee754_pow(double x, double y)
 k = (iy>>20)-0x3ff;	/* exponent */
 if(k>20) {
 j = ly>>(52-k);
-if((j<<(52-k))==ly) yisint = 2-(j&1);
+if((u_int32_t)(j<<(52-k))==ly) yisint = 2-(j&1);
 } else if(ly==0) {
 j = iy>>(20-k);
 if((j<<(20-k))==iy) yisint = 2-(j&1);
diff --git a/mingw-w64-crt/stdio/mingw_pformat.c b/mingw-w64-crt/stdio/mingw_pformat.c
index 0438112..445320c 100644
--- a/mingw-w64-crt/stdio/mingw_pformat.c
+++ b/mingw-w64-crt/stdio/mingw_pformat.c
@@ -77,13 +77,13 @@
 
 /* FIXME: The following belongs in values.h, but current MinGW
  * has nothing useful there!  OTOH, values.h is not a standard
- * header, and it's use may be considered obsolete; perhaps it
+ * header, and its use may be considered obsolete; perhaps it
  * is better to just keep these definitions here.
  */
 
 #include 
 /* workaround gcc bug */
-#ifdef __GNUC__
+#if defined(__GNUC__) && !defined(__clang__)
 #define ATTRIB_GCC_STRUCT __attribute__((gcc_struct))
 #else
 #define ATTRIB_GCC_STRUCT
diff --git a/mingw-w64-headers/include/mfapi.h b/mingw-w64-headers/include/mfapi.h
index 67dc684..94404ce 100644
--- a/mingw-w64-headers/include/mfapi.h
+++ b/mingw-w64-headers/include/mfapi.h
@@ -329,6 +329,12 @@ extern "C" {
   DEFINE_MEDIATYPE_GUID (MFVideoFormat_RGB555, D3DFMT_X1R5G5B5);
   DEFINE_MEDIATYPE_GUID (MFVideoFormat_RGB565, D3DFMT_R5G6B5);
   DEFINE_MEDIATYPE_GUID (MFVideoFormat_RGB8, D3DFMT_P8);
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wmultichar"
+#endif
+
   DEFINE_MEDIATYPE_GUID (MFVideoFormat_AI44, FCC ('AI44'));
   DEFINE_MEDIATYPE_GUID (MFVideoFormat_AYUV, FCC ('AYUV'));
   DEFINE_MEDIATYPE_GUID (MFVideoFormat_YUY2, FCC ('YUY2'));
@@ -384,6 +390,10 @@ extern "C" {
   DEFINE_MEDIATYPE_GUID (MFVideoFormat_H263, FCC ('H263'));
 #endif
 
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
+
 #ifdef LOCAL_D3DFMT_DEFINES
 #undef D3DFMT_R8G8B8
 #undef D3DFMT_A8R8G8B8
--
___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public