mesa: set up gl_vert_result and gl_frag_attrib values for gl_ClipDistance.
[mesa.git] / src / glsl / ralloc.c
index fa2dd8b01e66ae9d4792133054236e9a2184ae53..fb48a91c56472376088a43b4b036e4245fb2cf95 100644 (file)
 #include <string.h>
 #include <stdint.h>
 
+/* Android defines SIZE_MAX in limits.h, instead of the standard stdint.h */
+#ifdef ANDROID
+#include <limits.h>
+#endif
+
 #include "ralloc.h"
 
 #ifdef __GNUC__
@@ -392,9 +397,19 @@ printf_length(const char *fmt, va_list untouched_args)
    va_list args;
    va_copy(args, untouched_args);
 
+#ifdef _MSC_VER
+   /* We need to use _vcsprintf to calculate the size as vsnprintf returns -1
+    * if the number of characters to write is greater than count.
+    */
+   size = _vscprintf(fmt, args);
+   (void)junk;
+#else
    size = vsnprintf(&junk, 1, fmt, args);
+#endif
    assert(size >= 0);
 
+   va_end(args);
+
    return size;
 }