Re: [PATCH 3/5] nedmalloc: allow compiling with MSys2's compiler
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jan 13, 2016, 19:28 UTC
- Message-ID
- <xmqq8u3tnurx.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <cb506b103e7102073a1567044727837ab8ff5c64.1452691805.git.johannes.schindelin@gmx.de>
Johannes Schindelin <johannes.schindelin@gmx.de> writes:
Show 8 quoted lines
> With MSys2's GCC, `ReadWriteBarrier` is already defined, and FORCEINLINE > unfortunately gets defined incorrectly. > > Let's work around both problems, using the MSys2-specific > __MINGW64_VERSION_MAJOR constant to guard them. > > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> > ---
Thanks. I actually do not think #undef _ReadWriteBarrier needs to be inside any #ifdef, though. It isn't like it is an error to #undef that you did not #define before.
Show 27 quoted lines
> compat/nedmalloc/malloc.c.h | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/compat/nedmalloc/malloc.c.h b/compat/nedmalloc/malloc.c.h
> index f216a2a..18634e3 100644
> --- a/compat/nedmalloc/malloc.c.h
> +++ b/compat/nedmalloc/malloc.c.h
> @@ -720,6 +720,9 @@ struct mallinfo {
> inlining are defined as macros, so these aren't used for them.
> */
>
> +#ifdef __MINGW64_VERSION_MAJOR
> +#undef FORCEINLINE
> +#endif
> #ifndef FORCEINLINE
> #if defined(__GNUC__)
> #define FORCEINLINE __inline __attribute__ ((always_inline))
> @@ -1382,6 +1385,9 @@ LONG __cdecl _InterlockedExchange(LONG volatile *Target, LONG Value);
>
> /*** Atomic operations ***/
> #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) > 40100
> + #ifdef __MINGW64_VERSION_MAJOR
> + #undef _ReadWriteBarrier
> + #endif
> #define _ReadWriteBarrier() __sync_synchronize()
> #else
> static __inline__ __attribute__((always_inline)) long __sync_lock_test_and_set(volatile long * const Target, const long Value)