Remove function sr_ResHI from Linux specific code.
Add function VG_(sr_as_string).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15116 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/m_libcprint.c b/coregrind/m_libcprint.c
index fbd3d4c..b6efaad 100644
--- a/coregrind/m_libcprint.c
+++ b/coregrind/m_libcprint.c
@@ -643,6 +643,44 @@
    VG_(exit)(1);
 }
 
+/* ---------------------------------------------------------------------
+   VG_(sr_as_string)()
+   ------------------------------------------------------------------ */
+
+/* Return a textual representation of a SysRes value in a statically
+   allocated buffer. The buffer will be overwritten with the next 
+   invocation. */
+#if defined(VGO_linux)
+// FIXME: Does this function need to be adjusted for MIPS's _valEx ?
+const HChar *VG_(sr_as_string) ( SysRes sr )
+{
+   static HChar buf[7+1+2+16+1+1];   // large enough
+
+   if (sr_isError(sr))
+      VG_(sprintf)(buf, "Failure(0x%lx)", sr_Err(sr));
+   else
+      VG_(sprintf)(buf, "Success(0x%lx)", sr_Res(sr));
+   return buf;
+}
+
+#elif defined(VGO_darwin)
+
+const HChar *VG_(sr_as_string) ( SysRes sr )
+{
+   static HChar buf[7+1+2+16+1+2+16+1+1];   // large enough
+
+   if (sr_isError(sr))
+      VG_(sprintf)(buf, "Failure(0x%lx)", sr_Err(sr));
+   else
+      VG_(sprintf)(buf, "Success(0x%lx:0x%lx)", sr_ResHI(sr), sr_Res(sr));
+   return buf;
+}
+
+#else
+
+#error unknown OS
+
+#endif
 
 /*--------------------------------------------------------------------*/
 /*--- end                                                          ---*/