[Piglit] [PATCH] util: Do not define asprintf for MinGW.

Vinson Lee vlee at freedesktop.org
Thu Dec 19 16:39:07 PST 2013


MinGW provides asprintf in stdio.h.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=72556
Signed-off-by: Vinson Lee <vlee at freedesktop.org>
---
 tests/util/piglit-util.c | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/tests/util/piglit-util.c b/tests/util/piglit-util.c
index 1c7f118..fbc8723 100644
--- a/tests/util/piglit-util.c
+++ b/tests/util/piglit-util.c
@@ -56,14 +56,7 @@
 #include "piglit-util.h"
 
 
-#if defined(_WIN32)
-
-/* Some versions of MinGW are missing _vscprintf's declaration, although they
- * still provide the symbol in the import library.
- */
-#ifdef __MINGW32__
-_CRTIMP int _vscprintf(const char *format, va_list argptr);
-#endif
+#if defined(_MSC_VER)
 
 int asprintf(char **strp, const char *fmt, ...)
 {
@@ -76,15 +69,10 @@ int asprintf(char **strp, const char *fmt, ...)
 
 	va_copy(args_copy, args);
 
-#ifdef _WIN32
 	/* We need to use _vcsprintf to calculate the length as vsnprintf returns -1
 	 * if the number of characters to write is greater than count.
 	 */
 	length = _vscprintf(fmt, args_copy);
-#else
-	char dummy;
-	length = vsnprintf(&dummy, sizeof dummy, fmt, args_copy);
-#endif
 
 	va_end(args_copy);
 
@@ -103,7 +91,7 @@ int asprintf(char **strp, const char *fmt, ...)
 	return length;
 }
 
-#endif /* _WIN32 */
+#endif /* _MSC_VER */
 
 /**
  * \brief Split \a string into an array of strings.
-- 
1.8.4.2



More information about the Piglit mailing list