From 34849828b715a73ecd6367c24d8f693451c1c15c Mon Sep 17 00:00:00 2001 From: verhaegs Date: Sun, 16 Aug 2009 14:42:15 +0000 Subject: [PATCH] Added startup section to library .conf file. Code in this section will be added to the library autoinit code. Programs that link with the libxxx.a file of a library and get the libbase initialization code from there will also get the code in this section. git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@31709 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- tools/genmodule/config.c | 54 +++++++++++++++++++++++++++++++++++++---- tools/genmodule/config.h | 4 +-- tools/genmodule/writeautoinit.c | 7 ++++++ 3 files changed, 58 insertions(+), 7 deletions(-) diff --git a/tools/genmodule/config.c b/tools/genmodule/config.c index 5d6dd4b184..792aeb7799 100644 --- a/tools/genmodule/config.c +++ b/tools/genmodule/config.c @@ -299,6 +299,7 @@ static char *readsections(struct config *, struct classinfo *, int); static void readsectionconfig(struct config *, struct classinfo *, int); static void readsectioncdef(struct config *); static void readsectioncdefprivate(struct config *); +static void readsectionstartup(struct config *); static void readsectionfunctionlist(struct config *); static void readsectionmethodlist(struct classinfo *); static void readsectionclass(struct config *); @@ -400,7 +401,7 @@ static char *readsections(struct config *cfg, struct classinfo *cl, int inclass) { static char *parts[] = { - "config", "cdefprivate", "cdef", "functionlist", "methodlist", "class" + "config", "cdefprivate", "cdef", "startup", "functionlist", "methodlist", "class" }; const unsigned int nums = sizeof(parts)/sizeof(char *); unsigned int partnum; @@ -449,21 +450,27 @@ static char *readsections(struct config *cfg, struct classinfo *cl, int inclass) readsectioncdef(cfg); break; - case 4: /* functionlist */ + case 4: /* startup */ + if (inclass) + exitfileerror(20, "startup section not allowed in class section\n"); + readsectionstartup(cfg); + break; + + case 5: /* functionlist */ if (inclass) exitfileerror(20, "functionlist section not allow in class section\n"); readsectionfunctionlist(cfg); cfg->intcfg |= CFG_NOREADREF; break; - case 5: /* methodlist */ + case 6: /* methodlist */ if (cl == NULL) exitfileerror(20, "methodlist section when not in a class\n"); readsectionmethodlist(cl); cfg->intcfg |= CFG_NOREADREF; break; - case 6: /* class */ + case 7: /* class */ if (inclass) exitfileerror(20, "class section may not be nested\n"); readsectionclass(cfg); @@ -1154,7 +1161,7 @@ static void readsectioncdef(struct config *cfg) s = line+2; while (isspace(*s)) s++; if (strncmp(s, "end", 3)!=0) - exitfileerror(20, "\"##end startuplines, line); + } + else + { + s = line+2; + while (isspace(*s)) s++; + if (strncmp(s, "end", 3)!=0) + exitfileerror(20, "\"##end startup\" expected\n"); + + s += 3; + while (isspace(*s)) s++; + if (strncmp(s, "startup", 7)!=0) + exitfileerror(20, "\"##end startup\" expected\n"); + + s += 7; + while (isspace(*s)) s++; + if (*s!='\0') + exitfileerror(20, "unexpected character at position %d\n"); + + atend = 1; + } + } +} + static void readsectionfunctionlist(struct config *cfg) { int atend = 0, i; diff --git a/tools/genmodule/config.h b/tools/genmodule/config.h index 1d4a13a62c..e5d0e49bdd 100644 --- a/tools/genmodule/config.h +++ b/tools/genmodule/config.h @@ -120,8 +120,8 @@ struct config */ struct stringlist *forcelist; - /* Code to add to the generated fioles */ - struct stringlist *cdeflines, *cdefprivatelines; + /* Code to add to the generated files */ + struct stringlist *cdeflines, *cdefprivatelines, *startuplines; /* device specific data */ char *beginiofunc, *abortiofunc; diff --git a/tools/genmodule/writeautoinit.c b/tools/genmodule/writeautoinit.c index 9bc9f74f33..9f061a3d7a 100644 --- a/tools/genmodule/writeautoinit.c +++ b/tools/genmodule/writeautoinit.c @@ -10,6 +10,7 @@ void writeautoinit(struct config *cfg) { FILE *out; char line[256], *banner; + struct stringlist *linelistit; snprintf(line, 255, "%s/%s_autoinit.c", cfg->gendir, cfg->modulename); out = fopen(line, "w"); @@ -33,6 +34,12 @@ void writeautoinit(struct config *cfg) ); freeBanner(banner); + /* Write the code to be added to startup provided in the config file */ + for (linelistit = cfg->startuplines; linelistit != NULL; linelistit = linelistit->next) + { + fprintf(out, "%s\n", linelistit->s); + } + if (cfg->forcelist!=NULL) { struct stringlist * forcelistit; -- 2.11.4.GIT