[llvm-commits] [compiler-rt] r152540 - /compiler-rt/trunk/lib/asan/asan_win.cc

Timur Iskhodzhanov timurrrr at google.com
Sun Mar 11 05:45:13 PDT 2012


Author: timurrrr
Date: Sun Mar 11 07:45:12 2012
New Revision: 152540

URL: http://llvm.org/viewvc/llvm-project?rev=152540&view=rev
Log:
[ASan] Use WriteFile instead of fwrite in AsanWrite

Modified:
    compiler-rt/trunk/lib/asan/asan_win.cc

Modified: compiler-rt/trunk/lib/asan/asan_win.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_win.cc?rev=152540&r1=152539&r2=152540&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_win.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_win.cc Sun Mar 11 07:45:12 2012
@@ -59,8 +59,13 @@
   if (fd != 2)
     UNIMPLEMENTED();
 
-  // FIXME: use WriteFile instead?
-  return fwrite(buf, 1, count, stderr);
+  HANDLE err = GetStdHandle(STD_ERROR_HANDLE);
+  if (err == NULL)
+    return 0;  // FIXME: this might not work on some apps.
+  DWORD ret;
+  if (!WriteFile(err, buf, count, &ret, NULL))
+    return 0;
+  return ret;
 }
 
 // FIXME: Looks like these functions are not needed and are linked in by the





More information about the llvm-commits mailing list