X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Ftv%2Ffltcalc.c;h=aaec0484dfe4e23a51a0d2964f6a1f82b22c00db;hb=d566f952dd686c0afda6d9e4cd967c5c67651d9c;hp=7c5d6fdd15a1eed8f34c49b0d1db5674254e7965;hpb=b6fdc7afc1225aaa375e1663bd5337562b1c7519;p=libfirm diff --git a/ir/tv/fltcalc.c b/ir/tv/fltcalc.c index 7c5d6fdd1..aaec0484d 100644 --- a/ir/tv/fltcalc.c +++ b/ir/tv/fltcalc.c @@ -1,21 +1,34 @@ /* - * Project: libFIRM - * File name: ir/tv/fltcalc.c - * Purpose: - * Author: - * Modified by: - * Created: 2003 - * CVS-ID: $Id$ - * Copyright: (c) 2003 Universität Karlsruhe - * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE. + * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved. + * + * This file is part of libFirm. + * + * This file may be distributed and/or modified under the terms of the + * GNU General Public License version 2 as published by the Free Software + * Foundation and appearing in the file LICENSE.GPL included in the + * packaging of this file. + * + * Licensees holding valid libFirm Professional Edition licenses may use + * this file in accordance with the libFirm Commercial License. + * Agreement provided with the Software. + * + * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE + * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. */ +/** + * @file + * @brief tarval floating point calculations + * @date 2003 + * @author Mathias Heil + * @version $Id$ + */ #ifdef HAVE_CONFIG_H # include "config.h" #endif - #include "fltcalc.h" #include "strcalc.h" @@ -34,12 +47,6 @@ #ifdef HAVE_STDLIB_H # include #endif -#ifdef HAVE_ALLOCA_H -# include -#endif -#ifdef HAVE_MALLOC_H -# include -#endif #include #include @@ -711,6 +718,7 @@ static char* _fdiv(const char* a, const char* b, char* result) return _normalize(result, result, sc_had_carry()); } +#if 0 static void _power_of_ten(int exp, descriptor_t *desc, char *result) { char *build; @@ -748,6 +756,7 @@ static void _power_of_ten(int exp, descriptor_t *desc, char *result) _normalize(result, result, 0); } } +#endif /** * Truncate the fractional part away. @@ -1528,7 +1537,8 @@ char *fc_print(const void *a, char *buf, int buflen, unsigned base) case FC_PACKED: default: - snprintf(buf, buflen, "%s", sc_print(_pack(val, mul_1), value_size*4, SC_HEX)); + snprintf(buf, buflen, "%s", sc_print(_pack(val, mul_1), value_size*4, SC_HEX, 0)); + buf[buflen - 1] = '\0'; break; } return buf; @@ -1583,6 +1593,7 @@ void init_fltcalc(int precision) calc_buffer_size = DESCRIPTOR_POS + sizeof(descriptor_t); calc_buffer = xmalloc(calc_buffer_size); + memset(calc_buffer, 0, calc_buffer_size); DEBUGPRINTF(("init fltcalc:\n\tVALUE_SIZE = %d\n\tSIGN_POS = %d\n\tEXPONENT_POS = %d\n\tMANTISSA_POS = %d\n\tDESCRIPTOR_POS = %d\n\tCALC_BUFFER_SIZE = %d\n\tcalc_buffer = %p\n\n", value_size, SIGN_POS, EXPONENT_POS, MANTISSA_POS, DESCRIPTOR_POS, calc_buffer_size, calc_buffer)); #ifdef HAVE_LONG_DOUBLE DEBUGPRINTF(("\tUsing long double (1-15-64) interface\n"));