compiler: Fixed prototypes for new/new0/renew/renew0; Added check to default to host...
authorJerome St-Louis <jerome@ecere.com>
Tue, 5 Feb 2013 14:45:11 +0000 (09:45 -0500)
committerJerome St-Louis <jerome@ecere.com>
Sat, 16 Feb 2013 06:02:52 +0000 (01:02 -0500)
compiler/ecc/ecc.ec
compiler/ecp/ecp.ec
compiler/ecs/ecs.ec
compiler/libec/src/ecdefs.ec
compiler/libec/src/pass15.ec

index 586c67b..d473cd6 100644 (file)
@@ -128,7 +128,7 @@ class CompilerApp : Application
       char defaultOutputFile[MAX_LOCATION];
 
       Platform targetPlatform = GetRuntimePlatform();
-      int targetBits = (sizeof(uintptr) == 8) ? 64 : 32;
+      int targetBits = GetHostBits();
 
       SetSymbolsDir("");
 
index d9aeb50..73c77cb 100644 (file)
@@ -1292,7 +1292,7 @@ class PrecompApp : Application
       int argc = 0;*/
 
       Platform targetPlatform = GetRuntimePlatform();
-      int targetBits = (sizeof(uintptr) == 8) ? 64 : 32;
+      int targetBits = GetHostBits();
       /*
       for(c = 0; c<this.argc; c++)
       {
index a1288b5..2d0c9bb 100644 (file)
@@ -10,7 +10,7 @@ static define localeDir = "locale";
 static bool i18n;
 
 static Platform targetPlatform;
-static int targetBits = (sizeof(uintptr) == 8) ? 64 : 32;
+static int targetBits;
 
 static bool isConsole;
 static bool isDynamicLibrary;
@@ -1617,6 +1617,7 @@ class SymbolgenApp : Application
       char * output = null;
 
       targetPlatform = GetRuntimePlatform();
+      targetBits = GetHostBits();
 
       /*
       for(c = 0; c<this.argc; c++)
index a01642a..62e0572 100644 (file)
@@ -1325,6 +1325,32 @@ int yyerror(char * s)
 
 Platform targetPlatform;
 
+public int GetHostBits()
+{
+   // Default to runtime platform in case we fail to determine host
+   int hostBits = (sizeof(uintptr) == 8) ? 64 : 32;
+   String hostType = getenv("HOSTTYPE");
+   char host[256];
+   if(!hostType)
+   {
+      DualPipe f = DualPipeOpen({ output = true }, "uname -m");
+      if(f)
+      {
+         if(f.GetLine(host, sizeof(host)))
+            hostType = host;
+         delete f;
+      }
+   }
+   if(hostType)
+   {
+      if(!strcmp(hostType, "x86_64"))
+         hostBits = 64;
+      else if(!strcmp(hostType, "i386") || !strcmp(hostType, "i686"))
+         hostBits = 32;
+   }
+   return hostBits;
+}
+
 public void SetTargetPlatform(Platform platform) { targetPlatform = platform; };
 
 int targetBits;
index 5a287e8..78b56e4 100644 (file)
@@ -12151,6 +12151,20 @@ static void ProcessClass(OldList definitions, Symbol symbol)
    }
 }
 
+void DeclareFunctionUtil(String s)
+{
+   GlobalFunction function = eSystem_FindFunction(privateModule, s);
+   if(function)
+   {
+      char name[1024];
+      name[0] = 0;
+      if(function.module.importType != staticImport && (!function.dataType || !function.dataType.dllExport))
+         strcpy(name, "__ecereFunction_");
+      FullClassNameCat(name, s, false); // Why is this using FullClassNameCat ?
+      DeclareFunction(function, name);
+   }
+}
+
 void ComputeDataTypes()
 {
    External external;
@@ -12167,6 +12181,11 @@ void ComputeDataTypes()
 
    curExternal = temp;
 
+   DeclareFunctionUtil("eSystem_New");
+   DeclareFunctionUtil("eSystem_New0");
+   DeclareFunctionUtil("eSystem_Renew");
+   DeclareFunctionUtil("eSystem_Renew0");
+
    DeclareStruct("ecere::com::Class", false);
    DeclareStruct("ecere::com::Instance", false);
    DeclareStruct("ecere::com::Property", false);