Re: [HarfBuzz] Patches for building HarfBuzz with mingw.org's MinGW

2019-06-05 Thread Eli Zaretskii
> From: Behdad Esfahbod 
> Date: Tue, 4 Jun 2019 13:08:35 -0700
> Cc: "harfbuzz@lists.freedesktop.org" 
> 
> I can't say I'm super-excited about adding more workarounds, specially since 
> I don't even understand why you
> can't use mingw64 instead.
> 
> At any rate, I'm not one to judge.  Please open a github Pull Request with 
> your changes and we'll go from
> there.

Done, I think.
___
HarfBuzz mailing list
HarfBuzz@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/harfbuzz

Re: [HarfBuzz] Patches for building HarfBuzz with mingw.org's MinGW

2019-06-04 Thread Behdad Esfahbod
Hi Eli,

I can't say I'm super-excited about adding more workarounds, specially
since I don't even understand why you can't use mingw64 instead.

At any rate, I'm not one to judge.  Please open a github Pull Request with
your changes and we'll go from there.

Thanks

On Sun, Jun 2, 2019 at 9:35 AM Eli Zaretskii  wrote:

> Hi,
>
> I'd like to submit a few small patches that allow HarfBuzz to be built
> on Windows with mingw.org's MinGW toolchain.  (And before you ask: the
> reason you don't see the problems I describe below in your MinGW
> builds is that you use MinGW64, which is a different flavor of MinGW.)
>
> The patches are against HarfBuzz 2.5.1.
>
> Here are the patches, with explanations:
>
> 1. This patch is needed because MinGW doesn't have _BitScanForward and
> _BitScanReverse.  They are only used with old GCC versions, so
> conditioning their calls by those old versions of GCC is good enough,
> IMO.
>
> --- src/hb-algs.hh~02019-06-01 08:49:47.0 +0300
> +++ src/hb-algs.hh  2019-06-02 11:03:52.373677900 +0300
> @@ -400,7 +400,7 @@
>  return sizeof (unsigned long long) * 8 - __builtin_clzll (v);
>  #endif
>
> -#if (defined(_MSC_VER) && _MSC_VER >= 1500) || defined(__MINGW32__)
> +#if (defined(_MSC_VER) && _MSC_VER >= 1500) || (defined(__MINGW32__) &&
> (__GNUC__ < 4))
>if (sizeof (T) <= sizeof (unsigned int))
>{
>  unsigned long where;
> @@ -474,7 +474,7 @@
>  return __builtin_ctzll (v);
>  #endif
>
> -#if (defined(_MSC_VER) && _MSC_VER >= 1500) || defined(__MINGW32__)
> +#if (defined(_MSC_VER) && _MSC_VER >= 1500) || (defined(__MINGW32__) &&
> (__GNUC__ < 4))
>if (sizeof (T) <= sizeof (unsigned int))
>{
>  unsigned long where;
>
>
> 2. This patch is needed because mingw.org's MinGW defines
> MemoryBarrier as an inline function, not as a macro.
> __MINGW32_VERSION is defined only by mingw.org's MinGW, so the change
> shouldn't affect MinGW64.
>
> --- src/hb-atomic.hh~0  2019-05-27 20:07:58.0 +0300
> +++ src/hb-atomic.hh2019-06-02 10:55:49.013099500 +0300
> @@ -107,7 +107,7 @@
>
>  static inline void _hb_memory_barrier ()
>  {
> -#ifndef MemoryBarrier
> +#if !defined(MemoryBarrier) && !defined(__MINGW32_VERSION)
>/* MinGW has a convoluted history of supporting MemoryBarrier. */
>LONG dummy = 0;
>InterlockedExchange (&dummy, 1);
>
>
> 3. This patch is needed because MinGW doesn't define
> E_NOT_SUFFICIENT_BUFFER.
>
> --- src/hb-uniscribe.cc~0   2019-05-14 03:28:16.0 +0300
> +++ src/hb-uniscribe.cc 2019-06-02 11:04:43.843081900 +0300
> @@ -31,6 +31,10 @@
>  #include 
>  #include 
>
> +#ifndef E_NOT_SUFFICIENT_BUFFER
> +#define E_NOT_SUFFICIENT_BUFFER HRESULT_FROM_WIN32
> (ERROR_INSUFFICIENT_BUFFER)
> +#endif
> +
>  #include "hb-uniscribe.h"
>
>  #include "hb-open-file.hh"
>
>
> 4. This patch is needed because mingw.org's MinGW doesn't have the
> intrin.h header file; instead, the intrinsics are declared by
> including windows.h.
>
> --- src/hb.hh~0 2019-05-14 09:42:00.0 +0300
> +++ src/hb.hh   2019-06-02 11:06:01.413041500 +0300
> @@ -183,8 +183,15 @@
>  #include 
>
>  #if (defined(_MSC_VER) && _MSC_VER >= 1500) || defined(__MINGW32__)
> +#ifdef __MINGW32_VERSION
> +#ifndef WIN32_LEAN_AND_MEAN
> +#define WIN32_LEAN_AND_MEAN 1
> +#endif
> +#include 
> +#else
>  #include 
>  #endif
> +#endif
>
>  #define HB_PASTE1(a,b) a##b
>  #define HB_PASTE(a,b) HB_PASTE1(a,b)
>
>
> Thank you for developing HarfBuzz.
> ___
> HarfBuzz mailing list
> HarfBuzz@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/harfbuzz



-- 
behdad
http://behdad.org/
___
HarfBuzz mailing list
HarfBuzz@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/harfbuzz

[HarfBuzz] Patches for building HarfBuzz with mingw.org's MinGW

2019-06-02 Thread Eli Zaretskii
Hi,

I'd like to submit a few small patches that allow HarfBuzz to be built
on Windows with mingw.org's MinGW toolchain.  (And before you ask: the
reason you don't see the problems I describe below in your MinGW
builds is that you use MinGW64, which is a different flavor of MinGW.)

The patches are against HarfBuzz 2.5.1.

Here are the patches, with explanations:

1. This patch is needed because MinGW doesn't have _BitScanForward and
_BitScanReverse.  They are only used with old GCC versions, so
conditioning their calls by those old versions of GCC is good enough,
IMO.

--- src/hb-algs.hh~02019-06-01 08:49:47.0 +0300
+++ src/hb-algs.hh  2019-06-02 11:03:52.373677900 +0300
@@ -400,7 +400,7 @@
 return sizeof (unsigned long long) * 8 - __builtin_clzll (v);
 #endif
 
-#if (defined(_MSC_VER) && _MSC_VER >= 1500) || defined(__MINGW32__)
+#if (defined(_MSC_VER) && _MSC_VER >= 1500) || (defined(__MINGW32__) && 
(__GNUC__ < 4))
   if (sizeof (T) <= sizeof (unsigned int))
   {
 unsigned long where;
@@ -474,7 +474,7 @@
 return __builtin_ctzll (v);
 #endif
 
-#if (defined(_MSC_VER) && _MSC_VER >= 1500) || defined(__MINGW32__)
+#if (defined(_MSC_VER) && _MSC_VER >= 1500) || (defined(__MINGW32__) && 
(__GNUC__ < 4))
   if (sizeof (T) <= sizeof (unsigned int))
   {
 unsigned long where;


2. This patch is needed because mingw.org's MinGW defines
MemoryBarrier as an inline function, not as a macro.
__MINGW32_VERSION is defined only by mingw.org's MinGW, so the change
shouldn't affect MinGW64.

--- src/hb-atomic.hh~0  2019-05-27 20:07:58.0 +0300
+++ src/hb-atomic.hh2019-06-02 10:55:49.013099500 +0300
@@ -107,7 +107,7 @@
 
 static inline void _hb_memory_barrier ()
 {
-#ifndef MemoryBarrier
+#if !defined(MemoryBarrier) && !defined(__MINGW32_VERSION)
   /* MinGW has a convoluted history of supporting MemoryBarrier. */
   LONG dummy = 0;
   InterlockedExchange (&dummy, 1);


3. This patch is needed because MinGW doesn't define
E_NOT_SUFFICIENT_BUFFER.

--- src/hb-uniscribe.cc~0   2019-05-14 03:28:16.0 +0300
+++ src/hb-uniscribe.cc 2019-06-02 11:04:43.843081900 +0300
@@ -31,6 +31,10 @@
 #include 
 #include 
 
+#ifndef E_NOT_SUFFICIENT_BUFFER
+#define E_NOT_SUFFICIENT_BUFFER HRESULT_FROM_WIN32 (ERROR_INSUFFICIENT_BUFFER)
+#endif
+
 #include "hb-uniscribe.h"
 
 #include "hb-open-file.hh"


4. This patch is needed because mingw.org's MinGW doesn't have the
intrin.h header file; instead, the intrinsics are declared by
including windows.h.

--- src/hb.hh~0 2019-05-14 09:42:00.0 +0300
+++ src/hb.hh   2019-06-02 11:06:01.413041500 +0300
@@ -183,8 +183,15 @@
 #include 
 
 #if (defined(_MSC_VER) && _MSC_VER >= 1500) || defined(__MINGW32__)
+#ifdef __MINGW32_VERSION
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN 1
+#endif
+#include 
+#else
 #include 
 #endif
+#endif
 
 #define HB_PASTE1(a,b) a##b
 #define HB_PASTE(a,b) HB_PASTE1(a,b)


Thank you for developing HarfBuzz.
___
HarfBuzz mailing list
HarfBuzz@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/harfbuzz