[Lldb-commits] [lldb] r245610 - Inline fake snprintf to avoid linkage issues on Windows.
Chaoren Lin via lldb-commits
lldb-commits at lists.llvm.org
Thu Aug 20 13:53:16 PDT 2015
Author: chaoren
Date: Thu Aug 20 15:53:15 2015
New Revision: 245610
URL: http://llvm.org/viewvc/llvm-project?rev=245610&view=rev
Log:
Inline fake snprintf to avoid linkage issues on Windows.
Summary:
dllexport doesn't work if linking against a static library with its own
copy of snprintf.
Reviewers: zturner
Subscribers: zturner, lldb-commits
Differential Revision: http://reviews.llvm.org/D12206
Modified:
lldb/trunk/include/lldb/Host/windows/win32.h
lldb/trunk/source/Host/windows/Windows.cpp
Modified: lldb/trunk/include/lldb/Host/windows/win32.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/windows/win32.h?rev=245610&r1=245609&r2=245610&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/windows/win32.h (original)
+++ lldb/trunk/include/lldb/Host/windows/win32.h Thu Aug 20 15:53:15 2015
@@ -65,8 +65,19 @@ int strcasecmp(const char* s1, const cha
int strncasecmp(const char* s1, const char* s2, size_t n);
#if _MSC_VER < 1900
-int __declspec(dllexport)
-snprintf(char *buffer, size_t count, const char *format, ...);
+namespace lldb_private {
+int vsnprintf(char *buffer, size_t count, const char *format, va_list argptr);
+}
+
+// inline to avoid linkage conflicts
+int inline snprintf(char *buffer, size_t count, const char *format, ...)
+{
+ va_list argptr;
+ va_start(argptr, format);
+ int r = lldb_private::vsnprintf(buffer, count, format, argptr);
+ va_end(argptr);
+ return r;
+}
#endif
#define STDIN_FILENO 0
Modified: lldb/trunk/source/Host/windows/Windows.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/Windows.cpp?rev=245610&r1=245609&r2=245610&view=diff
==============================================================================
--- lldb/trunk/source/Host/windows/Windows.cpp (original)
+++ lldb/trunk/source/Host/windows/Windows.cpp Thu Aug 20 15:53:15 2015
@@ -203,18 +203,17 @@ int usleep(uint32_t useconds)
}
#if _MSC_VER < 1900
-int snprintf(char *buffer, size_t count, const char *format, ...)
+namespace lldb_private {
+int vsnprintf(char *buffer, size_t count, const char *format, va_list argptr)
{
int old_errno = errno;
- va_list argptr;
- va_start(argptr, format);
- int r = vsnprintf(buffer, count, format, argptr);
+ int r = ::vsnprintf(buffer, count, format, argptr);
int new_errno = errno;
buffer[count-1] = '\0';
if (r == -1 || r == count)
{
FILE *nul = fopen("nul", "w");
- int bytes_written = vfprintf(nul, format, argptr);
+ int bytes_written = ::vfprintf(nul, format, argptr);
fclose(nul);
if (bytes_written < count)
errno = new_errno;
@@ -224,9 +223,9 @@ int snprintf(char *buffer, size_t count,
r = bytes_written;
}
}
- va_end(argptr);
return r;
}
+} // namespace lldb_private
#endif
#endif // _MSC_VER
More information about the lldb-commits
mailing list