fixed different types
[libfirm] / ir / tv / strcalc.c
index b2ac72e..2fe8df0 100644 (file)
 # include "config.h"
 #endif
 
-
-#include "strcalc.h"
-
-#include <stdlib.h>
+#ifdef HAVE_STDLIB_H
+# include <stdlib.h>
+#endif
 #ifdef HAVE_ALLOCA_H
 # include <alloca.h>
 #endif
 #ifdef HAVE_MALLOC_H
 # include <malloc.h>
 #endif
+#ifdef HAVE_STRING_H
+# include <string.h>  /* memset/memcmp */
+#endif
 #include <assert.h>   /* assertions */
-#include <string.h>   /* memset/memcmp */
 #include <stdio.h>    /* output for error messages */
 #include <limits.h>   /* definition of LONG_MIN, used in sc_get_val_from_long */
 
+#include "strcalc.h"
+
 /*
  * local definitions and macros
  */
@@ -1153,22 +1156,14 @@ void sc_val_from_ulong(unsigned long value, void *buffer)
   }
 }
 
-long sc_val_to_long(const void *val, unsigned int bits, unsigned int is_signed)
+long sc_val_to_long(const void *val)
 {
   int i;
   long l = 0;
 
   for (i = CALC_BUFFER_SIZE - 1; i >= 0; i--)
+  {
     l = (l << 4) + _val(((char *)val)[i]);
-
-  if (bits < (sizeof(long) << 3)) {
-    /* remove unused bits */
-    l &= ~((-1) << bits);
-
-    /* sign extend */
-    if (is_signed)
-      if (l & (1 << (bits-1)))
-        l |= ((-1) << bits);
   }
   return l;
 }
@@ -1287,7 +1282,7 @@ void sc_bitcalc(const void* value1, const void* value2, int radius, int sign, un
   long offset;
 
   carry_flag = 0;
-  offset = sc_val_to_long(val2, radius, sign);
+  offset = sc_val_to_long(val2);
 
   DEBUGPRINTF_COMPUTATION(("%s ", sc_print_hex(value1)));
   switch (op)