From fba298744a68d4478044bf2426413d3e247d9145 Mon Sep 17 00:00:00 2001 From: Avril Date: Thu, 26 Nov 2020 17:40:28 +0000 Subject: [PATCH] added work parse --- lean/include/work.h | 4 +++- lean/src/main.c | 1 + lean/src/work.cpp | 42 ++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/lean/include/work.h b/lean/include/work.h index 2992a7a..f608752 100644 --- a/lean/include/work.h +++ b/lean/include/work.h @@ -17,6 +17,8 @@ typedef struct { OP_UNSHUFFLE_IP, // Unshuffle in place OP_UNSHUFFLE_OP, // Unshuffle out of place + + OP_HELP, // Print help then exit } op; union { struct { @@ -41,7 +43,7 @@ typedef struct { } data; } work_args_t; -int do_work(work_args_t args); +int do_work(const work_args_t args); #ifdef __cplusplus } diff --git a/lean/src/main.c b/lean/src/main.c index 2452690..94b8681 100644 --- a/lean/src/main.c +++ b/lean/src/main.c @@ -29,6 +29,7 @@ static void unshuffle_file(const char* filename) panic("unimplemented"); }*/ +//XXX: Not using this anymore static void* map_callback(mmap_t map, void* user) { struct prog_args args = *(struct prog_args*)user; diff --git a/lean/src/work.cpp b/lean/src/work.cpp index f0cf1b0..e50a670 100644 --- a/lean/src/work.cpp +++ b/lean/src/work.cpp @@ -1,8 +1,46 @@ #include #include +#include -extern "C" int do_work(work_args_t args) +namespace work { - //TODO: Delegate work + /// Shuffle or unshuffle in place + template + int xshuffle_ip(const char* file) + { + return 0; + } + + /// Shuffle or unshuffle out of place + template + int xshuffle_op(const char* ifile, const char* ofile, bool is_buffered) + { + return 0; + } + +} + +int help() +{ + //Print help then exit + return 1; +} + +extern "C" int do_work(const work_args_t args) +{ + using A = decltype(args.op); + switch (args.op) { + case A::OP_SHUFFLE_IP: return work::xshuffle_ip(args.data.op_shuffle_ip.file); + case A::OP_SHUFFLE_OP: return work::xshuffle_op(args.data.op_shuffle_op.ifile, + args.data.op_shuffle_op.ofile, + args.data.op_shuffle_op.buffered == WORK_BO_BUFFERED); + case A::OP_UNSHUFFLE_IP: return work::xshuffle_ip(args.data.op_unshuffle_ip.file); + case A::OP_UNSHUFFLE_OP: return work::xshuffle_op(args.data.op_unshuffle_op.ifile, + args.data.op_unshuffle_op.ofile, + args.data.op_unshuffle_op.buffered == WORK_BO_BUFFERED); + case A::OP_HELP: return help(); + + default: panic("Unknown op %d", (int)args.op); + } return 0; }