compiler/libec; ecere: Fixed MemoryGuard config warnings
authorJerome St-Louis <jerome@ecere.com>
Thu, 12 Jun 2014 21:55:44 +0000 (17:55 -0400)
committerJerome St-Louis <jerome@ecere.com>
Thu, 12 Jun 2014 21:55:44 +0000 (17:55 -0400)
compiler/bootstrap/libec/bootstrap/output.c
compiler/bootstrap/libec/bootstrap/pass15.c
compiler/libec/src/output.ec
compiler/libec/src/pass15.ec
ecere/src/com/instance.ec

index b423aaa..7addbb3 100644 (file)
@@ -1973,6 +1973,8 @@ extern void ListAdd(struct __ecereNameSpace__ecere__sys__OldList * list, void *
 
 extern struct Specifier * MkSpecifierName(const char *  name);
 
+extern char *  strcpy(char * , const char * );
+
 extern void PrintType(struct Type * type, char *  string, unsigned int printName, unsigned int fullName);
 
 extern struct TypeName * MkTypeName(struct __ecereNameSpace__ecere__sys__OldList * qualifiers, struct Declarator * declarator);
@@ -2400,6 +2402,9 @@ decl = MkDeclaratorIdentifier(MkIdentifier("__ecereReturnVal"));
 }
 else
 {
+if(returnType->passAsTemplate)
+strcpy(string, "uint64");
+else
 PrintType(returnType, string, returnType->kind == 18 ? 1 : 0, 1);
 decl = SpecDeclFromString(string, specs, MkDeclaratorIdentifier(MkIdentifier("__ecereReturnVal")));
 }
@@ -3316,8 +3321,6 @@ OutputInitializer(decl->initializer, f);
 }
 }
 
-extern char *  strcpy(char * , const char * );
-
 static void OutputDeclaration(struct Declaration * decl, struct __ecereNameSpace__ecere__com__Instance * f)
 {
 struct Specifier * spec;
index 3d7ba7a..e6bfe59 100644 (file)
@@ -18887,6 +18887,8 @@ DeclareFunction(function, name);
 
 extern struct __ecereNameSpace__ecere__com__Instance * GetPrivateModule(void);
 
+extern unsigned int memoryGuard;
+
 void ComputeDataTypes()
 {
 struct External * external;
@@ -18957,6 +18959,11 @@ DeclareFunctionUtil("eInstance_IncRef");
 DeclareFunctionUtil("eInstance_StopWatching");
 DeclareFunctionUtil("eInstance_Watch");
 DeclareFunctionUtil("eInstance_FireWatchers");
+if(memoryGuard)
+{
+DeclareFunctionUtil("MemoryGuard_PushLoc");
+DeclareFunctionUtil("MemoryGuard_PopLoc");
+}
 DeclareStruct("ecere::com::Class", 0);
 DeclareStruct("ecere::com::Instance", 0);
 DeclareStruct("ecere::com::Property", 0);
index cefa2cf..e7097b3 100644 (file)
@@ -625,7 +625,10 @@ static void OutputStatement(Statement stmt, File f)
                else
                {
                   // Printing 'name' as a hack when we're dealing with typedefs with extended attributes
-                  PrintType /*NoConst*/(returnType, string, returnType.kind == dummyType ? true : false, true);
+                  if(returnType.passAsTemplate)
+                     strcpy(string, "uint64");
+                  else
+                     PrintType /*NoConst*/(returnType, string, returnType.kind == dummyType ? true : false, true);
                   decl = SpecDeclFromString(string, specs, MkDeclaratorIdentifier(MkIdentifier("__ecereReturnVal")));
                }
 
index abfe0ed..4d66c54 100644 (file)
@@ -13236,6 +13236,11 @@ void ComputeDataTypes()
    DeclareFunctionUtil("eInstance_StopWatching");
    DeclareFunctionUtil("eInstance_Watch");
    DeclareFunctionUtil("eInstance_FireWatchers");
+   if(memoryGuard)
+   {
+      DeclareFunctionUtil("MemoryGuard_PushLoc");
+      DeclareFunctionUtil("MemoryGuard_PopLoc");
+   }
 
    DeclareStruct("ecere::com::Class", false);
    DeclareStruct("ecere::com::Instance", false);
index 43b3ed8..4cfc36a 100644 (file)
@@ -32,10 +32,11 @@ import "Mutex"
 #ifdef MEMINFO
 import "Thread"
 static define MAX_MEMORY_LOC = 40;
+static define MAX_STACK_FRAMES = 1000;
 
 static class MemStack : BTNode
 {
-   const char * frames[1000];
+   const char * frames[MAX_STACK_FRAMES];
    int pos;
    bool recurse;
 };
@@ -153,10 +154,8 @@ public dllexport void MemoryGuard_PushLoc(const char * loc)
       stack.key = GetCurrentThreadID();
       memStacks.Add(stack);
    }
-   if(stack.pos < 1000)
+   if(stack.pos < MAX_STACK_FRAMES)
       stack.frames[stack.pos++] = loc;
-   else
-      printf("");
    memMutex.Release();
 #endif
 }
