[glib: 1/2] build: Mismatch between gint64 and int64_t in OSX 64-bit
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 1/2] build: Mismatch between gint64 and int64_t in OSX 64-bit
- Date: Thu, 23 Aug 2018 07:51:58 +0000 (UTC)
commit 5df3f42d7ba1d3bba55fbcd1e253820d850ba121
Author: John Ralls <jralls ceridwen us>
Date: Sat Dec 13 16:38:51 2014 -0800
build: Mismatch between gint64 and int64_t in OSX 64-bit
Check for compile warnings when assigning an int64_t* to a long*,
make gint64 a long long if they occur and assigning an int64_t* to
a long long* doesn't.
Modified by Philip Withnall <withnall endlessm com> to support Meson as
well as autotools.
https://gitlab.gnome.org/GNOME/glib/issues/972
configure.ac | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++-------
meson.build | 37 ++++++++++++++++++++++++++++++++++--
2 files changed, 89 insertions(+), 9 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 3fd519ecd..704014579 100644
--- a/configure.ac
+++ b/configure.ac
@@ -834,6 +834,41 @@ int main ()
AC_MSG_RESULT($glib_ssize_type)
+dnl Some platforms (Apple) hard-code int64_t to long long instead of
+dnl using long on 64-bit architectures. This can cause type mismatch
+dnl warnings when trying to interface with code using the standard
+dnl library type. Test for the warnings and set gint64 to whichever
+dnl works.
+dnl
+AS_IF([test $ac_cv_sizeof_long_long = $ac_cv_sizeof_long], [
+ GLIB_CHECK_COMPILE_WARNINGS([AC_LANG_SOURCE([[
+#if defined(_AIX) && !defined(__GNUC__)
+#pragma options langlvl=stdc99
+#endif
+#include <stdint.h>
+#include <stdio.h>
+int main ()
+{
+ int64_t i1 = 1;
+ long *i2 = &i1;
+ return 1;
+}
+ ]])],[ glib_cv_int64_t=long ],
+ [GLIB_CHECK_COMPILE_WARNINGS([AC_LANG_SOURCE([[
+#if defined(_AIX) && !defined(__GNUC__)
+#pragma options langlvl=stdc99
+#endif
+#include <stdint.h>
+#include <stdio.h>
+int main ()
+{
+ int64_t i1 = 1;
+ long long *i2 = &i1;
+ return 1;
+}
+ ]])],[ glib_cv_int64_t=long_long ])])
+])
+
# Check for some functions
AC_CHECK_FUNCS(lstat strsignal vsnprintf stpcpy strcasecmp strncasecmp poll vasprintf setenv unsetenv
getc_unlocked readlink symlink fdwalk mkostemp link)
AC_CHECK_FUNCS(lchmod lchown fchmod fchown utimes getresuid)
@@ -3018,13 +3053,25 @@ $ac_cv_sizeof_int)
guint64_constant='(val)'
;;
$ac_cv_sizeof_long)
- gint64=long
- gint64_modifier='"l"'
- gint64_format='"li"'
- guint64_format='"lu"'
- glib_extension=
- gint64_constant='(val##L)'
- guint64_constant='(val##UL)'
+ if test "x$glib_cv_int64_t" = "xlong_long"; then
+ gint64='long long'
+ if test -n "$glib_cv_long_long_format"; then
+ gint64_modifier='"'$glib_cv_long_long_format'"'
+ gint64_format='"'$glib_cv_long_long_format'i"'
+ guint64_format='"'$glib_cv_long_long_format'u"'
+ fi
+ glib_extension='G_GNUC_EXTENSION '
+ gint64_constant='(G_GNUC_EXTENSION (val##LL))'
+ guint64_constant='(G_GNUC_EXTENSION (val##ULL))'
+ else
+ gint64=long
+ gint64_modifier='"l"'
+ gint64_format='"li"'
+ guint64_format='"lu"'
+ glib_extension=
+ gint64_constant='(val##L)'
+ guint64_constant='(val##UL)'
+ fi
;;
$ac_cv_sizeof_long_long)
gint64='long long'
diff --git a/meson.build b/meson.build
index 20bdb3743..a0fd423c3 100644
--- a/meson.build
+++ b/meson.build
@@ -1073,6 +1073,39 @@ else
ssizet_size = cc.sizeof('ssize_t')
endif
+# Some platforms (Apple) hard-code int64_t to long long instead of
+# using long on 64-bit architectures. This can cause type mismatch
+# warnings when trying to interface with code using the standard
+# library type. Test for the warnings and set gint64 to whichever
+# works.
+if long_long_size == long_size
+ if cc.compiles('''#if defined(_AIX) && !defined(__GNUC__)
+ #pragma options langlvl=stdc99
+ #endif
+ #pragma GCC diagnostic error "-Wincompatible-pointer-types"
+ #include <stdint.h>
+ #include <stdio.h>
+ int main () {
+ int64_t i1 = 1;
+ long *i2 = &i1;
+ return 1;
+ }''', name : 'int64_t is long')
+ int64_t_typedef = 'long'
+ elif cc.compiles('''#if defined(_AIX) && !defined(__GNUC__)
+ #pragma options langlvl=stdc99
+ #endif
+ #pragma GCC diagnostic error "-Wincompatible-pointer-types"
+ #include <stdint.h>
+ #include <stdio.h>
+ int main () {
+ int64_t i1 = 1;
+ long long *i2 = &i1;
+ return 1;
+ }''', name : 'int64_t is long long')
+ int64_t_typedef = 'long long'
+ endif
+endif
+
int64_m = 'll'
char_align = cc.alignment('char')
short_align = cc.alignment('short')
@@ -1149,7 +1182,7 @@ if int_size == 8
gint64_constant='(val)'
guint64_constant='(val)'
guint64_align = int_align
-elif long_size == 8
+elif long_size == 8 and (long_long_size != long_size or int64_t_typedef == 'long')
gint64 = 'long'
glib_extension=''
gint64_modifier='l'
@@ -1158,7 +1191,7 @@ elif long_size == 8
gint64_constant='(val##L)'
guint64_constant='(val##UL)'
guint64_align = long_align
-elif long_long_size == 8
+elif long_long_size == 8 and (long_long_size != long_size or int64_t_typedef == 'long long')
gint64 = 'long long'
glib_extension='G_GNUC_EXTENSION '
gint64_modifier=int64_m
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]