Made the ARM port with simulator build and run on Windows.
authorsgjesse@chromium.org <sgjesse@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 19 Sep 2008 12:35:15 +0000 (12:35 +0000)
committersgjesse@chromium.org <sgjesse@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 19 Sep 2008 12:35:15 +0000 (12:35 +0000)
The reason for the "ugly" definition of SScanF is that the Windows CRT does not have a vsscanf function making it difficult to add OS::SSprintF to platform.h.
Review URL: http://codereview.chromium.org/2988

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@350 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/disasm-arm.cc
src/simulator-arm.cc

index 88f6842..4aa9b78 100644 (file)
@@ -855,13 +855,9 @@ static const char* reg_names[16] = {
 
 
 const char* NameConverter::NameOfAddress(byte* addr) const {
-  static char tmp_buffer[32];
-#ifdef WIN32
-  _snprintf(tmp_buffer, sizeof tmp_buffer, "%p", addr);
-#else
-  snprintf(tmp_buffer, sizeof tmp_buffer, "%p", addr);
-#endif
-  return tmp_buffer;
+  static v8::internal::EmbeddedVector<char, 32> tmp_buffer;
+  v8::internal::OS::SNPrintF(tmp_buffer, "%p", addr);
+  return tmp_buffer.start();
 }
 
 
index d76957f..321ab06 100644 (file)
@@ -44,6 +44,15 @@ using ::v8::internal::OS;
 using ::v8::internal::ReadLine;
 using ::v8::internal::DeleteArray;
 
+// This macro provides a platform independent use of sscanf. The reason for
+// SScanF not beeing implemented in a platform independent was through
+// ::v8::internal::OS in the same way as SNPrintF is that the Windows C Run-Time
+// Library does not provide vsscanf.
+#ifdef WIN32
+#define SScanF sscanf_s
+#else
+#define SScanF sscanf  // NOLINT
+#endif
 
 // The Debugger class is used by the simulator while debugging simulated ARM
 // code.
@@ -130,7 +139,7 @@ bool Debugger::GetValue(char* desc, int32_t* value) {
     }
     return true;
   } else {
-    return sscanf(desc, "%i", value) == 1;  // NOLINT
+    return SScanF(desc, "%i", value) == 1;
   }
   return false;
 }
@@ -215,7 +224,7 @@ void Debugger::Debug() {
     } else {
       // Use sscanf to parse the individual parts of the command line. At the
       // moment no command expects more than two parameters.
-      int args = sscanf(line,  // NOLINT
+      int args = SScanF(line,
                         "%" XSTR(COMMAND_SIZE) "s "
                         "%" XSTR(ARG_SIZE) "s "
                         "%" XSTR(ARG_SIZE) "s",