[前][次][番号順一覧][スレッド一覧]

ruby-changes:69974

From: Naohisa <ko1@a...>
Date: Tue, 30 Nov 2021 00:27:59 +0900 (JST)
Subject: [ruby-changes:69974] 8287d2f23c (master): Workaround for implicit declaration of function 'madvise' on Solaris

https://git.ruby-lang.org/ruby.git/commit/?id=8287d2f23c

From 8287d2f23c06c614d1ae83b6e0dad48bcda622cb Mon Sep 17 00:00:00 2001
From: Naohisa Goto <ngotogenome@g...>
Date: Mon, 29 Nov 2021 23:46:48 +0900
Subject: Workaround for implicit declaration of function 'madvise' on Solaris

On Solaris, madvise(3C) is NOT defined for SUS (XPG4v2) or later,
but MADV_* macros are defined when __EXTENSIONS__ is defined.
This may cause compile error on Solaris 10 with GCC when
"-Werror=implicit-function-declaration" and "-D_XOPEN_SOURCE=600"
are added by configure.
---
 configure.ac | 1 +
 cont.c       | 8 ++++++++
 2 files changed, 9 insertions(+)

diff --git a/configure.ac b/configure.ac
index 66a7a9e2b0b..4b495371d49 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1107,6 +1107,7 @@ main() https://github.com/ruby/ruby/blob/trunk/configure.ac#L1107
 		    RUBY_APPEND_OPTIONS(CXXFLAGS, -U_XOPEN_SOURCE)
 		  ])
 		])
+		AC_CHECK_TYPES([caddr_t],[],[],[@%:@include <sys/types.h>])
 		],
 [haiku*], [
 		LIBS="$LIBS" # m lib is include in root
diff --git a/cont.c b/cont.c
index 8a56fa67352..2af7971a9a3 100644
--- a/cont.c
+++ b/cont.c
@@ -16,6 +16,14 @@ https://github.com/ruby/ruby/blob/trunk/cont.c#L16
 #include <sys/mman.h>
 #endif
 
+// On Solaris, madvise() is NOT declared for SUS (XPG4v2) or later,
+// but MADV_* macros are defined when __EXTENSIONS__ is defined.
+#if defined(__sun) && defined(HAVE_CADDR_T) && \
+    (defined(MADV_FREE) || defined(MADV_DONTNEED))
+#include <sys/types.h>
+extern int madvise(caddr_t, size_t, int);
+#endif
+
 #include COROUTINE_H
 
 #include "eval_intern.h"
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]