ruby-changes:69978
From: Nobuyoshi <ko1@a...>
Date: Tue, 30 Nov 2021 09:11:47 +0900 (JST)
Subject: [ruby-changes:69978] 12fbdf4d4e (master): Fix conflicting declaration on Solaris
https://git.ruby-lang.org/ruby.git/commit/?id=12fbdf4d4e From 12fbdf4d4e52bafaeef6f923b8f357a39a37c02b Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Tue, 30 Nov 2021 09:01:36 +0900 Subject: Fix conflicting declaration on Solaris SunC ``` "cont.c", line 24: identifier redeclared: madvise current : function(pointer to char, unsigned int, int) returning int previous: function(pointer to void, unsigned int, int) returning int : "/usr/include/sys/mman.h", line 232 ``` GCC ``` cont.c:24:12: error: conflicting types for 'madvise' 24 | extern int madvise(caddr_t, size_t, int); | ^~~~~~~ In file included from cont.c:16: /usr/include/sys/mman.h:232:12: note: previous declaration of 'madvise' was here 232 | extern int madvise(void *, size_t, int); | ^~~~~~~ ``` --- configure.ac | 9 +++++++++ cont.c | 3 +-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 4b495371d49..7ec11478f5c 100644 --- a/configure.ac +++ b/configure.ac @@ -1108,6 +1108,15 @@ main() https://github.com/ruby/ruby/blob/trunk/configure.ac#L1108 ]) ]) AC_CHECK_TYPES([caddr_t],[],[],[@%:@include <sys/types.h>]) + RUBY_WERROR_FLAG([AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + @%:@if defined(HAVE_CADDR_T) && (defined(MADV_FREE) || defined(MADV_DONTNEED)) + @%:@include <sys/unistd.h> + @%:@include <sys/mman.h> + @%:@include <sys/types.h> + extern int madvise(caddr_t, size_t, int); + ]], [[]])], + [AC_DEFINE(NEED_MADVICE_PROTOTYPE_USING_CADDR_T, 1)], []) + ]) ], [haiku*], [ LIBS="$LIBS" # m lib is include in root diff --git a/cont.c b/cont.c index 2af7971a9a3..290be430122 100644 --- a/cont.c +++ b/cont.c @@ -18,8 +18,7 @@ https://github.com/ruby/ruby/blob/trunk/cont.c#L18 // 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)) +#ifdef NEED_MADVICE_PROTOTYPE_USING_CADDR_T #include <sys/types.h> extern int madvise(caddr_t, size_t, int); #endif -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/