From patchwork Mon Aug 3 14:45:07 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Froyd X-Patchwork-Id: 30598 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 9ECC7B6F1F for ; Tue, 4 Aug 2009 03:08:18 +1000 (EST) Received: from localhost ([127.0.0.1]:50854 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MY11C-0003dj-Cm for incoming@patchwork.ozlabs.org; Mon, 03 Aug 2009 13:08:14 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MXyu3-0007qO-3C for qemu-devel@nongnu.org; Mon, 03 Aug 2009 10:52:43 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MXyty-0007mF-Ik for qemu-devel@nongnu.org; Mon, 03 Aug 2009 10:52:42 -0400 Received: from [199.232.76.173] (port=47679 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MXyty-0007lv-5H for qemu-devel@nongnu.org; Mon, 03 Aug 2009 10:52:38 -0400 Received: from mx20.gnu.org ([199.232.41.8]:47644) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MXytx-0006cr-Lw for qemu-devel@nongnu.org; Mon, 03 Aug 2009 10:52:37 -0400 Received: from mail.codesourcery.com ([65.74.133.4]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MXytw-0001h4-Oy for qemu-devel@nongnu.org; Mon, 03 Aug 2009 10:52:37 -0400 Received: (qmail 16848 invoked from network); 3 Aug 2009 14:45:11 -0000 Received: from unknown (HELO localhost) (froydnj@127.0.0.2) by mail.codesourcery.com with ESMTPA; 3 Aug 2009 14:45:11 -0000 From: Nathan Froyd To: qemu-devel@nongnu.org Date: Mon, 3 Aug 2009 07:45:07 -0700 Message-Id: <1249310711-8873-3-git-send-email-froydnj@codesourcery.com> X-Mailer: git-send-email 1.6.3.2 In-Reply-To: <1249310711-8873-1-git-send-email-froydnj@codesourcery.com> References: <1249310711-8873-1-git-send-email-froydnj@codesourcery.com> X-Detected-Operating-System: by mx20.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Subject: [Qemu-devel] [PATCH 2/6] add softmmu_target_strlen 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 Signed-off-by: Nathan Froyd --- softmmu-semi.h | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-) diff --git a/softmmu-semi.h b/softmmu-semi.h index 79278cc..a32588a 100644 --- a/softmmu-semi.h +++ b/softmmu-semi.h @@ -7,6 +7,12 @@ * This code is licenced under the GPL */ +#ifdef __GNUC__ +#define SOFTMMU_UNUSED __attribute__ ((unused)) +#else +#define SOFTMUU_UNUSED +#endif + static inline uint32_t softmmu_tget32(CPUState *env, uint32_t addr) { uint32_t val; @@ -60,6 +66,23 @@ static char *softmmu_lock_user_string(CPUState *env, uint32_t addr) return s; } #define lock_user_string(p) softmmu_lock_user_string(env, p) + +SOFTMMU_UNUSED +static int softmmu_target_strlen(CPUState *env, target_ulong addr) +{ + uint8_t c; + int len; + + len = 0; + do { + cpu_memory_rw_debug(env, addr + len, &c, 1, 0); + len++; + } while (c); + + return len - 1; +} +#define target_strlen(p) softmmu_target_strlen(env, p) + static void softmmu_unlock_user(CPUState *env, void *p, target_ulong addr, target_ulong len) { @@ -68,3 +91,5 @@ static void softmmu_unlock_user(CPUState *env, void *p, target_ulong addr, free(p); } #define unlock_user(s, args, len) softmmu_unlock_user(env, s, args, len) + +#undef SOFTMMU_UNUSED