From patchwork Sat Sep 11 11:51:57 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 64510 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 1414CB70CD for ; Sat, 11 Sep 2010 21:53:18 +1000 (EST) Received: from localhost ([127.0.0.1]:35519 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OuOdr-0002Ga-EU for incoming@patchwork.ozlabs.org; Sat, 11 Sep 2010 07:53:11 -0400 Received: from [140.186.70.92] (port=52192 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OuOdI-0002GV-Rl for qemu-devel@nongnu.org; Sat, 11 Sep 2010 07:52:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OuOdH-0007Vl-F4 for qemu-devel@nongnu.org; Sat, 11 Sep 2010 07:52:36 -0400 Received: from fmmailgate01.web.de ([217.72.192.221]:35215) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OuOdH-0007Vc-3T for qemu-devel@nongnu.org; Sat, 11 Sep 2010 07:52:35 -0400 Received: from smtp01.web.de ( [172.20.0.243]) by fmmailgate01.web.de (Postfix) with ESMTP id 65E47167F051B; Sat, 11 Sep 2010 13:52:33 +0200 (CEST) Received: from [84.148.28.143] (helo=sunshine.local) by smtp01.web.de with asmtp (WEB.DE 4.110 #24) id 1OuOdF-0007oF-00; Sat, 11 Sep 2010 13:52:33 +0200 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Sat, 11 Sep 2010 13:51:57 +0200 Message-Id: <1284205917-8124-1-git-send-email-andreas.faerber@web.de> X-Mailer: git-send-email 1.7.2.2 MIME-Version: 1.0 X-Sender: Andreas.Faerber@web.de X-Provags-ID: V01U2FsdGVkX18YVFmLDfcm0njGR8OgOWtjanW6GdLpjKgUMv6b VKuM2mh7zGeib0EBGOJ6VzvO5frJSAUQLDufb9/3nUYL5MLjTd 64OWhAfy0ayX+Qcvy0mw== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 Cc: Blue Swirl , =?UTF-8?q?Andreas=20F=C3=A4rber?= Subject: [Qemu-devel] [PATCH] Prefer posix_madvise() over madvise() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Andreas Färber vl.c has a Sun-specific hack to supply a prototype for madvise(), but the call site has apparently moved to arch_init.c. The underlying issue is that madvise() is not a POSIX function, therefore Solaris' _POSIX_C_SOURCE suppresses the prototype. Haiku doesn't implement madvise() at all. Where functionality equivalent to that of madvise() is provided, use the POSIX function posix_madvise(). http://www.opengroup.org/onlinepubs/9699919799/functions/posix_madvise.html Remaining madvise() users: exec.c: limited to __linux__ and/or MADV_MERGEABLE (no POSIX equivalent) kvm-all.c: limited to MADV_DONTFORK (no POSIX equivalent), otherwise runtime error if !kvm_has_sync_mmu() hw/virtio-balloon.c: limited to __linux__ Signed-off-by: Andreas Färber Cc: Blue Swirl --- arch_init.c | 2 +- vl.c | 3 --- 2 files changed, 1 insertions(+), 4 deletions(-) diff --git a/arch_init.c b/arch_init.c index e468c0c..fa39557 100644 --- a/arch_init.c +++ b/arch_init.c @@ -396,7 +396,7 @@ int ram_load(QEMUFile *f, void *opaque, int version_id) #ifndef _WIN32 if (ch == 0 && (!kvm_enabled() || kvm_has_sync_mmu())) { - madvise(host, TARGET_PAGE_SIZE, MADV_DONTNEED); + posix_madvise(host, TARGET_PAGE_SIZE, POSIX_MADV_DONTNEED); } #endif } else if (flags & RAM_SAVE_FLAG_PAGE) { diff --git a/vl.c b/vl.c index 3f45aa9..d352d18 100644 --- a/vl.c +++ b/vl.c @@ -80,9 +80,6 @@ #include #include #include -/* See MySQL bug #7156 (http://bugs.mysql.com/bug.php?id=7156) for - discussion about Solaris header problems */ -extern int madvise(caddr_t, size_t, int); #endif #endif #endif