Skip to content

Commit

Permalink
Sync kconfig files with upstream 4.15
Browse files Browse the repository at this point in the history
Last updated with 4.9-rc7.
This commit introduces the following upstream changes:

9059a3493efe kconfig: fix relational operators for bool and tristate symbols
88127dae6ed9 kconfig/symbol.c: use correct pointer type argument for sizeof
b24413180f56 License cleanup: add SPDX GPL-2.0 license identifier to files with no license
bb3290d91695 Remove gperf usage from toolchain
ad8181060788 kconfig: fix sparse warnings in nconfig
ff85a1a80e00 kconfig: Check for libncurses before menuconfig
9be3213b14d4 gconfig: remove misleading parentheses around a condition
83c3a1bad224 xconfig: fix missing suboption and help panels on first run
e039303ff71a xconfig: fix 'Show Debug' functionality
79e51b5c2dee kconfig/nconf: Fix hang when editing symbol with a long prompt
0eb47346968f Scripts: kconfig: nconf: fix _GNU_SOURCE redefined warning
237e3ad0f195 Kconfig: Introduce the "imply" keyword

Signed-off-by: Bryan Hundven <bryanhundven@gmail.com>
  • Loading branch information
bhundven committed Feb 1, 2018
1 parent ba165ed commit 59b08f8
Show file tree
Hide file tree
Showing 17 changed files with 174 additions and 98 deletions.
1 change: 0 additions & 1 deletion kconfig/.gitignore
Expand Up @@ -3,7 +3,6 @@ conf
*.o
*.dep
zconf.lex.c
zconf.hash.c
zconf.tab.c
*.exe
Makefile
12 changes: 4 additions & 8 deletions kconfig/Makefile.in
Expand Up @@ -11,8 +11,7 @@ all: $(PROGS)
@true # Just be silent, you fscking son of a fscking beach...

# Build flags
CFLAGS = -DCONFIG_=\"CT_\" -DPACKAGE="\"crosstool-NG $(VERSION)\"" \
-DGPERF_LEN_TYPE="$(gperf_len_type)"
CFLAGS = -DCONFIG_=\"CT_\" -DPACKAGE="\"crosstool-NG $(VERSION)\""
LDFLAGS = $(INTL_LIBS)

ifneq (@DPKG_BUILDFLAGS@,)
Expand Down Expand Up @@ -78,16 +77,13 @@ DEPS += $(nconf_DEP)
$(call __silent,DEP,$@)$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -MM $< |$(sed) -r -e 's|([^:]+.o)( *:+)|$(<:.c=.o) $@\2|;' >$@

# Generate the grammar parser
zconf.tab.o: zconf.tab.c zconf.hash.c zconf.lex.c
zconf.tab.dep: zconf.tab.c zconf.hash.c zconf.lex.c
zconf.tab.o: zconf.tab.c zconf.lex.c
zconf.tab.dep: zconf.tab.c zconf.lex.c

.PRECIOUS: zconf.tab.c
zconf.tab.c: zconf.y
$(call __silent,BISON)bison -l -b zconf -p zconf $<

zconf.hash.c: zconf.gperf
$(call __silent,GPERF)$(gperf) -C < $< > $@

zconf.lex.c: zconf.l
$(call __silent,LEX)flex -L -Pzconf -o$@ $<

