mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-31 06:16:03 +00:00
Add basic controls for dfa optimization
This commit is contained in:
@@ -159,6 +159,7 @@ static void display_usage(char *command)
|
||||
"-V, --version Display version info and exit\n"
|
||||
"-d, --debug Debug apparmor definitions\n"
|
||||
"-D [n], --dump Dump internal info for debugging\n"
|
||||
"-O [n], --Optimize Control dfa optimizations\n"
|
||||
"-h [command], --help Display this text or info about command\n"
|
||||
,command);
|
||||
}
|
||||
@@ -187,6 +188,24 @@ static void display_dump(char *command)
|
||||
,command);
|
||||
}
|
||||
|
||||
static void display_optimize(char *command)
|
||||
{
|
||||
display_version();
|
||||
printf("\n%s: -O [Option]\n\n"
|
||||
"Options:\n"
|
||||
"--------\n"
|
||||
"0 no optimizations\n"
|
||||
"equiv use equivalent classes\n"
|
||||
"no-equiv don't use equivalent classes\n"
|
||||
"expr-normalize do expr normalization\n"
|
||||
"expr-simplify do expr tree simplification\n"
|
||||
"no-expr-normalize don't do expr normalization\n"
|
||||
"no-expr-simplify don't do expr tree simplification\n"
|
||||
"expr-left-simplify do left simplification first\n"
|
||||
"expr-right-simplify do right simplification first\n"
|
||||
,command);
|
||||
}
|
||||
|
||||
void pwarn(char *fmt, ...)
|
||||
{
|
||||
va_list arg;
|
||||
@@ -216,7 +235,7 @@ static int process_args(int argc, char *argv[])
|
||||
int count = 0;
|
||||
option = OPTION_ADD;
|
||||
|
||||
while ((c = getopt_long(argc, argv, "adf:h::rRVvI:b:BCD:NSm:qQn:XKTWk", long_options, &o)) != -1)
|
||||
while ((c = getopt_long(argc, argv, "adf:h::rRVvI:b:BCD:NSm:qQn:XKTWkO:", long_options, &o)) != -1)
|
||||
{
|
||||
switch (c) {
|
||||
case 0:
|
||||
@@ -319,6 +338,29 @@ static int process_args(int argc, char *argv[])
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
case 'O':
|
||||
skip_cache = 1;
|
||||
if (strcmp(optarg, "0") == 0) {
|
||||
dfaflags |= DFA_CONTROL_NO_TREE_NORMAL |
|
||||
DFA_CONTROL_NO_TREE_SIMPLE;
|
||||
} else if (strcmp(optarg, "equiv") == 0) {
|
||||
dfaflags |= DFA_CONTROL_EQUIV;
|
||||
} else if (strcmp(optarg, "no-equiv") == 0) {
|
||||
dfaflags &= ~DFA_CONTROL_EQUIV;
|
||||
} else if (strcmp(optarg, "expr-normalize") == 0) {
|
||||
dfaflags &= ~DFA_CONTROL_NO_TREE_NORMAL;
|
||||
} else if (strcmp(optarg, "no-expr-normalize") == 0) {
|
||||
dfaflags |= DFA_CONTROL_NO_TREE_NORMAL;
|
||||
} else if (strcmp(optarg, "expr-simplify") == 0) {
|
||||
dfaflags &= ~DFA_CONTROL_NO_TREE_SIMPLE;
|
||||
} else if (strcmp(optarg, "no-expr-simplify") == 0) {
|
||||
dfaflags |= DFA_CONTROL_NO_TREE_SIMPLE;
|
||||
} else if (strcmp(optarg, "expr-left-simplify") == 0) {
|
||||
dfaflags |= DFA_CONTROL_TREE_LEFT;
|
||||
} else if (strcmp(optarg, "expr-right-simplify") == 0) {
|
||||
dfaflags &= ~DFA_CONTROL_TREE_LEFT;
|
||||
}
|
||||
break;
|
||||
case 'm':
|
||||
match_string = strdup(optarg);
|
||||
break;
|
||||
|
Reference in New Issue
Block a user