X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Ftv%2Fstrcalc.c;h=dd2e6a3f277adcf13d7496b7211b566c807c700c;hb=93a3661e3fb02276b3ccc27db7ede68f708bd306;hp=d682979cd2a6e0a98bf35078da8ae1d50a4b3d03;hpb=ca0508a081617b4b04e9e9f85a6127bd01fad96c;p=libfirm diff --git a/ir/tv/strcalc.c b/ir/tv/strcalc.c index d682979cd..dd2e6a3f2 100644 --- a/ir/tv/strcalc.c +++ b/ir/tv/strcalc.c @@ -32,6 +32,7 @@ #include /* definition of LONG_MIN, used in sc_get_val_from_long */ #include "strcalc.h" +#include "xmalloc.h" /* * local definitions and macros @@ -76,7 +77,7 @@ static int carry_flag; /**< some computation set the carry_flag: However, the meaning of carry is machine dependent and often defined in other ways! */ -static const char sex_digit[4] = { SC_F, SC_E, SC_C, SC_8 }; +static const char sex_digit[4] = { SC_E, SC_C, SC_8, SC_0 }; static const char max_digit[4] = { SC_0, SC_1, SC_3, SC_7 }; static const char min_digit[4] = { SC_F, SC_E, SC_C, SC_8 }; @@ -962,7 +963,7 @@ int sc_get_buffer_length(void) * Do sign extension if the mode is signed, expects all upper bits * cleared. */ -static void sign_extend(char *calc_buffer, ir_mode *mode) { +void sign_extend(char *calc_buffer, ir_mode *mode) { if (mode_is_signed(mode)) { int bits = get_mode_size_bits(mode) - 1; int ofs = bits >> 2; @@ -974,7 +975,7 @@ static void sign_extend(char *calc_buffer, ir_mode *mode) { for (i = ofs + 1; i < calc_buffer_size; ++i) calc_buffer[i] = SC_F; - calc_buffer[ofs] = sex_digit[bits & 3]; + calc_buffer[ofs] = or_table[calc_buffer[ofs]][sex_digit[bits & 3]]; } } } @@ -1600,13 +1601,8 @@ void init_strcalc(int precision) calc_buffer_size = (precision / 2); max_value_size = (precision / 4); - calc_buffer = malloc(calc_buffer_size+1 * sizeof(char)); - output_buffer = malloc(bit_pattern_size+1 * sizeof(char)); - - if (calc_buffer == NULL || output_buffer == NULL) { - assert(0 && "malloc failed"); - exit(-1); - } + calc_buffer = xmalloc(calc_buffer_size+1 * sizeof(char)); + output_buffer = xmalloc(bit_pattern_size+1 * sizeof(char)); DEBUGPRINTF(("init strcalc: \n\tPRECISION: %d\n\tCALC_BUFFER_SIZE = %d\n\tMAX_VALUE_SIZE = %d\n\tbuffer pointer: %p\n", precision, calc_buffer_size, max_value_size, calc_buffer)); }