Expand Down Expand Up @@ -121,4 +117,4 @@ install-kconfig.mk: kconfig.mk
clean:
$(call __silent,RM,objs)rm -f $(ALL_OBJS) $(ALL_DEPS)
$(call __silent_rm,$(PROGS))
$(call __silent_rm,zconf.tab.c zconf.hash.c zconf.lex.c lex.backup)
$(call __silent_rm,zconf.tab.c zconf.lex.c lex.backup)
1 change: 1 addition & 0 deletions kconfig/check.sh
@@ -1,4 +1,5 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# Needed for systems without gettext
$* -x c -o /dev/null - > /dev/null 2>&1 << EOF
#include <libintl.h>
Expand Down
1 change: 1 addition & 0 deletions kconfig/conf.c
Expand Up @@ -538,6 +538,7 @@ int main(int ac, char **av)
}
if (ac == optind) {
printf(_("%s: Kconfig file missing\n"), av[0]);
fprintf(stderr, _("See README for usage info\n"));
exit(1);
}
name = av[optind];
Expand Down
5 changes: 4 additions & 1 deletion kconfig/expr.c
Expand Up @@ -893,7 +893,10 @@ static enum string_value_kind expr_parse_string(const char *str,
switch (type) {
case S_BOOLEAN:
case S_TRISTATE:
return k_string;
val->s = !strcmp(str, "n") ? 0 :
!strcmp(str, "m") ? 1 :
!strcmp(str, "y") ? 2 : -1;
return k_signed;
case S_INT:
val->s = strtoll(str, &tail, 10);
kind = k_signed;
Expand Down
2 changes: 2 additions & 0 deletions kconfig/expr.h
Expand Up @@ -85,6 +85,7 @@ struct symbol {
struct property *prop;
struct expr_value dir_dep;
struct expr_value rev_dep;
struct expr_value implied;
};

#define for_all_symbols(i, sym) for (i = 0; i < SYMBOL_HASHSIZE; i++) for (sym = symbol_hash[i]; sym; sym = sym->next) if (sym->type != S_OTHER)
Expand Down Expand Up @@ -136,6 +137,7 @@ enum prop_type {
P_DEFAULT, /* default y */
P_CHOICE, /* choice value */
P_SELECT, /* select BAR */
P_IMPLY, /* imply BAR */
P_RANGE, /* range 7..100 (for a symbol) */
P_ENV, /* value from environment variable */
P_SYMBOL, /* where a symbol is defined */
Expand Down
54 changes: 54 additions & 0 deletions kconfig/kconf_id.c
@@ -0,0 +1,54 @@

static struct kconf_id kconf_id_array[] = {
{ "mainmenu", T_MAINMENU, TF_COMMAND },
{ "menu", T_MENU, TF_COMMAND },
{ "endmenu", T_ENDMENU, TF_COMMAND },
{ "source", T_SOURCE, TF_COMMAND },
{ "choice", T_CHOICE, TF_COMMAND },
{ "endchoice", T_ENDCHOICE, TF_COMMAND },
{ "comment", T_COMMENT, TF_COMMAND },
{ "config", T_CONFIG, TF_COMMAND },
{ "menuconfig", T_MENUCONFIG, TF_COMMAND },
{ "help", T_HELP, TF_COMMAND },
{ "---help---", T_HELP, TF_COMMAND },
{ "if", T_IF, TF_COMMAND|TF_PARAM },
{ "endif", T_ENDIF, TF_COMMAND },
{ "depends", T_DEPENDS, TF_COMMAND },
{ "optional", T_OPTIONAL, TF_COMMAND },
{ "default", T_DEFAULT, TF_COMMAND, S_UNKNOWN },
{ "prompt", T_PROMPT, TF_COMMAND },
{ "tristate", T_TYPE, TF_COMMAND, S_TRISTATE },
{ "def_tristate", T_DEFAULT, TF_COMMAND, S_TRISTATE },
{ "bool", T_TYPE, TF_COMMAND, S_BOOLEAN },
{ "boolean", T_TYPE, TF_COMMAND, S_BOOLEAN },
{ "def_bool", T_DEFAULT, TF_COMMAND, S_BOOLEAN },
{ "int", T_TYPE, TF_COMMAND, S_INT },
{ "hex", T_TYPE, TF_COMMAND, S_HEX },
{ "string", T_TYPE, TF_COMMAND, S_STRING },
{ "select", T_SELECT, TF_COMMAND },
{ "imply", T_IMPLY, TF_COMMAND },
{ "range", T_RANGE, TF_COMMAND },
{ "visible", T_VISIBLE, TF_COMMAND },
{ "option", T_OPTION, TF_COMMAND },
{ "on", T_ON, TF_PARAM },
{ "modules", T_OPT_MODULES, TF_OPTION },
{ "defconfig_list", T_OPT_DEFCONFIG_LIST, TF_OPTION },
{ "env", T_OPT_ENV, TF_OPTION },
{ "allnoconfig_y", T_OPT_ALLNOCONFIG_Y, TF_OPTION },
};

#define KCONF_ID_ARRAY_SIZE (sizeof(kconf_id_array)/sizeof(struct kconf_id))

static const struct kconf_id *kconf_id_lookup(register const char *str, register unsigned int len)
{
int i;

for (i = 0; i < KCONF_ID_ARRAY_SIZE; i++) {
struct kconf_id *id = kconf_id_array+i;
int l = strlen(id->name);

if (len == l && !memcmp(str, id->name, len))
return id;
}
return NULL;
}
1 change: 1 addition & 0 deletions kconfig/list.h
@@ -1,3 +1,4 @@
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef LIST_H
#define LIST_H

Expand Down
2 changes: 1 addition & 1 deletion kconfig/lkc.h
Expand Up @@ -62,7 +62,7 @@ enum conf_def_mode {
#define T_OPT_ALLNOCONFIG_Y 4

struct kconf_id {
int name;
const char *name;
int token;
unsigned int flags;
enum symbol_type stype;
Expand Down
1 change: 1 addition & 0 deletions kconfig/lkc_proto.h
@@ -1,3 +1,4 @@
/* SPDX-License-Identifier: GPL-2.0 */
#include <stdarg.h>

/* confdata.c */
Expand Down
1 change: 1 addition & 0 deletions kconfig/lxdialog/check-lxdialog.sh
@@ -1,4 +1,5 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# Check ncurses compatibility

# What library to link
Expand Down
57 changes: 40 additions & 17 deletions kconfig/menu.c
Expand Up @@ -239,6 +239,8 @@ static void sym_check_prop(struct symbol *sym)
{
struct property *prop;
struct symbol *sym2;
char *use;

for (prop = sym->prop; prop; prop = prop->next) {
switch (prop->type) {
case P_DEFAULT:
Expand All @@ -258,18 +260,20 @@ static void sym_check_prop(struct symbol *sym)
}
break;
case P_SELECT:
case P_IMPLY:
use = prop->type == P_SELECT ? "select" : "imply";
sym2 = prop_get_symbol(prop);
if (sym->type != S_BOOLEAN && sym->type != S_TRISTATE)
prop_warn(prop,
"config symbol '%s' uses select, but is "
"not boolean or tristate", sym->name);
"config symbol '%s' uses %s, but is "
"not boolean or tristate", sym->name, use);
else if (sym2->type != S_UNKNOWN &&
sym2->type != S_BOOLEAN &&
sym2->type != S_TRISTATE)
prop_warn(prop,
"'%s' has wrong type. 'select' only "
"'%s' has wrong type. '%s' only "
"accept arguments of boolean and "
"tristate type", sym2->name);
"tristate type", sym2->name, use);
break;
case P_RANGE:
if (sym->type != S_INT && sym->type != S_HEX)
Expand Down Expand Up @@ -339,6 +343,10 @@ void menu_finalize(struct menu *parent)
struct symbol *es = prop_get_symbol(prop);
es->rev_dep.expr = expr_alloc_or(es->rev_dep.expr,
expr_alloc_and(expr_alloc_symbol(menu->sym), expr_copy(dep)));
} else if (prop->type == P_IMPLY) {
struct symbol *es = prop_get_symbol(prop);
es->implied.expr = expr_alloc_or(es->implied.expr,
expr_alloc_and(expr_alloc_symbol(menu->sym), expr_copy(dep)));
}
}
}
Expand Down Expand Up @@ -483,7 +491,7 @@ bool menu_is_visible(struct menu *menu)

if (menu->visibility) {
if (expr_calc_value(menu->visibility) == no)
return no;
return false;
}

sym = menu->sym;
Expand Down Expand Up @@ -618,13 +626,30 @@ static struct property *get_symbol_prop(struct symbol *sym)
return prop;
}

static void get_symbol_props_str(struct gstr *r, struct symbol *sym,
enum prop_type tok, const char *prefix)
{
bool hit = false;
struct property *prop;

for_all_properties(sym, prop, tok) {
if (!hit) {
str_append(r, prefix);
hit = true;
} else
str_printf(r, " && ");
expr_gstr_print(prop->expr, r);
}
if (hit)
str_append(r, "\n");
}

/*
* head is optional and may be NULL
*/
static void get_symbol_str(struct gstr *r, struct symbol *sym,
struct list_head *head)
{
bool hit;
struct property *prop;

if (sym && sym->name) {
Expand Down Expand Up @@ -654,22 +679,20 @@ static void get_symbol_str(struct gstr *r, struct symbol *sym,
}
}

hit = false;
for_all_properties(sym, prop, P_SELECT) {
if (!hit) {
str_append(r, " Selects: ");
hit = true;
} else
str_printf(r, " && ");
expr_gstr_print(prop->expr, r);
}
if (hit)
str_append(r, "\n");
get_symbol_props_str(r, sym, P_SELECT, _(" Selects: "));
if (sym->rev_dep.expr) {
str_append(r, _(" Selected by: "));
expr_gstr_print(sym->rev_dep.expr, r);
str_append(r, "\n");
}

get_symbol_props_str(r, sym, P_IMPLY, _(" Implies: "));
if (sym->implied.expr) {
str_append(r, _(" Implied by: "));
expr_gstr_print(sym->implied.expr, r);
str_append(r, "\n");
}

str_append(r, "\n\n");
}

Expand Down
14 changes: 8 additions & 6 deletions kconfig/nconf.c
Expand Up @@ -5,7 +5,9 @@
* Derived from menuconfig.
*
*/
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <string.h>
#include <stdlib.h>

Expand Down Expand Up @@ -272,7 +274,7 @@ static struct mitem k_menu_items[MAX_MENU_ITEMS];
static int items_num;
static int global_exit;
/* the currently selected button */
const char *current_instructions = menu_instructions;
static const char *current_instructions = menu_instructions;

static char *dialog_input_result;
static int dialog_input_result_len;
Expand Down Expand Up @@ -306,7 +308,7 @@ struct function_keys {
};

static const int function_keys_num = 9;
struct function_keys function_keys[] = {
static struct function_keys function_keys[] = {
{
.key_str = "F1",
.func = "Help",
Expand Down Expand Up @@ -509,7 +511,7 @@ static int get_mext_match(const char *match_str, match_f flag)
index = (index + items_num) % items_num;
while (true) {
char *str = k_menu_items[index].str;
if (strcasestr(str, match_str) != 0)
if (strcasestr(str, match_str) != NULL)
return index;
if (flag == FIND_NEXT_MATCH_UP ||
flag == MATCH_TINKER_PATTERN_UP)
Expand Down Expand Up @@ -1068,7 +1070,7 @@ static int do_match(int key, struct match_state *state, int *ans)

static void conf(struct menu *menu)
{
struct menu *submenu = 0;
struct menu *submenu = NULL;
const char *prompt = menu_get_prompt(menu);
struct symbol *sym;
int res;
Expand Down Expand Up @@ -1235,7 +1237,7 @@ static void show_help(struct menu *menu)
static void conf_choice(struct menu *menu)
{
const char *prompt = _(menu_get_prompt(menu));
struct menu *child = 0;
struct menu *child = NULL;
struct symbol *active;
int selected_index = 0;
int last_top_row = 0;
Expand Down Expand Up @@ -1457,7 +1459,7 @@ static void conf_save(void)
}
}

void setup_windows(void)
static void setup_windows(void)
{
int lines, columns;

Expand Down

0 comments on commit 59b08f8

Please sign in to comment.