[gtk/gtk-4-2: 46/91] meson: check for madvise()
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/gtk-4-2: 46/91] meson: check for madvise()
- Date: Tue, 4 May 2021 02:05:41 +0000 (UTC)
commit b9ce81b912993f5d69e0acedd84ee3458013973c
Author: Jason Francis <jason@cycles.network>
Date: Sat Apr 17 19:28:36 2021 -0400
meson: check for madvise()
config.h.meson | 3 +++
gtk/gtksecurememory.c | 2 +-
meson.build | 5 ++++-
3 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/config.h.meson b/config.h.meson
index 549a677379..22ad215682 100644
--- a/config.h.meson
+++ b/config.h.meson
@@ -76,6 +76,9 @@
/* Define to 1 if you have a working `mmap' system call. */
#mesondefine HAVE_MMAP
+/* Define to 1 if you have a working `madvise' system call. */
+#mesondefine HAVE_MADVISE
+
/* Define to 1 if you have the `posix_fallocate' function. */
#mesondefine HAVE_POSIX_FALLOCATE
diff --git a/gtk/gtksecurememory.c b/gtk/gtksecurememory.c
index 6dff307e65..a7aa34c447 100644
--- a/gtk/gtksecurememory.c
+++ b/gtk/gtksecurememory.c
@@ -943,7 +943,7 @@ sec_acquire_pages (size_t *sz,
DEBUG_ALLOC ("gtk-secure-memory: new block ", *sz);
-#if defined(MADV_DONTDUMP)
+#if defined(HAVE_MADVISE) && defined(MADV_DONTDUMP)
if (madvise (pages, *sz, MADV_DONTDUMP) < 0) {
if (show_warning && gtk_secure_warnings) {
/*
diff --git a/meson.build b/meson.build
index 38d23ed61c..b8de932e8e 100644
--- a/meson.build
+++ b/meson.build
@@ -220,10 +220,13 @@ if cc.compiles(uint128_t_src, name : '__uint128_t available')
cdata.set('HAVE_UINT128_T', 1)
endif
-# Check for mlock
+# Check for mlock and madvise
if cc.has_function('mlock', prefix: '#include <sys/mman.h>')
cdata.set('HAVE_MLOCK', 1)
endif
+if cc.has_function('madvise', prefix: '#include <sys/mman.h>')
+ cdata.set('HAVE_MADVISE', 1)
+endif
# Disable deprecation checks for all libraries we depend on on stable branches.
# This is so newer versions of those libraries don't cause more warnings with
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]