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);
      |            ^~~~~~~
```
This commit is contained in:
Nobuyoshi Nakada 2021-11-30 09:01:36 +09:00
Родитель ac8647bec1
Коммит 12fbdf4d4e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 7CD2805BFA3770C6
2 изменённых файлов: 10 добавлений и 2 удалений

Просмотреть файл

@ -1108,6 +1108,15 @@ main()
])
])
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

3
cont.c
Просмотреть файл

@ -18,8 +18,7 @@
// 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