Mesa (master): gallivm: Use %.9g to print floats.

Jose Fonseca jrfonseca at kemper.freedesktop.org
Thu Jul 12 20:15:03 UTC 2012


Module: Mesa
Branch: master
Commit: 978807ef0153be27e4df19691e3d5f7d7a2a472b
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=978807ef0153be27e4df19691e3d5f7d7a2a472b

Author: José Fonseca <jfonseca at vmware.com>
Date:   Wed Jul 11 20:23:52 2012 +0100

gallivm: Use %.9g to print floats.

So that we can see them in their full denormalized glory.

Reviewed-by: Roland Scheidegger <sroland at vmware.com>

---

 src/gallium/auxiliary/gallivm/lp_bld_printf.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_printf.c b/src/gallium/auxiliary/gallivm/lp_bld_printf.c
index 8549b87..0de6a08 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_printf.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_printf.c
@@ -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';




More information about the mesa-commit mailing list