added work parse

lean
Avril 4 years ago
parent e701f96b37
commit fba298744a
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -17,6 +17,8 @@ typedef struct {
OP_UNSHUFFLE_IP, // Unshuffle in place OP_UNSHUFFLE_IP, // Unshuffle in place
OP_UNSHUFFLE_OP, // Unshuffle out of place OP_UNSHUFFLE_OP, // Unshuffle out of place
OP_HELP, // Print help then exit
} op; } op;
union { union {
struct { struct {
@ -41,7 +43,7 @@ typedef struct {
} data; } data;
} work_args_t; } work_args_t;
int do_work(work_args_t args); int do_work(const work_args_t args);
#ifdef __cplusplus #ifdef __cplusplus
} }

@ -29,6 +29,7 @@ static void unshuffle_file(const char* filename)
panic("unimplemented"); panic("unimplemented");
}*/ }*/
//XXX: Not using this anymore
static void* map_callback(mmap_t map, void* user) static void* map_callback(mmap_t map, void* user)
{ {
struct prog_args args = *(struct prog_args*)user; struct prog_args args = *(struct prog_args*)user;

@ -1,8 +1,46 @@
#include <shuffle3.h> #include <shuffle3.h>
#include <work.h> #include <work.h>
#include <panic.h>
extern "C" int do_work(work_args_t args) namespace work
{ {
//TODO: Delegate work /// Shuffle or unshuffle in place
template<bool unshuffle>
int xshuffle_ip(const char* file)
{
return 0;
}
/// Shuffle or unshuffle out of place
template<bool unshuffle>
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<false >(args.data.op_shuffle_ip.file);
case A::OP_SHUFFLE_OP: return work::xshuffle_op<false >(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<true >(args.data.op_unshuffle_ip.file);
case A::OP_UNSHUFFLE_OP: return work::xshuffle_op<true>(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; return 0;
} }

Loading…
Cancel
Save