From 9850809890076f13bca3d5e6e0fcc050ad647c8d Mon Sep 17 00:00:00 2001 From: comex Date: Sun, 11 Jan 2015 19:39:23 -0500 Subject: Revert "C++ is just a giant pain in the ass" This reverts commit 4743027a22ae4e622d7e78f878eff307d02ac373. --- test/test-dis.c | 8 +++---- test/test-tdarm-simple.c | 52 ++++++++++++++++++++++++++++++++++++++++++++ test/test-tdarm-simple.cpp | 54 ---------------------------------------------- 3 files changed, 56 insertions(+), 58 deletions(-) create mode 100644 test/test-tdarm-simple.c delete mode 100644 test/test-tdarm-simple.cpp (limited to 'test') diff --git a/test/test-dis.c b/test/test-dis.c index 8b4a2b3..127b0b4 100644 --- a/test/test-dis.c +++ b/test/test-dis.c @@ -1,13 +1,13 @@ #include #include "dis.h" unsigned f(unsigned x) { - struct bitslice addr = {.nruns = 4, .runs = {{0,0,4}, {5,5,7}, {16,13,4}, {23,12,1}}}; - return bs_get(&addr, x); + struct bitslice addr = {.nruns = 4, .runs = (struct bitslice_run[]) {{0,0,4}, {5,5,7}, {16,13,4}, {23,12,1}}}; + return bs_get(addr, x); } unsigned fs(unsigned val, unsigned op) { - struct bitslice addr = {.nruns = 4, .runs = {{0,0,4}, {5,5,7}, {16,13,4}, {23,12,1}}}; - return bs_set(&addr, val, op); + struct bitslice addr = {.nruns = 4, .runs = (struct bitslice_run[]) {{0,0,4}, {5,5,7}, {16,13,4}, {23,12,1}}}; + return bs_set(addr, val, op); } int main() { diff --git a/test/test-tdarm-simple.c b/test/test-tdarm-simple.c new file mode 100644 index 0000000..99a5d4a --- /dev/null +++ b/test/test-tdarm-simple.c @@ -0,0 +1,52 @@ +#include +#include +#include +#include "dis.h" + +typedef void tdis_ret; +typedef struct tc { + uint32_t pc; + uint32_t op; + +} *tdis_ctx; +#define P(x) P_##x + +static void P_data(struct tc *ctx, struct dis_data_operand *ops, size_t nops) { + printf("data: %08x\n", ctx->op); + for(size_t i = 0; i < nops; i++) { + unsigned val = bs_get(ops[i].n, ctx->op); + printf(" {"); + for(int j = 0; j < ops[i].n.nruns; j++) { + struct bitslice_run run = ops[i].n.runs[j]; + printf(" %d:%d:%d", run.inpos, run.outpos, run.len); + } + printf(" } =>\n"); + printf(" reg %x: %s\n", val, ops[i].out ? "out" : "in"); + } + unsigned newop = ctx->op; + for(size_t i = 0; i < nops; i++) + newop = bs_set(ops[i].n, i, newop); + printf("modified: %x\n", newop); +} + +static void P_adr(struct tc *ctx, UNUSED uint32_t dpc) { + printf("adr: %08x\n", ctx->op); +} + +static void P_branch(struct tc *ctx, UNUSED uint32_t dpc) { + printf("branch: %08x\n", ctx->op); +} + +static void P_unidentified(struct tc *ctx) { + printf("unidentified: %08x\n", ctx->op); + +} +#include "dis-arm.inc.h" + +int main(UNUSED int argc, char **argv) { + struct tc ctx; + ctx.pc = 0xdead0000; + ctx.op = (uint32_t) strtoll(argv[1] ? argv[1] : "deadbeef", NULL, 16); + P_dis_arm(&ctx); + +} diff --git a/test/test-tdarm-simple.cpp b/test/test-tdarm-simple.cpp deleted file mode 100644 index d590ba8..0000000 --- a/test/test-tdarm-simple.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include -#include -#include -#include "dis.h" - -typedef void tdis_ret; -typedef struct tc { - uint32_t pc; - uint32_t op; - -} *tdis_ctx; -#define P(x) P_##x - -__attribute__((noinline)) -static void P_data(struct tc *ctx, struct dis_data_operand *ops, size_t nops) { - printf("data: %08x\n", ctx->op); - for(size_t i = 0; i < nops; i++) { - const struct bitslice *n = ops[i].n; - unsigned val = bs_get(n, ctx->op); - printf(" {"); - for(int j = 0; j < n->nruns; j++) { - struct bitslice_run run = n->runs[j]; - printf(" %d:%d:%d", run.inpos, run.outpos, run.len); - } - printf(" } =>\n"); - printf(" reg %x: %s\n", val, ops[i].out ? "out" : "in"); - } - unsigned newop = ctx->op; - for(size_t i = 0; i < nops; i++) - newop = bs_set(ops[i].n, i, newop); - printf("modified: %x\n", newop); -} - -static void P_adr(struct tc *ctx, UNUSED uint32_t dpc) { - printf("adr: %08x\n", ctx->op); -} - -static void P_branch(struct tc *ctx, UNUSED uint32_t dpc) { - printf("branch: %08x\n", ctx->op); -} - -static void P_unidentified(struct tc *ctx) { - printf("unidentified: %08x\n", ctx->op); - -} -#include "dis-arm.inc.h" - -int main(UNUSED int argc, char **argv) { - struct tc ctx; - ctx.pc = 0xdead0000; - ctx.op = (uint32_t) strtoll(argv[1] ? argv[1] : "deadbeef", NULL, 16); - P_dis_arm(&ctx); - -} -- cgit v1.2.3