diff --git a/platforms/Cross/vm/sqCogStackAlignment.h b/platforms/Cross/vm/sqCogStackAlignment.h index 0e5cb76557..c33b6fa9d4 100644 --- a/platforms/Cross/vm/sqCogStackAlignment.h +++ b/platforms/Cross/vm/sqCogStackAlignment.h @@ -20,6 +20,9 @@ # define STACK_ALIGN_BYTES 4 # define STACK_FP_ALIGNMENT 0 # endif +# if _MSC_VER +# define STACK_SP_ALIGNMENT 4 +# endif #endif #if defined(__arm64__) || defined(__aarch64__) || defined(ARM64) @@ -115,19 +118,7 @@ # else /* !(__i386__ || __arm__ || __x86_64__) */ # error define code for your processor here # endif -# if !defined(getfp) -# define getfp() ceGetFP() /* provided by Cogit */ -# endif -# if !defined(getsp) -# define getsp() ceGetSP() /* provided by Cogit */ -# endif -# define STACK_ALIGN_MASK (STACK_ALIGN_BYTES-1) -# define assertCStackWellAligned() do { \ - extern sqInt cFramePointerInUse; \ - if (cFramePointerInUse) \ - assert((getfp() & STACK_ALIGN_MASK) == STACK_FP_ALIGNMENT); \ - assert((getsp() & STACK_ALIGN_MASK) == 0); \ -} while (0) + #else /* defined(STACK_ALIGN_BYTES) */ # if defined(powerpc) || defined(__powerpc__) || defined(_POWER) || defined(__POWERPC__) || defined(__PPC__) # define STACK_ALIGN_BYTES 16 @@ -140,3 +131,22 @@ # endif # define assertCStackWellAligned() 0 #endif /* defined(STACK_ALIGN_BYTES) */ + +#if !defined(getfp) +# define getfp() ceGetFP() /* provided by Cogit */ +#endif +#if !defined(getsp) +# define getsp() ceGetSP() /* provided by Cogit */ +#endif +#define STACK_ALIGN_MASK (STACK_ALIGN_BYTES-1) +#if !defined(STACK_SP_ALIGNMENT) +# define STACK_SP_ALIGNMENT 0 +#endif +#if !defined(assertCStackWellAligned) +# define assertCStackWellAligned() do { \ + extern sqInt cFramePointerInUse; \ + if (cFramePointerInUse) \ + assert((getfp() & STACK_ALIGN_MASK) == STACK_FP_ALIGNMENT); \ + assert((getsp() & STACK_ALIGN_MASK) == STACK_SP_ALIGNMENT); \ +} while (0) +#endif diff --git a/platforms/Cross/vm/sqNamedPrims.c b/platforms/Cross/vm/sqNamedPrims.c index 91a2a5f2cb..9a1f95bb0f 100644 --- a/platforms/Cross/vm/sqNamedPrims.c +++ b/platforms/Cross/vm/sqNamedPrims.c @@ -46,12 +46,11 @@ struct VirtualMachine *sqGetInterpreterProxy(void); static void * findLoadedModule(char *pluginName) { - ModuleEntry *module; + ModuleEntry *module = firstModule; if (!pluginName || !pluginName[0]) return squeakModule; - module = firstModule; while (module) { - if (strcmp(module->name, pluginName) == 0) + if (!strcmp(module->name, pluginName)) return module; module = module->next; } @@ -140,9 +139,7 @@ findInternalFunctionIn(char *functionName, char *pluginName #endif ) { - char *function, *plugin; sqInt listIndex, index; - sqExport *exports; DPRINTF(("Looking (internally) for %s in %s ... ", functionName, (pluginName ? pluginName : ""))); @@ -150,11 +147,11 @@ findInternalFunctionIn(char *functionName, char *pluginName if (functionName && !functionName[0]) functionName = NULL; if (pluginName && !pluginName[0]) pluginName = NULL; for (listIndex=0;; listIndex++) { - exports = pluginExports[listIndex]; + sqExport *exports = pluginExports[listIndex]; if (!exports) break; for (index=0;; index++) { - plugin = exports[index].pluginName; - function = exports[index].primitiveName; + char *plugin = exports[index].pluginName; + char *function = exports[index].primitiveName; /* canonicalize plugin and function to be NULL if not specified */ if (plugin && !plugin[0]) plugin = NULL; if (function && !function[0]) function = NULL; @@ -307,10 +304,9 @@ findAndLoadModule(char *pluginName, sqInt ffiLoad) /* NOT ffiLoad */ if (!handle) { /* might be internal, so go looking for setInterpreter() */ - if (findInternalFunctionIn("setInterpreter", pluginName NADA)) - handle = squeakModule->handle; - else + if (!findInternalFunctionIn("setInterpreter", pluginName NADA)) return NULL; /* PluginName_setInterpreter() not found */ + handle = squeakModule->handle; } module = addToModuleList(pluginName, handle, ffiLoad); if (!callInitializersIn(module)) { @@ -593,17 +589,15 @@ char * ioListBuiltinModule(sqInt moduleIndex) { sqInt index, listIndex; - char *function, *plugin; - sqExport *exports; for (listIndex=0;; listIndex++) { - exports = pluginExports[listIndex]; + sqExport * exports = pluginExports[listIndex]; if (!exports) break; for (index=0;; index++) { - plugin = exports[index].pluginName; - function = exports[index].primitiveName; + char *plugin = exports[index].pluginName; + char *function = exports[index].primitiveName; if (!function && !plugin) break; /* no more plugins */ - if (strcmp(function,"setInterpreter") == 0) { + if (!strcmp(function,"setInterpreter")) { /* new module */ if (--moduleIndex == 0) { char *moduleName; @@ -630,24 +624,20 @@ ioListLoadedModule(sqInt moduleIndex) ModuleEntry *entry = firstModule; if (moduleIndex < 1) - return (char*)NULL; + return NULL; while (entry && index < moduleIndex) { entry = entry->next; index = index + 1; } - if ( entry ) { - char *moduleName; - void * init0; - - init0 = findFunctionIn("getModuleName", entry); + if (entry) { + void *init0 = findFunctionIn("getModuleName", entry); if (init0) { /* Check the compiled name of the module */ - moduleName = ((char* (*) (void))init0)(); + char *moduleName = ((char* (*) (void))init0)(); if (moduleName) return moduleName; } return entry->name; } - else - return (char*)NULL; + return NULL; }