summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-08-23 19:27:03 +0000
committerChris Lattner <sabre@nondot.org>2008-08-23 19:27:03 +0000
commit0958ab0fd1fe8606f15ce38a7b893c6b74dc2aad (patch)
tree2bef0af5d479181810ae18f5273c54dfb92a95c0 /include
parent097af7fc8f8688cc21453a5561347f14ca7c5771 (diff)
downloadllvm-0958ab0fd1fe8606f15ce38a7b893c6b74dc2aad.tar.gz
llvm-0958ab0fd1fe8606f15ce38a7b893c6b74dc2aad.tar.bz2
llvm-0958ab0fd1fe8606f15ce38a7b893c6b74dc2aad.tar.xz
conditionalize this to work on windows, untested but it should work
according to the intarnetz git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55248 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/Support/raw_ostream.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/llvm/Support/raw_ostream.h b/include/llvm/Support/raw_ostream.h
index 58d5be2741..db312f8735 100644
--- a/include/llvm/Support/raw_ostream.h
+++ b/include/llvm/Support/raw_ostream.h
@@ -17,6 +17,7 @@
#include "llvm/ADT/StringExtras.h"
#include <cassert>
#include <cstring>
+#include <cstdio>
#include <string>
#include <iosfwd>
@@ -173,7 +174,11 @@ public:
/// returns the length of the formatted string. If the buffer is too small,
/// this returns a length to retry with, which will be larger than BufferSize.
virtual unsigned print(char *Buffer, unsigned BufferSize) const {
+#ifdef WIN32
+ int N = _snprintf(Buffer, BufferSize-1, Fmt, Val);
+#else
int N = snprintf(Buffer, BufferSize-1, Fmt, Val);
+#endif
if (N < 0) // VC++ and old GlibC return negative on overflow.
return BufferSize*2;
if (unsigned(N) >= BufferSize-1)// Other impls yield number of bytes needed.