From: Jerome St-Louis Date: Sun, 17 Mar 2013 18:25:17 +0000 (-0400) Subject: ecere/com: Fixed 32 bit cross-compiling issues in EDASQLite X-Git-Tag: 0.44.05~1 X-Git-Url: https://ecere.com/cgi-bin/gitweb.cgi?p=sdk;a=commitdiff_plain;h=1681c904ac8670946b70a4474a9a81477a26fc7b ecere/com: Fixed 32 bit cross-compiling issues in EDASQLite --- diff --git a/compiler/bootstrap/ecere/bootstrap/instance.c b/compiler/bootstrap/ecere/bootstrap/instance.c index 051f60d..715aa69 100644 --- a/compiler/bootstrap/ecere/bootstrap/instance.c +++ b/compiler/bootstrap/ecere/bootstrap/instance.c @@ -1143,6 +1143,8 @@ void __ecereNameSpace__ecere__com__CheckMemory() { } +static int __ecereNameSpace__ecere__com__insideCrossBuild32; + static void __ecereNameSpace__ecere__com__ComputeClassParameters(struct __ecereNameSpace__ecere__com__Class * templatedClass, char * templateParams, struct __ecereNameSpace__ecere__com__Instance * findModule); extern char * strchr(const char * , int); @@ -1785,7 +1787,7 @@ if(type == 0 || type == 5) _class->offset = (base && base->structSize && base->type != 1000) ? base->structSize : ((type == 5) ? 0 : (force64Bits ? 24 : (force32Bits && inCompiler) ? 12 : structSize_Instance)); if(crossBits) { -if(strstr(name, "ecere::sys::EARHeader") || strstr(name, "AnchorValue") || !strcmp(name, "ecere::com::CustomAVLTree") || !strcmp(name, "ecere::sys::Mutex")) +if(strstr(name, "ecere::sys::EARHeader") || strstr(name, "AnchorValue") || !strcmp(name, "ecere::com::CustomAVLTree") || !strcmp(name, "ecere::gui::Window") || !strcmp(name, "ecere::sys::Mutex")) ; else { @@ -3508,22 +3510,15 @@ if(_class) { { int size = _class->structSize; -struct __ecereNameSpace__ecere__com__Instance * module = _class->module; -struct __ecereNameSpace__ecere__com__Instance * application = module ? ((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + structSize_Instance)))->application : (((void *)0)); -int flags = application ? (unsigned int)((struct __ecereNameSpace__ecere__com__Application *)(((char *)application + structSize_Module)))->isGUIApp : 0; -unsigned int inCompiler = (flags & 8) ? 0x1 : 0x0; - -if(inCompiler) -{ -unsigned int force32Bits = (flags & 4) ? 0x1 : 0x0; -if(force32Bits) +if(__ecereNameSpace__ecere__com__insideCrossBuild32) { if(!strcmp(_class->name, "Module")) size = 560; else if(_class->templateClass && !strcmp(_class->templateClass->name, "Map")) size = 40; -} +else +size *= 3; } instance = __ecereNameSpace__ecere__com___calloc(1, size); } @@ -4252,6 +4247,10 @@ void * __ecereTemp1; unsigned int (stdcall * Load)(struct __ecereNameSpace__ecere__com__Instance * module) = (((void *)0)); unsigned int (stdcall * Unload)(struct __ecereNameSpace__ecere__com__Instance * module) = (((void *)0)); struct __ecereNameSpace__ecere__com__Instance * module; +int flags = (unsigned int)((struct __ecereNameSpace__ecere__com__Application *)(((char *)((struct __ecereNameSpace__ecere__com__Module *)(((char *)fromModule + structSize_Instance)))->application + structSize_Module)))->isGUIApp; +unsigned int inCompiler = (flags & 8) ? 0x1 : 0x0; +unsigned int force32Bits = (flags & 4) ? 0x1 : 0x0; +unsigned int setInsideCrossBuild32 = force32Bits && inCompiler; for(module = ((struct __ecereNameSpace__ecere__com__Application *)(((char *)((struct __ecereNameSpace__ecere__com__Module *)(((char *)fromModule + structSize_Instance)))->application + structSize_Module)))->allModules.first; module; module = ((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + structSize_Instance)))->next) { @@ -4283,6 +4282,8 @@ library = Instance_Module_Load(libLocation, name, &Load, &Unload); } if(Load) { +if(setInsideCrossBuild32) +__ecereNameSpace__ecere__com__insideCrossBuild32++; module = (struct __ecereNameSpace__ecere__com__Instance *)__ecereNameSpace__ecere__com__eInstance_New(__ecereNameSpace__ecere__com__eSystem_FindClass(fromModule, "Module")); ((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + structSize_Instance)))->application = ((struct __ecereNameSpace__ecere__com__Module *)(((char *)fromModule + structSize_Instance)))->application; ((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + structSize_Instance)))->library = library; @@ -4294,6 +4295,8 @@ if(!Load(module)) __ecereNameSpace__ecere__com__eInstance_Delete((struct __ecereNameSpace__ecere__com__Instance *)module); module = (((void *)0)); } +if(setInsideCrossBuild32) +__ecereNameSpace__ecere__com__insideCrossBuild32--; } __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add(&((struct __ecereNameSpace__ecere__com__Application *)(((char *)((struct __ecereNameSpace__ecere__com__Module *)(((char *)fromModule + structSize_Instance)))->application + structSize_Module)))->allModules, module); } @@ -4313,6 +4316,8 @@ if(!module) { Load = __ecereDll_Load_ecere; Unload = __ecereDll_Unload_ecere; +if(setInsideCrossBuild32) +__ecereNameSpace__ecere__com__insideCrossBuild32++; module = (struct __ecereNameSpace__ecere__com__Instance *)__ecereNameSpace__ecere__com__eInstance_New(__ecereNameSpace__ecere__com__eSystem_FindClass(fromModule, "Module")); ((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + structSize_Instance)))->application = ((struct __ecereNameSpace__ecere__com__Module *)(((char *)fromModule + structSize_Instance)))->application; ((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + structSize_Instance)))->library = (((void *)0)); @@ -4323,6 +4328,8 @@ if(!Load(module)) __ecereNameSpace__ecere__com__eInstance_Delete((struct __ecereNameSpace__ecere__com__Instance *)module); module = (((void *)0)); } +if(setInsideCrossBuild32) +__ecereNameSpace__ecere__com__insideCrossBuild32--; __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add(&((struct __ecereNameSpace__ecere__com__Application *)(((char *)((struct __ecereNameSpace__ecere__com__Module *)(((char *)fromModule + structSize_Instance)))->application + structSize_Module)))->allModules, module); } if(module) @@ -4836,6 +4843,8 @@ void __ecereNameSpace__ecere__com__eInstance_FireWatchers(struct __ecereNameSpac { if(instance && _property && _property->isWatchable) { +if(!__ecereNameSpace__ecere__com__insideCrossBuild32) +{ struct __ecereNameSpace__ecere__sys__OldList * watchers = (struct __ecereNameSpace__ecere__sys__OldList *)((unsigned char *)instance + _property->watcherOffset); struct __ecereNameSpace__ecere__com__Watcher * watcher, * next; @@ -4846,6 +4855,7 @@ watcher->callback(watcher->object, instance); } } } +} void __ecereNameSpace__ecere__com__eProperty_Watchable(struct __ecereNameSpace__ecere__com__Property * _property) { diff --git a/compiler/bootstrap/ecs/bootstrap/ecs.c b/compiler/bootstrap/ecs/bootstrap/ecs.c index 52ab172..bcc8fe9 100644 --- a/compiler/bootstrap/ecs/bootstrap/ecs.c +++ b/compiler/bootstrap/ecs/bootstrap/ecs.c @@ -2201,6 +2201,8 @@ extern void SetTargetPlatform(int platform); extern void SetTargetBits(int bits); +extern void SetInSymbolGen(unsigned int b); + extern struct __ecereNameSpace__ecere__com__Instance * __ecereNameSpace__ecere__com____ecere_COM_Initialize(unsigned int guiApp, int argc, char * argv[]); extern void SetPrivateModule(struct __ecereNameSpace__ecere__com__Instance * module); @@ -2422,6 +2424,7 @@ SetTopContext(theGlobalContext); SetCurrentContext(theGlobalContext); SetTargetPlatform(targetPlatform); SetTargetBits(targetBits); +SetInSymbolGen(0x1); privateModule = (struct __ecereNameSpace__ecere__com__Instance *)__ecereNameSpace__ecere__com____ecere_COM_Initialize(0x1 | (targetBits == sizeof(uintptr_t) * 8 ? (unsigned int)0 : targetBits == 64 ? (unsigned int)2 : targetBits == 32 ? (unsigned int)4 : (unsigned int)0) | (unsigned int)8, 1, (((void *)0))); SetPrivateModule(privateModule); mainModule = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_ModuleImport); diff --git a/compiler/bootstrap/libec/bootstrap/loadSymbols.c b/compiler/bootstrap/libec/bootstrap/loadSymbols.c index 044976f..2722edc 100644 --- a/compiler/bootstrap/libec/bootstrap/loadSymbols.c +++ b/compiler/bootstrap/libec/bootstrap/loadSymbols.c @@ -614,6 +614,13 @@ void SetInPreCompiler(unsigned int b) inPreCompiler = b; } +unsigned int inSymbolGen = 0x0; + +void SetInSymbolGen(unsigned int b) +{ +inSymbolGen = b; +} + struct __ecereNameSpace__ecere__sys__OldList * precompDefines; void SetPrecompDefines(struct __ecereNameSpace__ecere__sys__OldList * list) @@ -1735,7 +1742,7 @@ char file[274]; strcpy(file, name); __ecereNameSpace__ecere__sys__StripExtension(file); -if(!inCompiler) +if(!inCompiler && !inPreCompiler && !inSymbolGen) { struct __ecereNameSpace__ecere__com__MapIterator it = (it.container = (void *)0, it.pointer = (void *)0, __ecereProp___ecereNameSpace__ecere__com__MapIterator_Set_map(&it, loadedModules), it); @@ -1990,6 +1997,7 @@ __ecereNameSpace__ecere__com__eSystem_RegisterFunction("SetSysIncludeDirs", "voi __ecereNameSpace__ecere__com__eSystem_RegisterFunction("SetEcereImported", "void SetEcereImported(bool b)", SetEcereImported, module, 1); __ecereNameSpace__ecere__com__eSystem_RegisterFunction("GetEcereImported", "bool GetEcereImported(void)", GetEcereImported, module, 1); __ecereNameSpace__ecere__com__eSystem_RegisterFunction("SetInPreCompiler", "void SetInPreCompiler(bool b)", SetInPreCompiler, module, 1); +__ecereNameSpace__ecere__com__eSystem_RegisterFunction("SetInSymbolGen", "void SetInSymbolGen(bool b)", SetInSymbolGen, module, 1); __ecereNameSpace__ecere__com__eSystem_RegisterFunction("SetPrecompDefines", "void SetPrecompDefines(ecere::sys::OldList * list)", SetPrecompDefines, module, 1); __ecereNameSpace__ecere__com__eSystem_RegisterFunction("DummyMethod", "bool DummyMethod(void)", DummyMethod, module, 1); __ecereNameSpace__ecere__com__eSystem_RegisterFunction("LoadSymbols", "bool LoadSymbols(char * fileName, ecere::com::ImportType importType, bool loadDllOnly)", LoadSymbols, module, 1); diff --git a/compiler/ecs/ecs.ec b/compiler/ecs/ecs.ec index 5984fb9..fd06ebd 100644 --- a/compiler/ecs/ecs.ec +++ b/compiler/ecs/ecs.ec @@ -1725,6 +1725,7 @@ class SymbolgenApp : Application SetCurrentContext(theGlobalContext); SetTargetPlatform(targetPlatform); SetTargetBits(targetBits); + SetInSymbolGen(true); privateModule = (Module)__ecere_COM_Initialize(true | (targetBits == sizeof(uintptr)*8 ? 0 : targetBits == 64 ? 2 : targetBits==32 ? 4 : 0) | 8, 1, null); SetPrivateModule(privateModule); diff --git a/compiler/libec/locale/ec.pot b/compiler/libec/locale/ec.pot index 0012989..8c341b7 100644 --- a/compiler/libec/locale/ec.pot +++ b/compiler/libec/locale/ec.pot @@ -44,7 +44,7 @@ msgstr "Couldn't determine type of array elements\n" msgid "Couldn't find member %s to override\n" msgstr "Couldn't find member %s to override\n" -#: ./src/loadSymbols.ec:716 +#: ./src/loadSymbols.ec:718 msgid "Couldn't open %s\n" msgstr "Couldn't open %s\n" @@ -126,7 +126,7 @@ msgstr "Public %s making use of a private class\n" msgid "Recursion in defined expression %s\n" msgstr "Recursion in defined expression %s\n" -#: ./src/loadSymbols.ec:1000 +#: ./src/loadSymbols.ec:1002 msgid "Redefinition of %s (defining as %s, already defined as %s)\n" msgstr "Redefinition of %s (defining as %s, already defined as %s)\n" diff --git a/compiler/libec/src/loadSymbols.ec b/compiler/libec/src/loadSymbols.ec index cb6cfb7..938b9c1 100644 --- a/compiler/libec/src/loadSymbols.ec +++ b/compiler/libec/src/loadSymbols.ec @@ -33,6 +33,8 @@ bool ecereImported; public void SetEcereImported(bool b) { ecereImported = b; } public bool GetEcereImported() { return ecereImported; } bool inPreCompiler = false; public void SetInPreCompiler(bool b) {inPreCompiler = b; } +bool inSymbolGen = false; +public void SetInSymbolGen(bool b) {inSymbolGen = b; } OldList * precompDefines; public void SetPrecompDefines(OldList * list) { precompDefines = list; } @@ -787,7 +789,7 @@ public void ImportModule(char * name, ImportType importType, AccessMode importAc // Load an extra instance of any shared module to ensure freeing up a // module loaded in another file will not invalidate our objects. - if(!inCompiler) + if(!inCompiler && !inPreCompiler && !inSymbolGen) { MapIterator > it { map = loadedModules }; if(!it.Index(file, false)) diff --git a/deps/libffi-3.0.11/ffi.epj b/deps/libffi-3.0.11/ffi.epj index 4084e4f..1256f25 100644 --- a/deps/libffi-3.0.11/ffi.epj +++ b/deps/libffi-3.0.11/ffi.epj @@ -39,8 +39,6 @@ { "Folder" : "x86", "Files" : [ - "ffi.c", - "ffitarget.h", "win32.S" ] }, @@ -54,7 +52,9 @@ "raw_api.c", "types.c", "closures.c", - "i686-pc-mingw32/include/ffi.h" + "i686-pc-mingw32/include/ffi.h", + "src/x86/ffi.c", + "src/x86/ffitarget.h" ] } ], diff --git a/ecere/src/com/instance.ec b/ecere/src/com/instance.ec index 5b9e157..86ca1f1 100644 --- a/ecere/src/com/instance.ec +++ b/ecere/src/com/instance.ec @@ -1906,6 +1906,8 @@ public void CheckMemory() #endif } +static int insideCrossBuild32; + static void FixDerivativesBase(Class base, Class mod) { OldLink derivative; @@ -2591,6 +2593,8 @@ public dllexport Class eSystem_RegisterClass(ClassType type, char * name, char * if(strstr(name, "ecere::sys::EARHeader") || strstr(name, "AnchorValue") || !strcmp(name, "ecere::com::CustomAVLTree") || + !strcmp(name, "ecere::com::Array") || + !strcmp(name, "ecere::gui::Window") || !strcmp(name, "ecere::sys::Mutex")); // Never recompute these, they're always problematic (errors, crashes) else { @@ -4349,21 +4353,15 @@ public dllexport void * eInstance_New(Class _class) #endif { int size = _class.structSize; - Module module = _class.module; - Application application = module ? module.application : null; - int flags = application ? application.isGUIApp : 0; - bool inCompiler = (flags & 8) ? true : false; - if(inCompiler) - { - bool force32Bits = (flags & 4) ? true : false; - if(force32Bits) - { - // Allocate 64 bit sizes for these when cross-compiling for 32 bit to allow loaded libraries to work properly - if(!strcmp(_class.name, "Module")) - size = 560; - else if(_class.templateClass && !strcmp(_class.templateClass.name, "Map")) - size = 40; - } + if(insideCrossBuild32) + { + // Allocate 64 bit sizes for these when cross-compiling for 32 bit to allow loaded libraries to work properly + if(!strcmp(_class.name, "Module")) + size = 560; + else if(_class.templateClass && !strcmp(_class.templateClass.name, "Map")) + size = 40; + else + size *= 3; } instance = _calloc(1, size); } @@ -5149,6 +5147,10 @@ static Module Module_Load(Module fromModule, char * name, AccessMode importAcces bool (stdcall * Load)(Module module) = null; bool (stdcall * Unload)(Module module) = null; Module module; + int flags = fromModule.application.isGUIApp; + bool inCompiler = (flags & 8) ? true : false; + bool force32Bits = (flags & 4) ? true : false; + bool setInsideCrossBuild32 = force32Bits && inCompiler; for(module = fromModule.application.allModules.first; module; module = module.next) { @@ -5182,17 +5184,24 @@ static Module Module_Load(Module fromModule, char * name, AccessMode importAcces } if(Load) { + if(setInsideCrossBuild32) + insideCrossBuild32++; + module = (Module)eInstance_New(eSystem_FindClass(fromModule, "Module")); module.application = fromModule.application; module.library = library; module.name = CopyString(name); module.Unload = Unload; module.origImportType = normalImport; + if(!Load(module)) { eInstance_Delete((Instance)module); module = null; } + + if(setInsideCrossBuild32) + insideCrossBuild32--; } fromModule.application.allModules.Add(module); } @@ -5213,16 +5222,23 @@ static Module Module_Load(Module fromModule, char * name, AccessMode importAcces Load = COM_LOAD_FUNCTION; Unload = COM_UNLOAD_FUNCTION; + if(setInsideCrossBuild32) + insideCrossBuild32++; + module = (Module)eInstance_New(eSystem_FindClass(fromModule, "Module")); module.application = fromModule.application; module.library = null; module.name = CopyString(name); module.Unload = Unload; + if(!Load(module)) { eInstance_Delete((Instance)module); module = null; } + + if(setInsideCrossBuild32) + insideCrossBuild32--; fromModule.application.allModules.Add(module); } if(module) @@ -5764,13 +5780,16 @@ public dllexport void eInstance_FireWatchers(Instance instance, Property _proper { if(instance && _property && _property.isWatchable) { - OldList * watchers = (OldList *)((byte *)instance + _property.watcherOffset); - Watcher watcher, next; - - for(watcher = watchers->first; watcher; watcher = next) + if(!insideCrossBuild32) { - next = watcher.next; - watcher.callback(watcher.object, instance); + OldList * watchers = (OldList *)((byte *)instance + _property.watcherOffset); + Watcher watcher, next; + + for(watcher = watchers->first; watcher; watcher = next) + { + next = watcher.next; + watcher.callback(watcher.object, instance); + } } } }