From 2a757a35998b6bf10ff55d9f8c9b7c687d597af3 Mon Sep 17 00:00:00 2001 From: verhaegs Date: Sat, 25 Aug 2012 11:54:20 +0000 Subject: [PATCH] tools/genmodule: Added .unusedlibbase option This option allows to indicate that the libbase does not need to be accessible inside the library when entering through this function. Using this function can avoid some overhead internally when calling such functions. One needs to be careful with using this option as the .unusedlibbase function may not call other functions that want to access the libbase. Added test case in test/library for the option. git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@45652 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- test/library/mmakefile.src | 4 +++- test/library/peropener.conf | 2 ++ test/library/peropenernolib.c | 4 ++++ test/library/peropenertest.c | 4 ++++ tools/genmodule/config.c | 6 ++++++ tools/genmodule/functionhead.c | 22 ++++++++++++++-------- tools/genmodule/functionhead.h | 3 ++- tools/genmodule/writeincdefines.c | 7 ++++--- 8 files changed, 39 insertions(+), 13 deletions(-) create mode 100644 test/library/peropenernolib.c diff --git a/test/library/mmakefile.src b/test/library/mmakefile.src index 29662d0d04..6c3c0e07ae 100644 --- a/test/library/mmakefile.src +++ b/test/library/mmakefile.src @@ -51,7 +51,9 @@ USER_LDFLAGS := -L$(TARGETDIR)/Development/lib modname=dummy modtype=library files=dummylib prefix=$(TARGETDIR) %build_module mmake=test-library-peropenerlib \ - modname=peropener modtype=library files=peropenervalue prefix=$(TARGETDIR) + modname=peropener modtype=library \ + files="peropenervalue peropenernolib" \ + prefix=$(TARGETDIR) %build_module mmake=test-library-pertasklib \ modname=pertask modtype=library \ diff --git a/test/library/peropener.conf b/test/library/peropener.conf index 3d02755160..c7b6f04b1a 100644 --- a/test/library/peropener.conf +++ b/test/library/peropener.conf @@ -11,4 +11,6 @@ options peropenerbase ##begin functionlist void PeropenerSetValue(int) int PeropenerGetValue(void) +int PeropenerNoLib(void) +.unusedlibbase ##end functionlist diff --git a/test/library/peropenernolib.c b/test/library/peropenernolib.c new file mode 100644 index 0000000000..04d554b64d --- /dev/null +++ b/test/library/peropenernolib.c @@ -0,0 +1,4 @@ +int PeropenerNoLib(void) +{ + return 1; +} diff --git a/test/library/peropenertest.c b/test/library/peropenertest.c index 98a62e11e2..b8827ee32a 100644 --- a/test/library/peropenertest.c +++ b/test/library/peropenertest.c @@ -24,6 +24,10 @@ int main (int argc, char ** argv) PeropenerBase = base1; PeropenerSetValue(1); + /* Check .unusedlibbase option with base1 */ + if (PeropenerNoLib() != 1) + Printf("Error calling PeropenerNoLib()\n"); + /* Set value for base2 */ PeropenerBase = base2; PeropenerSetValue(2); diff --git a/tools/genmodule/config.c b/tools/genmodule/config.c index 71234f4e50..87f222dbd6 100644 --- a/tools/genmodule/config.c +++ b/tools/genmodule/config.c @@ -1569,6 +1569,12 @@ static void readsectionfunctionlist(const char *type, struct functionhead **func minversion = ver; } + else if (strncmp(s, "unusedlibbase", 13) == 0) + { + if (*funclistptr == NULL) + exitfileerror(20, ".unusedlibbase has to come after a function declaration\n"); + (*funclistptr)->unusedlibbase = 1; + } else exitfileerror(20, "Syntax error"); } diff --git a/tools/genmodule/functionhead.c b/tools/genmodule/functionhead.c index ada6180e55..2c83fe5486 100644 --- a/tools/genmodule/functionhead.c +++ b/tools/genmodule/functionhead.c @@ -1,5 +1,5 @@ /* - Copyright © 1995-2009, The AROS Development Team. All rights reserved. + Copyright © 1995-2012, The AROS Development Team. All rights reserved. $Id$ The code for storing information of functions present in the module @@ -27,6 +27,7 @@ struct functionhead *newfunctionhead(const char *name, enum libcall libcall) funchead->method = NULL; funchead->novararg = 0; funchead->priv= 0; + funchead->unusedlibbase = 0; } else { @@ -117,8 +118,9 @@ void writefuncdefs(FILE *out, struct config *cfg, struct functionhead *funclist) fprintf(out, "%s", arglistit->arg); } fprintf(out, - ");\nAROS_LH%d(%s, %s,\n", - funclistit->argcount, funclistit->type, funclistit->internalname + ");\nAROS_LH%d%s(%s, %s,\n", + funclistit->argcount, funclistit->unusedlibbase ? "I" : "", + funclistit->type, funclistit->internalname ); for (arglistit = funclistit->arguments; arglistit!=NULL; @@ -169,8 +171,9 @@ void writefuncdefs(FILE *out, struct config *cfg, struct functionhead *funclist) || strchr(funclistit->arguments->reg, '/') == NULL) { fprintf(out, - "AROS_LD%d(%s, %s,\n", - funclistit->argcount, funclistit->type, funclistit->internalname + "AROS_LD%d%s(%s, %s,\n", + funclistit->argcount, funclistit->unusedlibbase ? "I" : "", + funclistit->type, funclistit->internalname ); for (arglistit = funclistit->arguments; arglistit!=NULL; @@ -289,8 +292,9 @@ void writefuncprotos(FILE *out, struct config *cfg, struct functionhead *funclis ) { fprintf(out, - "AROS_LP%d(%s, %s,\n", - funclistit->argcount, funclistit->type, funclistit->name + "AROS_LP%d%s(%s, %s,\n", + funclistit->argcount, funclistit->unusedlibbase ? "I" : "", + funclistit->type, funclistit->name ); for (arglistit = funclistit->arguments; arglistit!=NULL; @@ -381,7 +385,9 @@ void writefuncinternalstubs(FILE *out, struct config *cfg, struct functionhead * switch (funclistit->libcall) { case STACK: - if (cfg->options & OPTION_DUPBASE) + if ((cfg->options & OPTION_DUPBASE) + && !funclistit->unusedlibbase + ) { fprintf(out, "AROS_GM_STACKCALL(%s,%s,%d);\n" diff --git a/tools/genmodule/functionhead.h b/tools/genmodule/functionhead.h index 8a03b4b473..9b470cb471 100644 --- a/tools/genmodule/functionhead.h +++ b/tools/genmodule/functionhead.h @@ -1,5 +1,5 @@ /* - Copyright © 1995-2009, The AROS Development Team. All rights reserved. + Copyright © 1995-2012, The AROS Development Team. All rights reserved. $Id$ Desc: global include for genmodule. Defines global variables and @@ -37,6 +37,7 @@ struct functionhead { int version; /* First library version number this appeared in*/ int novararg : 1; /* Are varargs allowed for this function ? */ int priv : 1; /* Is function private */ + int unusedlibbase : 1; /* Libbase must no be made available internally */ }; struct functionhead *newfunctionhead(const char *name, enum libcall libcall); diff --git a/tools/genmodule/writeincdefines.c b/tools/genmodule/writeincdefines.c index 82584b3f1e..03c7441847 100644 --- a/tools/genmodule/writeincdefines.c +++ b/tools/genmodule/writeincdefines.c @@ -1,5 +1,5 @@ /* - Copyright © 1995-2011, The AROS Development Team. All rights reserved. + Copyright © 1995-2012, The AROS Development Team. All rights reserved. $Id$ Function to write defines/modulename.h. Part of genmodule. @@ -132,8 +132,9 @@ writedefineregister(FILE *out, struct functionhead *funclistit, struct config *c if (nquad == 0) { fprintf(out, - " AROS_LC%d%s(%s, %s, \\\n", - funclistit->argcount, (isvoid) ? "NR" : "", + " AROS_LC%d%s%s(%s, %s, \\\n", + funclistit->argcount, funclistit->unusedlibbase ? "I" : "", + (isvoid) ? "NR" : "", funclistit->type, funclistit->name ); -- 2.11.4.GIT