[Lldb-commits] [PATCH] D79999: [lldb] [Windows] Provide vasprintf only for MSVC

Mateusz MikuĊ‚a via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri May 15 05:53:23 PDT 2020


mati865 created this revision.
mati865 added a project: LLDB.

Mingw-w64 provides this function and it has been causing issues for MSYS2 when building lldb.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79999

Files:
  lldb/include/lldb/Host/windows/PosixApi.h
  lldb/source/Host/windows/Windows.cpp


Index: lldb/source/Host/windows/Windows.cpp
===================================================================
--- lldb/source/Host/windows/Windows.cpp
+++ lldb/source/Host/windows/Windows.cpp
@@ -42,28 +42,6 @@
 }
 }
 
-int vasprintf(char **ret, const char *fmt, va_list ap) {
-  char *buf;
-  int len;
-  size_t buflen;
-  va_list ap2;
-
-  va_copy(ap2, ap);
-  len = vsnprintf(NULL, 0, fmt, ap2);
-
-  if (len >= 0 &&
-      (buf = (char *)malloc((buflen = (size_t)(len + 1)))) != NULL) {
-    len = vsnprintf(buf, buflen, fmt, ap);
-    *ret = buf;
-  } else {
-    *ret = NULL;
-    len = -1;
-  }
-
-  va_end(ap2);
-  return len;
-}
-
 char *strcasestr(const char *s, const char *find) {
   char c, sc;
   size_t len;
@@ -194,6 +172,28 @@
   return strnicmp(s1, s2, n);
 }
 
+int vasprintf(char **ret, const char *fmt, va_list ap) {
+  char *buf;
+  int len;
+  size_t buflen;
+  va_list ap2;
+
+  va_copy(ap2, ap);
+  len = vsnprintf(NULL, 0, fmt, ap2);
+
+  if (len >= 0 &&
+      (buf = (char *)malloc((buflen = (size_t)(len + 1)))) != NULL) {
+    len = vsnprintf(buf, buflen, fmt, ap);
+    *ret = buf;
+  } else {
+    *ret = NULL;
+    len = -1;
+  }
+
+  va_end(ap2);
+  return len;
+}
+
 #if _MSC_VER < 1900
 namespace lldb_private {
 int vsnprintf(char *buffer, size_t count, const char *format, va_list argptr) {
Index: lldb/include/lldb/Host/windows/PosixApi.h
===================================================================
--- lldb/include/lldb/Host/windows/PosixApi.h
+++ lldb/include/lldb/Host/windows/PosixApi.h
@@ -96,7 +96,6 @@
 
 // Various useful posix functions that are not present in Windows.  We provide
 // custom implementations.
-int vasprintf(char **ret, const char *fmt, va_list ap);
 char *strcasestr(const char *s, const char *find);
 char *realpath(const char *name, char *resolved);
 
@@ -108,6 +107,8 @@
 int strcasecmp(const char *s1, const char *s2);
 int strncasecmp(const char *s1, const char *s2, size_t n);
 
+int vasprintf(char **ret, const char *fmt, va_list ap);
+
 #endif // _MSC_VER
 
 // empty functions


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79999.264208.patch
Type: text/x-patch
Size: 2062 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200515/53a99b37/attachment.bin>


More information about the lldb-commits mailing list