@@ -171,8 +170,6 @@ public dllexport void MemoryGuard_PopLoc()
    {
       stack.pos--;
    }
-   else
-      printf("");
    memMutex.Release();
 #endif
 }
@@ -628,8 +625,8 @@ static class MemInfo : BTNode //struct
    bool freed;
    const char * _class;
    uint id;
-   const char * allocLoc[MAX_MEMORY_LOC];
-   const char * freeLoc[MAX_MEMORY_LOC];
+   char * allocLoc[MAX_MEMORY_LOC];
+   char * freeLoc[MAX_MEMORY_LOC];
    bool internal;
 
    void OutputStacks(bool showFree)
@@ -663,13 +660,15 @@ static BinaryTree memBlocks;
 bool recurse = false;
 static int blockID;
 //Class allocateClass;
-const char * allocateClass;
+char * allocateClass;
 bool allocateInternal;
 
 #endif
 
 static uint TOTAL_MEM = 0;
+#ifndef MEMINFO
 static uint OUTSIDE_MEM = 0;
+#endif
 
 #if !defined(ECERE_BOOTSTRAP)
 static Mutex memMutex { };
@@ -1046,6 +1045,7 @@ private struct BlockPool
    }
 };
 
+#ifndef MEMINFO
 static BlockPool * pools; //[NUM_POOLS];
 
 /*static uint PosFibonacci(uint number)
@@ -1096,6 +1096,7 @@ static uint NextFibonacci(uint number)
    }
 }
 */
+
 static uint log1_5i(uint number)
 {
    uint pos;
@@ -1137,6 +1138,7 @@ static uint pow1_5i(uint number)
    }
    return (uint)current;
 }
+#endif
 
 // -- Math Helpers ---
 public uint log2i(uint number)
@@ -1154,6 +1156,7 @@ public uint pow2i(uint number)
    return 1<<log2i(number);
 }
 
+#ifndef MEMINFO
 static bool memoryInitialized = false;
 static void InitMemory()
 {
@@ -1177,7 +1180,9 @@ static void InitMemory()
          pools[c].Expand(Max(1, expansion));
    }
 }
+#endif
 
+#ifndef MEMINFO
 static void * _mymalloc(unsigned int size)
 {
    MemBlock block = null;
@@ -1217,6 +1222,7 @@ static void * _mycalloc(int n, unsigned int size)
    return pointer;
 }
 
+
 static void _myfree(void * pointer)
 {
    if(pointer)
@@ -1346,6 +1352,7 @@ static void * _mycrealloc(void * pointer, unsigned int size)
    }
    return newPointer;
 }
+#endif
 
 #ifndef MEMINFO
 #undef realloc
@@ -1858,7 +1865,7 @@ public void CheckMemory()
       }
    }
 
-   while(block = (MemInfo)memBlocks.root)
+   while((block = (MemInfo)memBlocks.root))
    {
       byte * address;
       int c;
@@ -1906,7 +1913,7 @@ public void CheckMemory()
    printf("Memory Check Completed.\n");
 #if defined(__WIN32__) && !defined(ECERE_BOOTSTRAP)
    if(memoryErrorsCount)
-      getch();
+      system("pause");
 #endif
 #endif
 }