diff mbox

[2/6] add softmmu_target_strlen

Message ID 1249310711-8873-3-git-send-email-froydnj@codesourcery.com
State Superseded
Headers show

Commit Message

Nathan Froyd Aug. 3, 2009, 2:45 p.m. UTC
Signed-off-by: Nathan Froyd <froydnj@codesourcery.com>
---
 softmmu-semi.h |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)
diff mbox

Patch

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