On older Solaris releases, we didn't get a protype for madvise, and so util/osdep.c provides its own prototype. Some time between the public Solaris 11.4 release and Solaris 11.4.42 CBE, we started getting an madvise prototype that looks like this:
extern int madvise(void *, size_t, int); Which conflicts with the prototype in util/osdeps.c. Instead of always declaring this prototype, check if madvise() is already declared, so we don't need to declare it ourselves. Signed-off-by: Andrew Deason <adea...@sinenomine.net> --- I'm not sure if a test is needed for this at all; that is, how much qemu cares about earlier Solaris. The madvise prototype exists earlier in Solaris 11 (I'm not sure when it started appearing usefully), but in 11.4 and earlier it was compatible with the char* prototype. meson.build | 3 +++ util/osdep.c | 2 ++ 2 files changed, 5 insertions(+) diff --git a/meson.build b/meson.build index 2d6601467f..c29d49c7a1 100644 --- a/meson.build +++ b/meson.build @@ -322,20 +322,23 @@ if targetos == 'windows' include_directories: include_directories('.')) host_dsosuf = '.dll' elif targetos == 'darwin' coref = dependency('appleframeworks', modules: 'CoreFoundation') iokit = dependency('appleframeworks', modules: 'IOKit', required: false) host_dsosuf = '.dylib' elif targetos == 'sunos' socket = [cc.find_library('socket'), cc.find_library('nsl'), cc.find_library('resolv')] + config_host_data.set('HAVE_MADVISE_PROTO', + cc.has_function('madvise', + prefix: '#include <sys/mman.h>')) elif targetos == 'haiku' socket = [cc.find_library('posix_error_mapper'), cc.find_library('network'), cc.find_library('bsd')] elif targetos == 'openbsd' if get_option('tcg').allowed() and target_dirs.length() > 0 # Disable OpenBSD W^X if available emulator_link_args = cc.get_supported_link_arguments('-Wl,-z,wxneeded') endif endif diff --git a/util/osdep.c b/util/osdep.c index 7c4deda6fe..c99083372b 100644 --- a/util/osdep.c +++ b/util/osdep.c @@ -21,24 +21,26 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #include "qemu/osdep.h" #include "qapi/error.h" /* Needed early for CONFIG_BSD etc. */ #ifdef CONFIG_SOLARIS #include <sys/statvfs.h> +#ifndef HAVE_MADVISE_PROTO /* See MySQL bug #7156 (http://bugs.mysql.com/bug.php?id=7156) for discussion about Solaris header problems */ extern int madvise(char *, size_t, int); #endif +#endif #include "qemu-common.h" #include "qemu/cutils.h" #include "qemu/sockets.h" #include "qemu/error-report.h" #include "qemu/madvise.h" #include "qemu/mprotect.h" #include "qemu/hw-version.h" #include "monitor/monitor.h" -- 2.11.0