gallivm: Altivec pack/unpack intrisics
[mesa.git] / src / gallium / auxiliary / gallivm / lp_bld_printf.c
index 16ef25a8a39c39217296337c319f80599f868307..0de6a0882ba6eff0e660b1a240c058e3b99887a6 100644 (file)
@@ -83,8 +83,8 @@ lp_build_print_value(struct gallivm_state *gallivm,
    LLVMTypeKind type_kind;
    LLVMTypeRef type_ref;
    LLVMValueRef params[2 + LP_MAX_VECTOR_LENGTH];
-   char type_fmt[4] = " %x";
-   char format[2 + 3 * LP_MAX_VECTOR_LENGTH + 2] = "%s";
+   char type_fmt[6] = " %x";
+   char format[2 + 5 * LP_MAX_VECTOR_LENGTH + 2] = "%s";
    unsigned length;
    unsigned i;
 
@@ -101,7 +101,10 @@ lp_build_print_value(struct gallivm_state *gallivm,
    }
 
    if (type_kind == LLVMFloatTypeKind || type_kind == LLVMDoubleTypeKind) {
-      type_fmt[2] = 'f';
+      type_fmt[2] = '.';
+      type_fmt[3] = '9';
+      type_fmt[4] = 'g';
+      type_fmt[5] = '\0';
    } else if (type_kind == LLVMIntegerTypeKind) {
       if (LLVMGetIntTypeWidth(type_ref) == 8) {
          type_fmt[2] = 'u';
@@ -118,16 +121,16 @@ 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);
+      util_strncat(format, type_fmt, sizeof(format) - strlen(format) - 1);
       params[2] = value;
    } else {
       for (i = 0; i < length; ++i) {
-         util_strncat(format, type_fmt, sizeof format);
+         util_strncat(format, type_fmt, sizeof(format) - strlen(format) - 1);
          params[2 + i] = LLVMBuildExtractElement(builder, value, lp_build_const_int32(gallivm, i), "");
       }
    }
 
-   util_strncat(format, "\n", sizeof format);
+   util_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);