create m5ops.cpp to count instructions before main

C++ has 2M while C has 100k.
This commit is contained in:
Ciro Santilli 六四事件 法轮功
2019-12-17 00:00:01 +00:00
parent ab6f733140
commit 5e39c1b911
2 changed files with 57 additions and 9 deletions

29
userland/cpp/m5ops.cpp Normal file
View File

@@ -0,0 +1,29 @@
/* https://cirosantilli.com/linux-kernel-module-cheat#m5ops-instructions */
#include <lkmc/m5ops.h>
int main(int argc, char **argv) {
char action;
if (argc > 1) {
action = argv[1][0];
} else {
action = 'e';
}
switch (action) {
case 'c':
LKMC_M5OPS_CHECKPOINT;
break;
case 'd':
LKMC_M5OPS_DUMPSTATS;
break;
case 'e':
LKMC_M5OPS_EXIT;
break;
case 'f':
LKMC_M5OPS_FAIL_1;
break;
case 'r':
LKMC_M5OPS_RESETSTATS;
break;
}
}