Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Zwinkau
libfirm
Commits
186cf32a
Commit
186cf32a
authored
Jan 15, 2010
by
Christoph Mallon
Browse files
Replace the shift_table[] by a simple macro.
[r26974]
parent
7cbf2ffb
Changes
1
Hide whitespace changes
Inline
Side-by-side
ir/tv/strcalc.c
View file @
186cf32a
...
...
@@ -40,9 +40,10 @@
* 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__)
...
...
@@ -84,8 +85,6 @@ static const char zex_digit[4] = { SC_1, SC_3, SC_7, SC_F };
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
},
...
...
@@ -619,7 +618,7 @@ static void do_shl(const char *val1, char *buffer, long shift_cnt, int bitsize,
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)
...
...
@@ -1130,7 +1129,7 @@ int sc_get_bit_at(const void *value, unsigned pos) {
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
)
...
...
@@ -1138,7 +1137,7 @@ 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
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment