From f073719687d07f4fe5dcdc62e8311d298c2d397c Mon Sep 17 00:00:00 2001 From: jmcmullan Date: Mon, 13 Aug 2012 01:41:48 +0000 Subject: [PATCH] shcommands: Cleanup SH_GLOBAL_SYSBASE, SH_GLOBAL_DOSBASE usage Signed-off-by: Jason S. McMullan git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@45528 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- compiler/include/aros/shcommands_embedded.h | 15 ++++++++++----- compiler/include/aros/shcommands_notembedded.h | 24 +++++++++++++++++++----- workbench/c/shellcommands/Clip.c | 1 + workbench/c/shellcommands/Cut.c | 8 ++++---- workbench/c/shellcommands/Execute.c | 6 ++++-- workbench/c/shellcommands/If.c | 2 -- workbench/c/shellcommands/Path.c | 1 - workbench/c/shellcommands/Setenv.c | 2 -- workbench/tools/debug/kecho/KEcho.c | 5 +++-- 9 files changed, 41 insertions(+), 23 deletions(-) diff --git a/compiler/include/aros/shcommands_embedded.h b/compiler/include/aros/shcommands_embedded.h index 37d79a08dc..a0a0ec4f41 100644 --- a/compiler/include/aros/shcommands_embedded.h +++ b/compiler/include/aros/shcommands_embedded.h @@ -28,8 +28,8 @@ struct shcommand #undef __AROS_SH_ARGS #define __AROS_SH_ARGS(name, version, numargs, defl, templ, help) \ static ULONG name##_main(CONST_STRPTR , IPTR *, \ - struct ExecBase *SysBase, \ - struct DosLibrary *); \ + struct ExecBase *_SysBase, \ + struct DosLibrary *_DOSBase); \ AROS_UFP2S(LONG, name##_entry, \ AROS_UFPA(char *,argstr,A0), \ AROS_UFPA(ULONG,argsize,D0) \ @@ -98,10 +98,15 @@ __exit: \ \ AROS_USERFUNC_EXIT \ } \ +DEFINE_SysBase_global \ +DEFINE_DOSBase_global \ static ULONG name##_main(CONST_STRPTR __argstr, \ IPTR *__shargs, \ - struct ExecBase *SysBase, \ - struct DosLibrary *DOSBase) \ -{ + struct ExecBase *_SysBase, \ + struct DosLibrary *_DOSBase) \ +{ \ + DEFINE_SysBase_local \ + DEFINE_DOSBase_local \ + SysBase = _SysBase; DOSBase = _DOSBase; #endif diff --git a/compiler/include/aros/shcommands_notembedded.h b/compiler/include/aros/shcommands_notembedded.h index 52cc56f38a..d844609716 100644 --- a/compiler/include/aros/shcommands_notembedded.h +++ b/compiler/include/aros/shcommands_notembedded.h @@ -15,21 +15,31 @@ #define _stringify(x) #x #define stringify(x) _stringify(x) +#if SH_GLOBAL_SYSBASE +# define DECLARE_SysBase_global extern struct ExecBase *SysBase; +# define DEFINE_SysBase_global struct ExecBase *SysBase; +# define DEFINE_SysBase_local +#else +# define DECLARE_SysBase_global +# define DEFINE_SysBase_local struct ExecBase __unused *SysBase; +# define DEFINE_SysBase_global +#endif + #if SH_GLOBAL_DOSBASE # define DECLARE_DOSBase_global extern struct DosLibrary *DOSBase; # define DEFINE_DOSBase_global struct DosLibrary *DOSBase; # define DEFINE_DOSBase_local #else # define DECLARE_DOSBase_global -# define DEFINE_DOSBase_local struct DosLibrary *DOSBase; +# define DEFINE_DOSBase_local struct DosLibrary __unused *DOSBase; # define DEFINE_DOSBase_global #endif #define CALL_main(name) name##_main(__shargs, __argstr, SysBase, DOSBase) #define DECLARE_main(name) \ - ULONG name##_main(IPTR *__shargs, char * __argstr, \ - struct ExecBase *SysBase, \ - struct DosLibrary *DOSBase) + ULONG name##_main(IPTR *__shargs, char * __argstr, \ + struct ExecBase *_SysBase, \ + struct DosLibrary *_DOSBase) #define DEFINE_main(name) DECLARE_main(name) #define SHArg(name) (*(SHA_##name##_type *)&__shargs[SHA_##name]) @@ -103,6 +113,7 @@ __exit: \ AROS_USERFUNC_EXIT \ } \ \ +DEFINE_SysBase_global \ DEFINE_DOSBase_global \ \ __used static const UBYTE name##_version[] = "$VER: " \ @@ -111,7 +122,10 @@ __used static const UBYTE name##_version[] = "$VER: " \ "(" ADATE ") © The AROS Development Team\n"; \ \ DEFINE_main(name) \ -{ +{ \ + DEFINE_SysBase_local \ + DEFINE_DOSBase_local \ + SysBase = _SysBase; DOSBase = _DOSBase; /* If 'AROS_AUTOINIT' is defined, automatically load * the libraries for this shell command. diff --git a/workbench/c/shellcommands/Clip.c b/workbench/c/shellcommands/Clip.c index 78472f917f..2251775996 100644 --- a/workbench/c/shellcommands/Clip.c +++ b/workbench/c/shellcommands/Clip.c @@ -45,6 +45,7 @@ //#define DEBUG 1 #include +#define SH_GLOBAL_SYSBASE 1 #include /* diff --git a/workbench/c/shellcommands/Cut.c b/workbench/c/shellcommands/Cut.c index ecc088bc4b..e4274c7abe 100644 --- a/workbench/c/shellcommands/Cut.c +++ b/workbench/c/shellcommands/Cut.c @@ -98,7 +98,7 @@ struct Bounds }; -static struct Bounds *getBoundaries(STRPTR String, APTR DOSBase); +static struct Bounds *getBoundaries(STRPTR String, APTR DOSBase, struct ExecBase *SysBase); AROS_SH4H(Cut,50.1, "extract some characters or words from a string\n", AROS_SHAH(STRPTR, ,STRING ,/A,NULL,"Quoted string from which to extract CHARacters or WORDs"), @@ -126,7 +126,7 @@ AROS_SHAH(STRPTR,S=,SEPARATOR,/K," " ,"Specify a string of any length to be used if (SHArg(WORD)) { - if ((wordBounds = getBoundaries(SHArg(WORD), DOSBase)) != NULL) + if ((wordBounds = getBoundaries(SHArg(WORD), DOSBase, SysBase)) != NULL) { if (0 != wordBounds->Start) { @@ -166,7 +166,7 @@ AROS_SHAH(STRPTR,S=,SEPARATOR,/K," " ,"Specify a string of any length to be used if (SHArg(CHAR)) { - if ((charBounds = getBoundaries(SHArg(CHAR), DOSBase)) != NULL) + if ((charBounds = getBoundaries(SHArg(CHAR), DOSBase, SysBase)) != NULL) { if (0 != charBounds->Start) stringBuf += charBounds->Start - 1; @@ -197,7 +197,7 @@ AROS_SHAH(STRPTR,S=,SEPARATOR,/K," " ,"Specify a string of any length to be used } -static struct Bounds *getBoundaries(STRPTR String, APTR DOSBase) +static struct Bounds *getBoundaries(STRPTR String, APTR DOSBase, struct ExecBase *SysBase) { CONST_STRPTR buffer; struct Bounds *bounds; diff --git a/workbench/c/shellcommands/Execute.c b/workbench/c/shellcommands/Execute.c index 51375b99ac..c911f3e7ce 100644 --- a/workbench/c/shellcommands/Execute.c +++ b/workbench/c/shellcommands/Execute.c @@ -52,10 +52,12 @@ #include #include -#define SH_GLOBAL_SYSBASE 1 - #define DEBUG 0 #include + +#ifndef USE_EMBEDDED_COMMANDS +#define SH_GLOBAL_SYSBASE 1 /* For __sprintf */ +#endif #include AROS_SH2(Execute, 41.1, diff --git a/workbench/c/shellcommands/If.c b/workbench/c/shellcommands/If.c index b9eb1e70ad..07a6b3f13c 100644 --- a/workbench/c/shellcommands/If.c +++ b/workbench/c/shellcommands/If.c @@ -94,8 +94,6 @@ #include #include "dos_commanderrors.h" -#define SH_GLOBAL_DOSBASE 1 - #include static BOOL doeval(STRPTR arg1, STRPTR arg2, BYTE op, IPTR numeric, APTR DOSBase, APTR UtilityBase); diff --git a/workbench/c/shellcommands/Path.c b/workbench/c/shellcommands/Path.c index a821efac55..3c9fe8fa93 100644 --- a/workbench/c/shellcommands/Path.c +++ b/workbench/c/shellcommands/Path.c @@ -60,7 +60,6 @@ #include #include "dos_commanderrors.h" -#define SH_GLOBAL_DOSBASE 1 #include #include diff --git a/workbench/c/shellcommands/Setenv.c b/workbench/c/shellcommands/Setenv.c index 36deb71413..cce591315f 100644 --- a/workbench/c/shellcommands/Setenv.c +++ b/workbench/c/shellcommands/Setenv.c @@ -83,8 +83,6 @@ #include #include -#define SH_GLOBAL_DOSBASE 1 /* because of Printf from amiga.lib */ - #include AROS_SH3(Setenv, 45.0, diff --git a/workbench/tools/debug/kecho/KEcho.c b/workbench/tools/debug/kecho/KEcho.c index 276a2744c6..d542cf3496 100644 --- a/workbench/tools/debug/kecho/KEcho.c +++ b/workbench/tools/debug/kecho/KEcho.c @@ -44,6 +44,7 @@ ******************************************************************************/ #define DEBUG 0 +#include #include #include @@ -51,9 +52,9 @@ #include #include #include -#include -#include +#define SH_GLOBAL_SYSBASE 1 /* for kprintf() */ +#include AROS_SH2(KEcho, 41.1, AROS_SHA(STRPTR *, , STRINGS, /M, NULL), -- 2.11.4.GIT