$OpenBSD: patch-meson_build,v 1.2 2019/01/10 13:36:26 jca Exp $

The old autoconf build has the following additional check after
determining a valid type for gsize:

dnl If int/long are the same size, we see which one produces
dnl warnings when used in the location as size_t. (This matters
dnl on AIX with xlc)
dnl
AS_IF([test $ac_cv_sizeof_size_t = $ac_cv_sizeof_int &&
       test $ac_cv_sizeof_size_t = $ac_cv_sizeof_long], 

It matters on OpenBSD too. Since sthen's meson-fu is lacking, this
simply reorders the if statement to put the one we need earlier.

Last hunk: __GCC_HAVE_SYNC_* macros were introduced after gcc 4.2.1,
make the workaround more generic.

Index: meson.build
--- meson.build.orig
+++ meson.build
@@ -1267,13 +1267,6 @@ if sizet_size == short_size
   glibconfig_conf.set_quoted('gsize_format', 'hu')
   glibconfig_conf.set_quoted('gssize_format', 'hi')
   glibconfig_conf.set('glib_msize_type', 'SHRT')
-elif sizet_size == int_size
-  glibconfig_conf.set('glib_size_type_define', 'int')
-  glibconfig_conf.set_quoted('gsize_modifier', '')
-  glibconfig_conf.set_quoted('gssize_modifier', '')
-  glibconfig_conf.set_quoted('gsize_format', 'u')
-  glibconfig_conf.set_quoted('gssize_format', 'i')
-  glibconfig_conf.set('glib_msize_type', 'INT')
 elif sizet_size == long_size
   glibconfig_conf.set('glib_size_type_define', 'long')
   glibconfig_conf.set_quoted('gsize_modifier', 'l')
@@ -1281,6 +1274,13 @@ elif sizet_size == long_size
   glibconfig_conf.set_quoted('gsize_format', 'lu')
   glibconfig_conf.set_quoted('gssize_format', 'li')
   glibconfig_conf.set('glib_msize_type', 'LONG')
+elif sizet_size == int_size
+  glibconfig_conf.set('glib_size_type_define', 'int')
+  glibconfig_conf.set_quoted('gsize_modifier', '')
+  glibconfig_conf.set_quoted('gssize_modifier', '')
+  glibconfig_conf.set_quoted('gsize_format', 'u')
+  glibconfig_conf.set_quoted('gssize_format', 'i')
+  glibconfig_conf.set('glib_msize_type', 'INT')
 elif sizet_size == long_long_size
   glibconfig_conf.set('glib_size_type_define', 'long long')
   glibconfig_conf.set_quoted('gsize_modifier', int64_m)
@@ -1571,9 +1571,8 @@ atomicdefine = '''
 # We know that we can always use real ("lock free") atomic operations with MSVC
 if cc.get_id() == 'msvc' or cc.links(atomictest, name : 'atomic ops')
   have_atomic_lock_free = true
-  if (host_system == 'android' or host_system == 'linux') and not cc.compiles(atomicdefine, name : 'atomic ops define')
-    # When building for armv5 on Linux, gcc provides
-    # __sync_bool_compare_and_swap but doesn't define
+  if cc.get_id() == 'gcc' and not cc.compiles(atomicdefine, name : 'atomic ops define')
+    # Old gcc release may provide __sync_bool_compare_and_swap but don't define
     # __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
     glib_conf.set('__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4', true)
   endif
