diff options
Diffstat (limited to 'package/config/patches/09-implement-kconfig-probability.patch')
-rw-r--r-- | package/config/patches/09-implement-kconfig-probability.patch | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/package/config/patches/09-implement-kconfig-probability.patch b/package/config/patches/09-implement-kconfig-probability.patch new file mode 100644 index 000000000..7adfc0b17 --- /dev/null +++ b/package/config/patches/09-implement-kconfig-probability.patch @@ -0,0 +1,43 @@ +--- + confdata.c | 21 +++++++++++++++++++-- + 1 file changed, 19 insertions(+), 2 deletions(-) + +Index: config.clean/confdata.c +=================================================================== +--- config.clean.orig/confdata.c ++++ config.clean/confdata.c +@@ -812,7 +812,16 @@ + struct symbol *sym, *csym; + struct property *prop; + struct expr *e; +- int i, cnt, def; ++ int i, cnt, def, prob = 50; ++ ++ if (mode == def_random) { ++ char *endp, *env = getenv("KCONFIG_PROBABILITY"); ++ if (env && *env) { ++ int tmp = (int)strtol(env, &endp, 10); ++ if (*endp == '\0' && tmp >= 0 && tmp <= 100) ++ prob = tmp; ++ } ++ } + + for_all_symbols(i, sym) { + if (sym_has_value(sym)) +@@ -831,7 +840,15 @@ + sym->def[S_DEF_USER].tri = no; + break; + case def_random: +- sym->def[S_DEF_USER].tri = (tristate)(rand() % 3); ++ cnt = (rand() % 100) - (100 - prob); ++ if (cnt < 0) ++ sym->def[S_DEF_USER].tri = no; ++ else ++ if ((sym_get_type(sym) == S_TRISTATE) ++ && (cnt > prob/2)) ++ sym->def[S_DEF_USER].tri = mod; ++ else ++ sym->def[S_DEF_USER].tri = yes; + break; + default: + continue; |