mesa: set up gl_vert_result and gl_frag_attrib values for gl_ClipDistance.
[mesa.git] / src / glsl / ralloc.c
index e92f433e336077df46596eb5370a7a56def61897..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__
 #define unlikely(x)     !!(x)
 #endif
 
+#ifndef va_copy
+#ifdef __va_copy
+#define va_copy(dest, src) __va_copy((dest), (src))
+#else
+#define va_copy(dest, src) (dest) = (src)
+#endif
+#endif
+
 #define CANARY 0x5A1106
 
 struct ralloc_header
@@ -384,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;
 }