w32pthreads: Map MemoryBarrier to __sync_synchronize on mingw

Message ID 1446209093-50016-1-git-send-email-martin@martin.st
State Committed
Commit 407ac22322e5ce67996ec54ef619cafa4c9ceb78
Headers show

Commit Message

Martin Storsjö Oct. 30, 2015, 12:44 p.m.
This fixes building on older mingw (both mingw.org and mingw64;
mingw64 from before May 2011).
---
I know that many think that mingw.org toolchains shouldn't be
supported/used, but I ran into this issue with a mingw64 setup
as well.
---
 compat/w32pthreads.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Hendrik Leppkes Oct. 30, 2015, 12:53 p.m. | #1
On Fri, Oct 30, 2015 at 1:44 PM, Martin Storsjö <martin@martin.st> wrote:
> This fixes building on older mingw (both mingw.org and mingw64;
> mingw64 from before May 2011).
> ---
> I know that many think that mingw.org toolchains shouldn't be
> supported/used, but I ran into this issue with a mingw64 setup
> as well.
> ---
>  compat/w32pthreads.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/compat/w32pthreads.h b/compat/w32pthreads.h
> index 3bc69b3..2fe2a5a 100644
> --- a/compat/w32pthreads.h
> +++ b/compat/w32pthreads.h
> @@ -39,9 +39,9 @@
>  #include <windows.h>
>  #include <process.h>
>
> -/* MinGW requires the intrinsics header for the pthread_once fallback code */
>  #if _WIN32_WINNT < 0x0600 && defined(__MINGW32__)
> -#include <intrin.h>
> +#undef MemoryBarrier
> +#define MemoryBarrier __sync_synchronize
>  #endif
>
>  #include "libavutil/attributes.h"
> --
> 2.4.9 (Apple Git-60)

I suppose its fine.
While I'm one of those that think old mingw shouldn't be used anymore,
this change is rather trivial and not worth bikeshedding over. ;)
Luca Barbato Oct. 30, 2015, 12:58 p.m. | #2
On 30/10/15 13:44, Martin Storsjö wrote:
> This fixes building on older mingw (both mingw.org and mingw64;
> mingw64 from before May 2011).
> ---
> I know that many think that mingw.org toolchains shouldn't be
> supported/used, but I ran into this issue with a mingw64 setup
> as well.
> ---
>  compat/w32pthreads.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/compat/w32pthreads.h b/compat/w32pthreads.h
> index 3bc69b3..2fe2a5a 100644
> --- a/compat/w32pthreads.h
> +++ b/compat/w32pthreads.h
> @@ -39,9 +39,9 @@
>  #include <windows.h>
>  #include <process.h>
>  
> -/* MinGW requires the intrinsics header for the pthread_once fallback code */
>  #if _WIN32_WINNT < 0x0600 && defined(__MINGW32__)
> -#include <intrin.h>
> +#undef MemoryBarrier
> +#define MemoryBarrier __sync_synchronize
>  #endif
>  
>  #include "libavutil/attributes.h"
> 

Thanks for fixing it.

Patch

diff --git a/compat/w32pthreads.h b/compat/w32pthreads.h
index 3bc69b3..2fe2a5a 100644
--- a/compat/w32pthreads.h
+++ b/compat/w32pthreads.h
@@ -39,9 +39,9 @@ 
 #include <windows.h>
 #include <process.h>
 
-/* MinGW requires the intrinsics header for the pthread_once fallback code */
 #if _WIN32_WINNT < 0x0600 && defined(__MINGW32__)
-#include <intrin.h>
+#undef MemoryBarrier
+#define MemoryBarrier __sync_synchronize
 #endif
 
 #include "libavutil/attributes.h"