From afaffaea3892b0d2af9269e10a2d9e09a95174f2 Mon Sep 17 00:00:00 2001 From: "Yann E. MORIN\"" Date: Sun, 15 Apr 2007 16:45:11 +0000 Subject: Update to latest kconfig from linux-2.6.20.7. I'm not sure of the improvements, but at least we're up-to-date, and updating in the future will be easier. diff --git a/kconfig/conf.c b/kconfig/conf.c index 1b5b5d5..63c7542 100644 --- a/kconfig/conf.c +++ b/kconfig/conf.c @@ -557,7 +557,7 @@ int main(int ac, char **av) case ask_silent: if (stat(".config", &tmpstat)) { printf(_("***\n" - "*** You have not yet configured your "PROJECT_NAME"!\n" + "*** You have not yet configured "PROJECT_NAME"!\n" "***\n" "*** Please run some configurator (e.g. \"make oldconfig\" or\n" "*** \"make menuconfig\" or \"make xconfig\").\n" @@ -600,7 +600,7 @@ int main(int ac, char **av) input_mode = ask_silent; valid_stdin = 1; } - } else if (sym_change_count) { + } else if (conf_get_changed()) { name = getenv("KCONFIG_NOSILENTUPDATE"); if (name && *name) { fprintf(stderr, _("\n*** "PROJECT_NAME" configuration requires explicit update.\n\n")); @@ -613,11 +613,11 @@ int main(int ac, char **av) conf_cnt = 0; check_conf(&rootmenu); } while (conf_cnt); - - if (!conf_write(NULL)) { -skip_check: - return 0; + if (conf_write(NULL)) { + fprintf(stderr, _("\n*** Error during writing of "PROJECT_NAME" configuration.\n\n")); + return 1; } - fprintf(stderr, _("\n*** Error writing "PROJECT_NAME" configuration.\n\n")); - return 1; +skip_check: + + return 0; } diff --git a/kconfig/confdata.c b/kconfig/confdata.c index 8d79f44..1f12cd2 100644 --- a/kconfig/confdata.c +++ b/kconfig/confdata.c @@ -5,9 +5,7 @@ #include #include -#include #include -#include #include #include #include @@ -23,9 +21,7 @@ static void conf_warning(const char *fmt, ...) static const char *conf_filename; static int conf_lineno, conf_warnings, conf_unsaved; -#ifndef conf_defname const char conf_defname[] = "arch/$ARCH/defconfig"; -#endif static void conf_warning(const char *fmt, ...) { @@ -104,7 +100,7 @@ int conf_read_simple(const char *name, int def) in = zconf_fopen(name); if (in) goto load; - sym_change_count++; + sym_add_change_count(1); if (!sym_defconfig_list) return 1; @@ -316,7 +312,7 @@ int conf_read(const char *name) struct expr *e; int i, flags; - sym_change_count = 0; + sym_set_change_count(0); if (conf_read_simple(name, S_DEF_USER)) return 1; @@ -368,26 +364,11 @@ int conf_read(const char *name) sym->flags &= flags | ~SYMBOL_DEF_USER; } - sym_change_count += conf_warnings || conf_unsaved; + sym_add_change_count(conf_warnings || conf_unsaved); return 0; } -struct menu *next_menu(struct menu *menu) -{ - if (menu->list) return menu->list; - do { - if (menu->next) { - menu = menu->next; - break; - } - } while ((menu = menu->parent)); - - return menu; -} - -#define SYMBOL_FORCEWRITE (1<<31) - int conf_write(const char *name) { FILE *out; @@ -395,7 +376,7 @@ int conf_write(const char *name) struct menu *menu; const char *basename; char dirname[128], tmpname[128], newname[128]; - int type, l, writetype; + int type, l; const char *str; time_t now; int use_timestamp = 1; @@ -451,20 +432,9 @@ int conf_write(const char *name) use_timestamp ? "# " : "", use_timestamp ? ctime(&now) : ""); - if (!sym_change_count) + if (!conf_get_changed()) sym_clear_all_valid(); - // Write out all symbols (even in closed sub-menus). - if (1) { - for (menu = rootmenu.list; menu; menu = next_menu(menu)) - if (menu->sym) menu->sym->flags |= SYMBOL_FORCEWRITE; - writetype = SYMBOL_FORCEWRITE; - - // Don't write out symbols in closed menus. - - } else writetype = SYMBOL_WRITE; - - menu = rootmenu.list; while (menu) { sym = menu->sym; @@ -478,9 +448,9 @@ int conf_write(const char *name) "#\n", str); } else if (!(sym->flags & SYMBOL_CHOICE)) { sym_calc_value(sym); - if (!(sym->flags & writetype)) + if (!(sym->flags & SYMBOL_WRITE)) goto next; - sym->flags &= ~writetype; + sym->flags &= ~SYMBOL_WRITE; type = sym->type; if (type == S_TRISTATE) { sym_calc_value(modules_sym); @@ -520,32 +490,29 @@ int conf_write(const char *name) case S_HEX: str = sym_get_string_value(sym); if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) { - fprintf(out, "CT_%s=%s\n", sym->name, *str ? str : "0"); + fprintf(out, "CT_%s=%s\n", sym->name, str); break; } case S_INT: str = sym_get_string_value(sym); - fprintf(out, "CT_%s=%s\n", sym->name, *str ? str : "0"); + fprintf(out, "CT_%s=%s\n", sym->name, str); break; } } next: - if (writetype == SYMBOL_WRITE) { - if (menu->list) { - menu = menu->list; - continue; - } - if (menu->next) + if (menu->list) { + menu = menu->list; + continue; + } + if (menu->next) + menu = menu->next; + else while ((menu = menu->parent)) { + if (menu->next) { menu = menu->next; - else while ((menu = menu->parent)) { - if (menu->next) { - menu = menu->next; - break; - } + break; } - } else - menu = next_menu(menu); + } } fclose(out); @@ -561,7 +528,7 @@ int conf_write(const char *name) "# configuration written to %s\n" "#\n"), newname); - sym_change_count = 0; + sym_set_change_count(0); return 0; } @@ -798,3 +765,30 @@ int conf_write_autoconf(void) return 0; } + +static int sym_change_count; +static void (*conf_changed_callback)(void); + +void sym_set_change_count(int count) +{ + int _sym_change_count = sym_change_count; + sym_change_count = count; + if (conf_changed_callback && + (bool)_sym_change_count != (bool)count) + conf_changed_callback(); +} + +void sym_add_change_count(int count) +{ + sym_set_change_count(count + sym_change_count); +} + +bool conf_get_changed(void) +{ + return sym_change_count; +} + +void conf_set_changed_callback(void (*fn)(void)) +{ + conf_changed_callback = fn; +} diff --git a/kconfig/lkc.h b/kconfig/lkc.h index cf32679..ab963df 100644 --- a/kconfig/lkc.h +++ b/kconfig/lkc.h @@ -6,12 +6,6 @@ #ifndef LKC_H #define LKC_H -#define PROJECT_NAME "crosstool-NG" - -// Make some warnings go away -#define YYENABLE_NLS 0 -#define YYLTYPE_IS_TRIVIAL 0 - #include "expr.h" #ifndef KBUILD_NO_NLS @@ -37,6 +31,7 @@ extern "C" { #define SRCTREE "srctree" +#define PROJECT_NAME "crosstool-NG" #define PACKAGE "crosstool-NG" #define LOCALEDIR "/usr/share/locale" @@ -71,6 +66,8 @@ char *zconf_curname(void); /* confdata.c */ char *conf_get_default_confname(void); +void sym_set_change_count(int count); +void sym_add_change_count(int count); /* kconfig_load.c */ void kconfig_load(void); diff --git a/kconfig/lkc_proto.h b/kconfig/lkc_proto.h index a263746..1503077 100644 --- a/kconfig/lkc_proto.h +++ b/kconfig/lkc_proto.h @@ -5,6 +5,8 @@ P(conf_read,int,(const char *name)); P(conf_read_simple,int,(const char *name, int)); P(conf_write,int,(const char *name)); P(conf_write_autoconf,int,(void)); +P(conf_get_changed,bool,(void)); +P(conf_set_changed_callback, void,(void (*fn)(void))); /* menu.c */ P(rootmenu,struct menu,); @@ -16,7 +18,6 @@ P(menu_get_parent_menu,struct menu *,(struct menu *menu)); /* symbol.c */ P(symbol_hash,struct symbol *,[SYMBOL_HASHSIZE]); -P(sym_change_count,int,); P(sym_lookup,struct symbol *,(const char *name, int isconst)); P(sym_find,struct symbol *,(const char *name)); diff --git a/kconfig/mconf.c b/kconfig/mconf.c index 8f268be..69fc4d5 100644 --- a/kconfig/mconf.c +++ b/kconfig/mconf.c @@ -868,7 +868,7 @@ int main(int ac, char **av) bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - conf_parse(av[1] ? av[1] : ""); + conf_parse(av[1]); conf_read(NULL); sym = sym_lookup("PROJECTVERSION", 0); @@ -890,26 +890,33 @@ int main(int ac, char **av) do { conf(&rootmenu); dialog_clear(); - res = dialog_yesno(NULL, - _("Do you wish to save your " - "new "PROJECT_NAME" configuration?\n" - " to continue."), - 6, 60); + if (conf_get_changed()) + res = dialog_yesno(NULL, + _("Do you wish to save your " + "new "PROJECT_NAME" configuration?\n" + " to continue."), + 6, 60); + else + res = -1; } while (res == KEY_ESC); end_dialog(); - if (res == 0) { + + switch (res) { + case 0: if (conf_write(NULL)) { fprintf(stderr, _("\n\n" - "Error writing "PROJECT_NAME" configuration.\n" - "Your configuration changes were NOT saved." + "Error during writing of "PROJECT_NAME" configuration.\n" + "Your kernel configuration changes were NOT saved." "\n\n")); return 1; } + case -1: printf(_("\n\n" "*** End of "PROJECT_NAME" configuration.\n" - "*** Execute 'make' to build, or try 'make help'." + "*** Execute 'make' to build the kernel or try 'make help'." "\n\n")); - } else { + break; + default: fprintf(stderr, _("\n\n" "Your configuration changes were NOT saved." "\n\n")); diff --git a/kconfig/symbol.c b/kconfig/symbol.c index 34f42fb..d79865c 100644 --- a/kconfig/symbol.c +++ b/kconfig/symbol.c @@ -30,7 +30,6 @@ struct symbol symbol_yes = { .flags = SYMBOL_VALID, }; -int sym_change_count; struct symbol *sym_defconfig_list; struct symbol *modules_sym; tristate modules_val; @@ -379,7 +378,7 @@ void sym_clear_all_valid(void) for_all_symbols(i, sym) sym->flags &= ~SYMBOL_VALID; - sym_change_count++; + sym_add_change_count(1); if (modules_sym) sym_calc_value(modules_sym); } diff --git a/kconfig/zconf.tab.c_shipped b/kconfig/zconf.tab.c_shipped index 34ccabd..2914cdf 100644 --- a/kconfig/zconf.tab.c_shipped +++ b/kconfig/zconf.tab.c_shipped @@ -2135,7 +2135,7 @@ void conf_parse(const char *name) sym_check_deps(sym); } - sym_change_count = 1; + sym_set_change_count(1); } const char *zconf_tokenname(int token) -- cgit v0.10.2-6-g49f6