* local definitions and macros
*/
#define CLEAR_BUFFER(b) assert(b); memset(b, SC_0, calc_buffer_size)
+#define SHIFT(count) (SC_1 << (count))
#define _val(a) ((a)-SC_0)
#define _digit(a) ((a)+SC_0)
-#define _bitisset(digit, pos) ((digit & shift_table[pos]) != SC_0)
+#define _bitisset(digit, pos) (((digit) & SHIFT(pos)) != SC_0)
#define fail_char(a, b, c, d) _fail_char((a), (b), (c), (d), __FILE__, __LINE__)
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 };
-static const char shift_table[4] = { SC_1, SC_2, SC_4, SC_8 };
-
static char const add_table[16][16][2] = {
{ {SC_0, SC_0}, {SC_1, SC_0}, {SC_2, SC_0}, {SC_3, SC_0},
{SC_4, SC_0}, {SC_5, SC_0}, {SC_6, SC_0}, {SC_7, SC_0},
return;
}
- shift = shift_table[_val(shift_cnt%4)]; /* this is 2 ** (offset % 4) */
+ shift = SHIFT(shift_cnt % 4); /* this is 2 ** (offset % 4) */
shift_cnt = shift_cnt / 4;
/* shift the single digits some bytes (offset) and some bits (table)
const char *val = value;
unsigned nibble = pos >> 2;
- return (val[nibble] & shift_table[pos & 3]) != SC_0;
+ return (val[nibble] & SHIFT(pos & 3)) != SC_0;
}
void sc_set_bit_at(void *value, unsigned pos)
char *val = value;
unsigned nibble = pos >> 2;
- val[nibble] |= shift_table[pos & 3];
+ val[nibble] |= SHIFT(pos & 3);
}
int sc_is_zero(const void *value) {