src: more clang-format

This commit is contained in:
Markus F.X.J. Oberhumer
2023-10-05 11:53:02 +02:00
parent 632c7c4826
commit e767461f65
23 changed files with 733 additions and 1191 deletions
+56 -83
View File
@@ -25,145 +25,118 @@
<markus@oberhumer.com> <ezerotven+github@gmail.com>
*/
/*************************************************************************
// 16-bit call-/swaptrick ("naive")
**************************************************************************/
#define CTSW16(f, cond1, cond2, addvalue, get, set) \
byte *b = f->buf; \
byte *b_end = b + f->buf_len - 3; \
do { \
if (cond1) \
{ \
b += 1; \
unsigned a = (unsigned) (b - f->buf); \
f->lastcall = a; \
set(b, get(b) + (addvalue)); \
f->calls++; \
b += 2 - 1; \
} \
else if (cond2) \
{ \
b += 1; \
unsigned a = (unsigned) (b - f->buf); \
f->lastcall = a; \
set(b, get(b)); \
f->calls++; \
b += 2 - 1; \
} \
} while (++b < b_end); \
if (f->lastcall) f->lastcall += 2; \
#define CTSW16(f, cond1, cond2, addvalue, get, set) \
byte *b = f->buf; \
byte *b_end = b + f->buf_len - 3; \
do { \
if (cond1) { \
b += 1; \
unsigned a = (unsigned) (b - f->buf); \
f->lastcall = a; \
set(b, get(b) + (addvalue)); \
f->calls++; \
b += 2 - 1; \
} else if (cond2) { \
b += 1; \
unsigned a = (unsigned) (b - f->buf); \
f->lastcall = a; \
set(b, get(b)); \
f->calls++; \
b += 2 - 1; \
} \
} while (++b < b_end); \
if (f->lastcall) \
f->lastcall += 2; \
return 0;
// filter
static int f_ctsw16_e8_e9(Filter *f)
{
static int f_ctsw16_e8_e9(Filter *f) {
CTSW16(f, (*b == 0xe8), (*b == 0xe9), a + f->addvalue, get_le16, set_be16)
}
static int f_ctsw16_e9_e8(Filter *f)
{
static int f_ctsw16_e9_e8(Filter *f) {
CTSW16(f, (*b == 0xe9), (*b == 0xe8), a + f->addvalue, get_le16, set_be16)
}
// unfilter
static int u_ctsw16_e8_e9(Filter *f)
{
static int u_ctsw16_e8_e9(Filter *f) {
CTSW16(f, (*b == 0xe8), (*b == 0xe9), 0 - a - f->addvalue, get_be16, set_le16)
}
static int u_ctsw16_e9_e8(Filter *f)
{
static int u_ctsw16_e9_e8(Filter *f) {
CTSW16(f, (*b == 0xe9), (*b == 0xe8), 0 - a - f->addvalue, get_be16, set_le16)
}
// scan
static int s_ctsw16_e8_e9(Filter *f)
{
static int s_ctsw16_e8_e9(Filter *f) {
CTSW16(f, (*b == 0xe8), (*b == 0xe9), a + f->addvalue, get_le16, set_dummy)
}
static int s_ctsw16_e9_e8(Filter *f)
{
static int s_ctsw16_e9_e8(Filter *f) {
CTSW16(f, (*b == 0xe9), (*b == 0xe8), a + f->addvalue, get_le16, set_dummy)
}
#undef CTSW16
/*************************************************************************
// 32-bit call-/swaptrick ("naive")
**************************************************************************/
#define CTSW32(f, cond1, cond2, addvalue, get, set) \
byte *b = f->buf; \
byte *b_end = b + f->buf_len - 5; \
do { \
if (cond1) \
{ \
b += 1; \
unsigned a = (unsigned) (b - f->buf); \
f->lastcall = a; \
set(b, get(b) + (addvalue)); \
f->calls++; \
b += 4 - 1; \
} \
else if (cond2) \
{ \
b += 1; \
unsigned a = (unsigned) (b - f->buf); \
f->lastcall = a; \
set(b, get(b)); \
f->calls++; \
b += 4 - 1; \
} \
} while (++b < b_end); \
if (f->lastcall) f->lastcall += 4; \
#define CTSW32(f, cond1, cond2, addvalue, get, set) \
byte *b = f->buf; \
byte *b_end = b + f->buf_len - 5; \
do { \
if (cond1) { \
b += 1; \
unsigned a = (unsigned) (b - f->buf); \
f->lastcall = a; \
set(b, get(b) + (addvalue)); \
f->calls++; \
b += 4 - 1; \
} else if (cond2) { \
b += 1; \
unsigned a = (unsigned) (b - f->buf); \
f->lastcall = a; \
set(b, get(b)); \
f->calls++; \
b += 4 - 1; \
} \
} while (++b < b_end); \
if (f->lastcall) \
f->lastcall += 4; \
return 0;
// filter
static int f_ctsw32_e8_e9(Filter *f)
{
static int f_ctsw32_e8_e9(Filter *f) {
CTSW32(f, (*b == 0xe8), (*b == 0xe9), a + f->addvalue, get_le32, set_be32)
}
static int f_ctsw32_e9_e8(Filter *f)
{
static int f_ctsw32_e9_e8(Filter *f) {
CTSW32(f, (*b == 0xe9), (*b == 0xe8), a + f->addvalue, get_le32, set_be32)
}
// unfilter
static int u_ctsw32_e8_e9(Filter *f)
{
static int u_ctsw32_e8_e9(Filter *f) {
CTSW32(f, (*b == 0xe8), (*b == 0xe9), 0 - a - f->addvalue, get_be32, set_le32)
}
static int u_ctsw32_e9_e8(Filter *f)
{
static int u_ctsw32_e9_e8(Filter *f) {
CTSW32(f, (*b == 0xe9), (*b == 0xe8), 0 - a - f->addvalue, get_be32, set_le32)
}
// scan
static int s_ctsw32_e8_e9(Filter *f)
{
static int s_ctsw32_e8_e9(Filter *f) {
CTSW32(f, (*b == 0xe8), (*b == 0xe9), a + f->addvalue, get_le32, set_dummy)
}
static int s_ctsw32_e9_e8(Filter *f)
{
static int s_ctsw32_e9_e8(Filter *f) {
CTSW32(f, (*b == 0xe9), (*b == 0xe8), a + f->addvalue, get_le32, set_dummy)
}
#undef CTSW32
/* vim:set ts=4 sw=4 et: */