summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorPovilas Kanapickas <povilas@radix.lt>2021-06-26 09:44:39 +0300
committerPovilas Kanapickas <povilas@radix.lt>2021-07-05 12:46:14 +0000
commitb67e514dbb59bffc23b75d47ca7f24e96c4aeb05 (patch)
tree184e11afb137822ccaa721af9c26fc7fb08fb68b /include
parentb2a0de4f072fdcc0fb20a0853f7edaf714add9d9 (diff)
meson: Fix warnings when reading back and checking feature flags
Meson does not like comparing things of different types which is a problem when reading back values of feature flags as they may contain either false (bool) or 1 (string). Since there is a strong reason why we use false when the feature does not exist, we work around this issue by always converting the returned value to int via to_int(). Fixes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1190 Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
Diffstat (limited to 'include')
-rw-r--r--include/meson.build11
1 files changed, 10 insertions, 1 deletions
diff --git a/include/meson.build b/include/meson.build
index 23dc254ee..4d2c4e075 100644
--- a/include/meson.build
+++ b/include/meson.build
@@ -16,6 +16,15 @@ conf_data.set('HAVE_TYPEOF', cc.compiles('''
''',
name: 'typeof()') ? '1' : false)
+# For feature macros we're using either false (boolean) or '1', which correspond to the macro being
+# not defined at all and defined to 1. This is to match autotools behavior and thus preserve
+# backwards compatibility with all the existing code that uses #ifdef to check if feature is
+# enabled. This ifdef would pass if the macro is defined to 0 which would silently break code
+# in various places.
+#
+# As a complication when we read the configuration from conf_data back we get either string or
+# bool. Meson does not like comparing things of different types so we always convert the returned
+# value to an integer using to_int().
conf_data.set('MONOTONIC_CLOCK', cc.has_function('clock_gettime') and
cc.compiles('''
#define _POSIX_C_SOURCE 200112L
@@ -181,7 +190,7 @@ if cc.has_header_symbol('sys/socket.h', 'SCM_RIGHTS')
conf_data.set('XTRANS_SEND_FDS', '1')
endif
-if conf_data.get('HAVE_GETPEEREID') == false and conf_data.get('HAVE_GETPEERUCRED') == false
+if conf_data.get('HAVE_GETPEEREID').to_int() == 0 and conf_data.get('HAVE_GETPEERUCRED').to_int() == 0
if not cc.has_header_symbol('sys/socket.h', 'SO_PEERCRED')
conf_data.set('NO_LOCAL_CLIENT_CRED', 1)
endif