util: use standard name for snprintf()
[mesa.git] / src / gallium / auxiliary / gallivm / lp_bld_printf.c
index 7a6bbd960bee1331aa0e6c05455ecb0bab8a4179..a4233a24e3317cc98f0c1cb3afe60cdc73258826 100644 (file)
@@ -26,6 +26,7 @@
  **************************************************************************/
 
 #include <stdio.h>
+#include <inttypes.h>
 
 #include "util/u_debug.h"
 #include "util/u_memory.h"
@@ -106,11 +107,15 @@ lp_build_print_value(struct gallivm_state *gallivm,
       type_fmt[4] = 'g';
       type_fmt[5] = '\0';
    } else if (type_kind == LLVMIntegerTypeKind) {
-      if (LLVMGetIntTypeWidth(type_ref) == 8) {
+      if (LLVMGetIntTypeWidth(type_ref) == 64) {
+         snprintf(type_fmt + 2, 3, "%s", PRId64);
+      } else if (LLVMGetIntTypeWidth(type_ref) == 8) {
          type_fmt[2] = 'u';
       } else {
          type_fmt[2] = 'i';
       }
+   } else if (type_kind == LLVMPointerTypeKind) {
+      type_fmt[2] = 'p';
    } else {
       /* Unsupported type */
       assert(0);
@@ -121,12 +126,12 @@ lp_build_print_value(struct gallivm_state *gallivm,
 
    params[1] = lp_build_const_string(gallivm, msg);
    if (length == 1) {
-      util_strncat(format, type_fmt, sizeof(format) - strlen(format) - 1);
+      strncat(format, type_fmt, sizeof(format) - strlen(format) - 1);
       params[2] = value;
    } else {
       for (i = 0; i < length; ++i) {
          LLVMValueRef param;
-         util_strncat(format, type_fmt, sizeof(format) - strlen(format) - 1);
+         strncat(format, type_fmt, sizeof(format) - strlen(format) - 1);
          param = LLVMBuildExtractElement(builder, value, lp_build_const_int32(gallivm, i), "");
          if (type_kind == LLVMIntegerTypeKind &&
              LLVMGetIntTypeWidth(type_ref) < sizeof(int) * 8) {
@@ -141,17 +146,17 @@ lp_build_print_value(struct gallivm_state *gallivm,
       }
    }
 
-   util_strncat(format, "\n", sizeof(format) - strlen(format) - 1);
+   strncat(format, "\n", sizeof(format) - strlen(format) - 1);
 
    params[0] = lp_build_const_string(gallivm, format);
    return lp_build_print_args(gallivm, 2 + length, params);
 }
 
 
-static int
+static unsigned
 lp_get_printf_arg_count(const char *fmt)
 {
-   int count =0;
+   unsigned count = 0;
    const char *p = fmt;
    int c;
 
@@ -188,11 +193,10 @@ lp_build_printf(struct gallivm_state *gallivm,
 {
    LLVMValueRef params[50];
    va_list arglist;
-   int argcount;
-   int i;
+   unsigned argcount, i;
 
    argcount = lp_get_printf_arg_count(fmt);
-   assert(Elements(params) >= argcount + 1);
+   assert(ARRAY_SIZE(params) >= argcount + 1);
 
    va_start(arglist, fmt);
    for (i = 1; i <= argcount; i++) {