Browse Source

64bit address target

Greg 15 years ago
parent
commit
b1a7f0241a

+ 3 - 0
gmsrc/doc/ChangeLog.txt

@@ -362,3 +362,6 @@ o Fix GC auto calibration. Thanks DrEvil.
 27/05/10
 o Improved Minimal example.  Not all errors were logged. Also enabled debug mode. Thanks xaxa.
 
+09/07/10
+o Updated code base for 64bit address target. (64bit builds of current binaries not made or tested yet.) 
+o Updated system lib for 64bit Win OS compatibility.

+ 1 - 1
gmsrc/src/binds/gmGCRootUtil.h

@@ -121,7 +121,7 @@ public:
   // Return number of elements in array
   int GetSize()
   {
-    return m_array.size();
+    return (int)m_array.size();
   }
 
   // Return last index eg. GetSize()-1

+ 7 - 7
gmsrc/src/binds/gmStringLib.cpp

@@ -269,7 +269,7 @@ static int GM_CDECL gmfStringSpanIncluding(gmThread * a_thread)
     const char * thisStr = (const char *) *strObj;
     const char * otherStr = a_thread->ParamString(0);
     
-    int offset = strspn(thisStr, otherStr);
+    int offset = (int)strspn(thisStr, otherStr);
     char * buffer = (char *) alloca(offset + 1);
     memcpy(buffer, thisStr, offset);
     buffer[offset] = 0;
@@ -297,7 +297,7 @@ static int GM_CDECL gmfStringSpanExcluding(gmThread * a_thread)
     const char * thisStr = (const char *) *strObj;
     const char * otherStr = a_thread->ParamString(0);
     
-    int offset = strcspn(thisStr, otherStr);
+    int offset = (int)strcspn(thisStr, otherStr);
     char * buffer = (char *) alloca(offset + 1);
     memcpy(buffer, thisStr, offset);
     buffer[offset] = 0;
@@ -434,7 +434,7 @@ static int GM_CDECL gmfStringReplaceCharsInSet(gmThread * a_thread)
 
   for(;;)
   {
-    validPos = strcspn(buffer, invalidCharSet);
+    validPos = (int)strcspn(buffer, invalidCharSet);
     if(validPos != lenA)
     {
       buffer[validPos] = repChar;
@@ -591,7 +591,7 @@ static int GM_CDECL gmStringReverse(gmThread * a_thread)
   gmStringObject * strObj = (gmStringObject *) GM_OBJECT(var->m_value.m_ref);
   const char * str = (const char *) *strObj;
 
-  int len = strlen(str);
+  int len = (int)strlen(str);
   if(len > 0)
   {
     char * buffer = (char *) alloca(len + 1); 
@@ -818,7 +818,7 @@ static int GM_CDECL gmStringGetFilenameNoExt(gmThread * a_thread)
   while (--lpsz >= buffer && *lpsz != '\\' && *lpsz != '/') {}
 
   buffer = ++lpsz;
-  strLength = strlen(buffer);
+  strLength = (int)strlen(buffer);
   lpsz = buffer + strLength;
   while (--lpsz >= buffer && *lpsz != '.') {}
   if(*lpsz == '.') *lpsz = 0;
@@ -884,12 +884,12 @@ static int GM_CDECL gmStringSetExtension(gmThread * a_thread)
 
   const char * str = (const char *) *strObj;
   int strLength = strObj->GetLength();
-  int extLength = strlen(newExt);
+  int extLength = (int)strlen(newExt);
 
   if (extLength && newExt[0] == '.')
   {
     ++newExt;
-    extLength = strlen(newExt);
+    extLength = (int)strlen(newExt);
   }
 
   char *buffer = (char *) alloca(strLength + 1 + extLength);

+ 39 - 12
gmsrc/src/binds/gmSystemLib.cpp

@@ -201,8 +201,6 @@ static void GM_CDECL gmFileOpGetDot(gmThread * a_thread, gmVariable * a_operands
   {
     gmStringObject * member = (gmStringObject *) GM_OBJECT(a_operands[1].m_value.m_ref);
 
-    GM_ASSERT(sizeof(gmptr) == sizeof(time_t));
-
     if(strcmp(member->GetString(), "SEEK_CUR") == 0)
       a_operands->SetInt(SEEK_CUR);
     else if(strcmp(member->GetString(), "SEEK_END") == 0)
@@ -268,7 +266,7 @@ static int GM_CDECL gmfFileReadLine(gmThread * a_thread) // flag keep \n (0), re
     char * str = fgets(buffer, len, (FILE *) fileObject->m_user);
     if(str)
     {
-      int slen = strlen(str);
+      int slen = (int)strlen(str);
       if(!keepLF)
       {
         if(!feof((FILE *) fileObject->m_user))
@@ -413,7 +411,25 @@ static int GM_CDECL gmfFileInfo(gmThread * a_thread)
 {
   GM_CHECK_NUM_PARAMS(1);
   GM_CHECK_STRING_PARAM(filename, 0);
-  
+
+#if 1 // Compatible with 64bit OS
+  struct _stat32 buf;
+  int fh, result;
+
+  if((fh = _open(filename, _O_RDONLY)) ==  -1) return GM_OK; // return null
+  result = _fstat32(fh, &buf); // Get data associated with "fh"
+  if(result == 0) //function obtained data correctly (0 == success, -1 == fail)
+  {
+    // create and push a gmFileInfoUser object
+    gmFileInfoUser * fileInfo = (gmFileInfoUser *) a_thread->GetMachine()->Sys_Alloc(sizeof(gmFileInfoUser));
+    fileInfo->m_creationTime = buf.st_ctime;
+    fileInfo->m_accessedTime = buf.st_atime;
+    fileInfo->m_modifiedTime = buf.st_mtime;
+    fileInfo->m_size = buf.st_size;
+    a_thread->PushNewUser(fileInfo, s_gmFileInfoType);
+  }
+  _close( fh );
+#else  
   struct _stat buf;
   int fh, result;
 
@@ -430,6 +446,7 @@ static int GM_CDECL gmfFileInfo(gmThread * a_thread)
     a_thread->PushNewUser(fileInfo, s_gmFileInfoType);
   }
   _close( fh );
+#endif
   return GM_OK;
 }
 
@@ -476,7 +493,7 @@ bool RecurseDeletePath(const char * a_path)
   strcpy(path,a_path);
 
   // remove trailing '\' char
-  int last = strlen(path) - 1;
+  int last = (int)strlen(path) - 1;
   if(path[last] == '\\')
   {
     path[last] = '\0';
@@ -567,11 +584,19 @@ static int GM_CDECL gmfDeleteFolder(gmThread * a_thread)
 
 static int GM_CDECL gmfTime(gmThread * a_thread)
 {
+#if 1 // Compatible with 64bit OS
+  __time32_t t;
+  _time32(&t);
+  GM_ASSERT(sizeof(t) <= sizeof(gmint));
+  a_thread->PushInt(t);
+  return GM_OK;
+#else
   time_t t;
   time(&t);
-  GM_ASSERT(sizeof(time_t) == sizeof(gmptr));
-  a_thread->PushInt((gmptr) t);
+  GM_ASSERT(sizeof(time_t) <= sizeof(gmptr));
+  a_thread->PushInt(t);
   return GM_OK;
+#endif
 }
 
 
@@ -694,16 +719,18 @@ static void GM_CDECL gmFileInfoOpGetDot(gmThread * a_thread, gmVariable * a_oper
     gmFileInfoUser * fileInfo = (gmFileInfoUser *) user->m_user;
     gmStringObject * member = (gmStringObject *) GM_OBJECT(a_operands[1].m_value.m_ref);
 
-    GM_ASSERT(sizeof(gmptr) == sizeof(time_t));
+    GM_ASSERT(sizeof(fileInfo->m_creationTime) <= sizeof(gmint));
+
+    // NOTE: Not valid or tested for 64bit target
 
     if(strcmp(member->GetString(), "creationTime") == 0)
-      a_operands->SetInt((gmptr) fileInfo->m_creationTime);
+      a_operands->SetInt((gmint) fileInfo->m_creationTime);
     else if(strcmp(member->GetString(), "accessedTime") == 0)
-      a_operands->SetInt((gmptr) fileInfo->m_accessedTime);
+      a_operands->SetInt((gmint) fileInfo->m_accessedTime);
     else if(strcmp(member->GetString(), "modifiedTime") == 0)
-      a_operands->SetInt((gmptr) fileInfo->m_modifiedTime);
+      a_operands->SetInt((gmint) fileInfo->m_modifiedTime);
     else if(strcmp(member->GetString(), "size") == 0)
-      a_operands->SetInt((gmptr) fileInfo->m_size);
+      a_operands->SetInt((gmint) fileInfo->m_size);
     else
     {
       a_operands->Nullify();

+ 2 - 2
gmsrc/src/gm/bison.simple

@@ -290,7 +290,7 @@ yynewstate:
 #endif
 
       /* Get the current used size of the three stacks, in elements.  */
-      int size = yyssp - yyss + 1;
+      int size = (int)(yyssp - yyss + 1); // _GD_ cast for 64bit build
 
 #ifdef yyoverflow
       /* Each stack pointer address is followed by the size of
@@ -562,7 +562,7 @@ yyerrlab:   /* here on detecting error */
           for (x = (yyn < 0 ? -yyn : 0);
                x < (int)(sizeof(yytname) / sizeof(char *)); x++) //_GD_
             if (yycheck[x + yyn] == x)
-              size += strlen(yytname[x]) + 15, count++;
+              size += (int)strlen(yytname[x]) + 15, count++; // _GD_ add cast for 64bit build
           //_GD_ msg = (char *) malloc(size + 15);
           msg = GM_NEW( char [size + 15] );
           if (msg != 0)

+ 12 - 5
gmsrc/src/gm/gmByteCode.cpp

@@ -27,14 +27,15 @@ void gmByteCodePrint(FILE * a_fp, const void * a_byteCode, int a_byteCodeLength)
   const gmuint8 * end = instruction + a_byteCodeLength;
   const gmuint8 * start = instruction;
   const char * cp;
-  bool opiptr, opf32;
+  bool opiptr, opf32, opi32;
 
   while(instruction < end)
   {
     opiptr = false;
     opf32 = false;
+    opi32 = false;
 
-    int addr = instruction - start;
+    int addr = (int)(instruction - start);
 
     switch(*instruction)
     {
@@ -62,7 +63,7 @@ void gmByteCodePrint(FILE * a_fp, const void * a_byteCode, int a_byteCodeLength)
       case BC_DUP2 : cp = "dup2"; break;
       case BC_SWAP : cp = "swap"; break;
       case BC_PUSHNULL : cp = "push null"; break;
-      case BC_PUSHINT : cp = "push int"; opiptr = true; break;
+      case BC_PUSHINT : cp = "push int"; opi32 = true; break;
       case BC_PUSHINT0 : cp = "push int 0"; break;
       case BC_PUSHINT1 : cp = "push int 1"; break;
       case BC_PUSHFP : cp = "push fp"; opf32 = true; break;
@@ -71,8 +72,8 @@ void gmByteCodePrint(FILE * a_fp, const void * a_byteCode, int a_byteCodeLength)
       case BC_PUSHFN : cp = "push fn"; opiptr = true; break;
       case BC_PUSHTHIS : cp = "push this"; break;
       
-      case BC_GETLOCAL : cp = "get local"; opiptr = true; break;
-      case BC_SETLOCAL : cp = "set local"; opiptr = true; break;
+      case BC_GETLOCAL : cp = "get local"; opi32 = true; break;
+      case BC_SETLOCAL : cp = "set local"; opi32 = true; break;
       case BC_GETGLOBAL : cp = "get global"; opiptr = true; break;
       case BC_SETGLOBAL : cp = "set global"; opiptr = true; break;
       case BC_GETTHIS : cp = "get this"; opiptr = true; break;
@@ -117,6 +118,12 @@ void gmByteCodePrint(FILE * a_fp, const void * a_byteCode, int a_byteCodeLength)
       instruction += sizeof(gmint32);
       fprintf(a_fp, "  %04d %s %f"GM_NL, addr, cp, fval);
     }
+    if(opi32)
+    {
+      gmint32 ival = *((gmint32 *) instruction);
+      instruction += sizeof(gmint32);
+      fprintf(a_fp, "  %04d %s %d"GM_NL, addr, cp, ival);
+    }
     else if (opiptr)
     {
       gmptr ival = *((gmptr *) instruction);

+ 10 - 2
gmsrc/src/gm/gmCodeGen.cpp

@@ -19,7 +19,7 @@
 //static const char * s_tempVarName0 = "__t0"; // Currently not used
 static const char * s_tempVarName1 = "__t1";
 
-#define SIZEOF_BC_BRA   8
+#define SIZEOF_BC_BRA   (sizeof(gmuint32)+sizeof(gmptr)) // instruction + address
 
 /// \brief gmSortDebugLines will sort debug line information
 static void gmSortDebugLines(gmArraySimple<gmLineInfo> &a_lineInfo)
@@ -628,7 +628,11 @@ bool gmCodeGenPrivate::GenExprTable(const gmCodeTreeNode * a_node, gmByteCodeGen
     }
     else
     {
+#if 1 // 32bit Integers
+      a_byteCode->Emit(BC_PUSHINT, index++);
+#else
       a_byteCode->EmitPtr(BC_PUSHINT, index++);
+#endif
       if(!Generate(fields, a_byteCode, false)) return false;
       a_byteCode->Emit(BC_SETIND);
     }
@@ -793,7 +797,7 @@ bool gmCodeGenPrivate::GenStmtForEach(const gmCodeTreeNode * a_node, gmByteCodeG
     return false;
   }
 
-  a_byteCode->Emit(BC_BRA, (gmuint32) loc1);
+  a_byteCode->EmitPtr(BC_BRA, (gmuint32) loc1);
   breakAddress = a_byteCode->Seek(loc2);
   a_byteCode->EmitPtr(BC_BRZ, breakAddress);
   a_byteCode->Seek(breakAddress);
@@ -1268,7 +1272,11 @@ bool gmCodeGenPrivate::GenExprConstant(const gmCodeTreeNode * a_node, gmByteCode
       }
       else
       {
+#if 1 // 32bit Integers
+        a_byteCode->Emit(BC_PUSHINT, *((gmint *) &a_node->m_data.m_iValue));
+#else
         a_byteCode->EmitPtr(BC_PUSHINT, *((gmptr *) &a_node->m_data.m_iValue));
+#endif
       }
       break;
     }

+ 1 - 1
gmsrc/src/gm/gmConfig.h

@@ -27,7 +27,7 @@
 /// \enum gmEndian Endian byte order
 enum gmEndian
 {
-  GM_ENDIAN_BIG = 0,      //!< MOTOROLA (MAC), NINTENDO GC
+  GM_ENDIAN_BIG = 0,      //!< MOTOROLA (MAC), NINTENDO GC, Xbox360, PS3
   GM_ENDIAN_LITTLE = 1    //!< x86, XBOX, PS2
 };
 

+ 23 - 6
gmsrc/src/gm/gmDebug.cpp

@@ -79,8 +79,8 @@ void gmDebuggerSource(gmDebugSession * a_session, int a_sourceId, const char * a
 void gmDebuggerException(gmDebugSession * a_session, int a_threadId);
 
 void gmDebuggerBeginContext(gmDebugSession * a_session, int a_threadId, int a_callFrame);
-void gmDebuggerContextCallFrame(gmDebugSession * a_session, int a_callFrame, const char * a_functionName, int a_sourceId, int a_lineNumber, const char * a_thisSymbol, const char * a_thisValue, int a_thisId);
-void gmDebuggerContextVariable(gmDebugSession * a_session, const char * a_varSymbol, const char * a_varValue, int a_varId);
+void gmDebuggerContextCallFrame(gmDebugSession * a_session, int a_callFrame, const char * a_functionName, int a_sourceId, int a_lineNumber, const char * a_thisSymbol, const char * a_thisValue, gmptr a_thisId);
+void gmDebuggerContextVariable(gmDebugSession * a_session, const char * a_varSymbol, const char * a_varValue, gmptr a_varId);
 void gmDebuggerEndContext(gmDebugSession * a_session);
 
 void gmDebuggerBeginSourceInfo(gmDebugSession * a_session);
@@ -354,10 +354,19 @@ gmDebugSession &gmDebugSession::Pack(int a_val)
 }
 
 
+#ifdef GT_PTR_SIZE_64 // Only needed if types gmptr != gmint
+gmDebugSession &gmDebugSession::Pack(gmint64 a_val)
+{
+  m_out << a_val;
+  return *this;
+}
+#endif //GT_PTR_SIZE_64
+
+
 gmDebugSession &gmDebugSession::Pack(const char * a_val)
 {
   if(a_val)
-    m_out.Write(a_val, strlen(a_val) + 1);
+    m_out.Write(a_val, (unsigned int)strlen(a_val) + 1);
   else
     m_out.Write("", 1);
   return *this;
@@ -378,11 +387,19 @@ gmDebugSession &gmDebugSession::Unpack(int &a_val)
 }
 
 
+#ifdef GT_PTR_SIZE_64 // Only needed if types gmptr != gmint
+gmDebugSession &gmDebugSession::Unpack(gmint64 &a_val)
+{
+  if(m_in.Read(&a_val, sizeof(gmint64)) != sizeof(gmint64)) a_val = 0;
+  return *this;
+}
+#endif //GT_PTR_SIZE_64
+
 gmDebugSession &gmDebugSession::Unpack(const char * &a_val)
 {
   // this is dangerous!!!
   a_val = &m_in.GetData()[m_in.Tell()];
-  int len = strlen(a_val);
+  int len = (int)strlen(a_val);
   m_in.Seek(m_in.Tell() + len + 1);
   return *this;
 }
@@ -653,10 +670,10 @@ void gmDebuggerSource(gmDebugSession * a_session, int a_sourceId, const char * a
 void gmDebuggerBeginContext(gmDebugSession * a_session, int a_threadId, int a_callFrame) {
   a_session->Pack(ID_dctx).Pack(a_threadId).Pack(a_callFrame);
 }
-void gmDebuggerContextCallFrame(gmDebugSession * a_session, int a_callFrame, const char * a_functionName, int a_sourceId, int a_lineNumber, const char * a_thisSymbol, const char * a_thisValue, int a_thisId) {
+void gmDebuggerContextCallFrame(gmDebugSession * a_session, int a_callFrame, const char * a_functionName, int a_sourceId, int a_lineNumber, const char * a_thisSymbol, const char * a_thisValue, gmptr a_thisId) {
   a_session->Pack(ID_call).Pack(a_callFrame).Pack(a_functionName).Pack(a_sourceId).Pack(a_lineNumber).Pack(a_thisSymbol).Pack(a_thisValue).Pack(a_thisId);
 }
-void gmDebuggerContextVariable(gmDebugSession * a_session, const char * a_varSymbol, const char * a_varValue, int a_varId) {
+void gmDebuggerContextVariable(gmDebugSession * a_session, const char * a_varSymbol, const char * a_varValue, gmptr a_varId) {
   a_session->Pack(ID_vari).Pack(a_varSymbol).Pack(a_varValue).Pack(a_varId);
 }
 void gmDebuggerEndContext(gmDebugSession * a_session) {

+ 6 - 0
gmsrc/src/gm/gmDebug.h

@@ -54,11 +54,17 @@ public:
 
   // send message helpers
   gmDebugSession &Pack(int a_val);
+#ifdef GT_PTR_SIZE_64 // Only needed if types gmptr != gmint
+  gmDebugSession &Pack(gmint64 a_val);
+#endif //GT_PTR_SIZE_64 
   gmDebugSession &Pack(const char * a_val);
   void Send();
 
   // rcv message helpers
   gmDebugSession &Unpack(int &a_val);
+#ifdef GT_PTR_SIZE_64 // Only needed if types gmptr != gmint
+  gmDebugSession &Unpack(gmint64 &a_val);
+#endif //GT_PTR_SIZE_64 
   gmDebugSession &Unpack(const char * &a_val);
 
   // helpers

+ 3 - 3
gmsrc/src/gm/gmFunctionObject.cpp

@@ -146,11 +146,11 @@ bool gmFunctionObject::Init(gmMachine * a_machine, bool a_debug, gmFunctionInfo
         case BC_BRZK :
         case BC_BRNZK :
         case BC_FOREACH :
-        case BC_PUSHINT :
         case BC_GETGLOBAL :
         case BC_SETGLOBAL :
         case BC_GETTHIS :
         case BC_SETTHIS : instruction += sizeof(gmptr); break;
+        case BC_PUSHINT : instruction += sizeof(gmint); break;
         case BC_PUSHFP : instruction += sizeof(gmfloat); break;
       
         case BC_CALL :
@@ -198,7 +198,7 @@ bool gmFunctionObject::Init(gmMachine * a_machine, bool a_debug, gmFunctionInfo
     // debug name
     if(a_info.m_debugName)
     {
-      int len = strlen(a_info.m_debugName) + 1;
+      int len = (int)strlen(a_info.m_debugName) + 1;
       m_debugInfo->m_debugName = (char *) a_machine->Sys_Alloc(len);
       memcpy(m_debugInfo->m_debugName, a_info.m_debugName, len);
     }
@@ -210,7 +210,7 @@ bool gmFunctionObject::Init(gmMachine * a_machine, bool a_debug, gmFunctionInfo
       int i;
       for(i = 0; i < m_numParamsLocals; ++i)
       {
-        int len = strlen(a_info.m_symbols[i]) + 1;
+        int len = (int)strlen(a_info.m_symbols[i]) + 1;
         m_debugInfo->m_symbols[i] = (char *) a_machine->Sys_Alloc(len);
         memcpy(m_debugInfo->m_symbols[i], a_info.m_symbols[i], len);
       }

+ 1 - 1
gmsrc/src/gm/gmFunctionObject.h

@@ -87,7 +87,7 @@ public:
 
   /// \brief GetLine() will return the source line for the given address
   int GetLine(int a_address) const;
-  int GetLine(const void * a_instruction) const { return GetLine((const char * ) a_instruction - (char *) m_byteCode); }
+  int GetLine(const void * a_instruction) const { return GetLine( (int)((const char * ) a_instruction - (char *) m_byteCode) ); }
 
   /// \brief GetInstructionAtLine() will return the instruction at the given line, or NULL of line was not within this function
   const void * GetInstructionAtLine(int a_line) const;

+ 5 - 5
gmsrc/src/gm/gmLibHooks.cpp

@@ -109,7 +109,7 @@ bool gmLibHooks::End(int a_errors)
     USymbol * symbol = m_symbols.GetLast();
     while(m_symbols.IsValid(symbol))
     {
-      m_stream->Write(symbol->m_string, strlen(symbol->m_string) + 1);
+      m_stream->Write(symbol->m_string, (unsigned int)strlen(symbol->m_string) + 1);
       symbol = m_symbols.GetPrev(symbol);
     }
     GM_ASSERT(m_stream->Tell() == m_symbolOffset + offsets[0] + sizeof(gmuint32));
@@ -118,7 +118,7 @@ bool gmLibHooks::End(int a_errors)
     if(m_debug && m_source)
     {
       offsets[1] = m_stream->Tell();
-      t = strlen(m_source) + 1;
+      t = (gmuint32)strlen(m_source) + 1;
       t1 = 0;
       *m_stream << t << t1;
       m_stream->Write(m_source, t);
@@ -167,7 +167,7 @@ gmptr gmLibHooks::GetSymbolId(const char * a_symbol)
   }
 
   // add a new symbol
-  unsigned int len = strlen(a_symbol) + 1;
+  unsigned int len = (unsigned int)strlen(a_symbol) + 1;
   symbol = (USymbol *) m_allocator.AllocBytes(sizeof(USymbol), GM_DEFAULT_ALLOC_ALIGNMENT);
   symbol->m_string = (char *) m_allocator.AllocBytes(len, GM_DEFAULT_ALLOC_ALIGNMENT);
   memcpy(symbol->m_string, a_symbol, len);
@@ -314,8 +314,8 @@ gmFunctionObject * gmLibHooks::BindLib(gmMachine &a_machine, gmStream &a_stream,
         case BC_BRNZ :
         case BC_BRZK :
         case BC_BRNZK :
-        case BC_FOREACH :
-        case BC_PUSHINT :
+        case BC_FOREACH : instruction += sizeof(gmptr); break;
+        case BC_PUSHINT : instruction += sizeof(gmint); break;
         case BC_PUSHFP : instruction += sizeof(gmfloat); break;
 
         case BC_CALL :

+ 2 - 2
gmsrc/src/gm/gmLibHooks.h

@@ -55,8 +55,8 @@ private:
   bool m_swapEndian;
   bool m_debug;
   const char * m_source;
-  gmptr m_symbolOffset;
-  gmptr m_functionId;
+  gmuint32 m_symbolOffset;
+  gmuint32 m_functionId;
   gmStreamBufferDynamic m_functionStream;
   gmListDouble<USymbol> m_symbols;
   gmMemChain m_allocator;

+ 1 - 1
gmsrc/src/gm/gmLog.cpp

@@ -70,7 +70,7 @@ void GM_CDECL gmLog::LogEntry(const char * a_format, ...)
   Entry * entry = (Entry *) m_mem.AllocBytes(sizeof(Entry) + sizeof(int), GM_DEFAULT_ALLOC_ALIGNMENT);
   if(entry != NULL)
   {
-    char * text = (char *) m_mem.AllocBytes(strlen(buffer) + 1, GM_DEFAULT_ALLOC_ALIGNMENT);
+    char * text = (char *) m_mem.AllocBytes( (int)strlen(buffer) + 1, GM_DEFAULT_ALLOC_ALIGNMENT);
     if(text)
     {
       strcpy(text, buffer);

+ 3 - 3
gmsrc/src/gm/gmMachine.cpp

@@ -80,8 +80,8 @@ public:
 
   gmSourceEntry(const char * a_source, const char * a_filename)
   {
-    int slen = strlen(a_source);
-    int flen = strlen(a_filename);
+    int slen = (int)strlen(a_source);
+    int flen = (int)strlen(a_filename);
     m_id = gmCrc32String(a_source);
 
     m_source = GM_NEW( char[slen + flen + 2] );
@@ -1490,7 +1490,7 @@ gmStringObject * gmMachine::AllocStringObject(const char * a_string, int a_lengt
   
   if(a_length < 0)
   {
-    a_length = strlen(a_string);
+    a_length = (int)strlen(a_string);
   }
   char * string = (char *) Sys_Alloc(a_length + 1);
   memcpy(string, a_string, a_length + 1);

+ 1 - 1
gmsrc/src/gm/gmMachineLib.cpp

@@ -742,7 +742,7 @@ static int GM_CDECL gmTableDuplicate(gmThread * a_thread)
 
 void gmConcat(gmMachine * a_machine, char * &a_dst, int &a_len, int &a_size, const char * a_src, int a_growBy = 32)
 {
-  int len = strlen(a_src);
+  int len = (int)strlen(a_src);
 
   if((a_len + len + 1) >= a_size)
   {

+ 3 - 3
gmsrc/src/gm/gmMemChain.cpp

@@ -105,7 +105,7 @@ gmMemChain::MemChunk* gmMemChain::NewChunk()
   
     //Allocate memory and set address space
     newChunk->m_minAddress = mem + sizeof(MemChunk);
-    newChunk->m_lastAddress = (void*)((unsigned int)newChunk->m_minAddress + m_chunkSize);
+    newChunk->m_lastAddress = (void*)((gmuptr)newChunk->m_minAddress + m_chunkSize);
     newChunk->m_curAddress = newChunk->m_minAddress;
 
     //Link new chunk to chain
@@ -196,12 +196,12 @@ void* gmMemChain::Alloc(unsigned int a_numElementsToAlloc)
 
   GM_ASSERT(allocSize <= m_chunkSize); // Chunk size is too small to alloc that many elements at once and should be increased
 
-  if(((unsigned int)m_currentChunk->m_curAddress + allocSize) > (unsigned int)m_currentChunk->m_lastAddress)
+  if(((gmuptr)m_currentChunk->m_curAddress + allocSize) > (gmuptr)m_currentChunk->m_lastAddress)
   {
     NewChunk();    
   }
   retPtr = m_currentChunk->m_curAddress;
-  m_currentChunk->m_curAddress = (void*)((unsigned int)m_currentChunk->m_curAddress + allocSize);
+  m_currentChunk->m_curAddress = (void*)((gmuptr)m_currentChunk->m_curAddress + allocSize);
 
   return retPtr;
 }

+ 8 - 6
gmsrc/src/gm/gmMemFixed.h

@@ -14,6 +14,8 @@
 
 #include "gmMemChain.h"
 
+#define GM_DEBUG_MEMFIXED 0 // Enable some debugging code, should be disabled unless developing or testing this code
+
 /// \class gmMemFixed
 /// \brief Fixed memory allocator, wrapper on chain memory allocator to provide memory reuse. 
 ///        Performance note: use can cause more random memory access
@@ -106,12 +108,12 @@ void* gmMemFixed::Alloc()
   m_memUsed += m_memChain.GetElementSize();
 #endif // GM_DEBUG_BUILD
 
-#if 0
+#if GM_DEBUG_MEMFIXED
   // clear new mem pointer to 0xB00BFEED
   int * n = (int *) newMemPtr;
   int c = m_memChain.GetElementSize() / sizeof(int);
   while(c--) *(n++) = 0xB00BFEED;
-#endif
+#endif //GM_DEBUG_MEMFIXED
 
   return newMemPtr;
 }
@@ -120,7 +122,7 @@ void* gmMemFixed::Alloc()
 
 void gmMemFixed::Free(void* a_ptr)
 {
-#if 0
+#if GM_DEBUG_MEMFIXED
   // make sure a_ptr is not already in list (freeing something twice)
   FreeListNode * node = m_freeList;
   while(node)
@@ -128,16 +130,16 @@ void gmMemFixed::Free(void* a_ptr)
     GM_ASSERT(a_ptr != node);
     node = node->m_next;
   }
-#endif
+#endif //GM_DEBUG_MEMFIXED
 
   if(a_ptr)
   {
-#if 0
+#if GM_DEBUG_MEMFIXED
     // clear new mem pointer to 0xFEEDFACE
     int * n = (int *) a_ptr;
     int c = m_memChain.GetElementSize() / sizeof(int);
     while(c--) *(n++) = 0xFEEDFACE;
-#endif
+#endif //GM_DEBUG_MEMFIXED
 
     //Add pointer to free list so we can reuse it
     ((FreeListNode*)a_ptr)->m_next = m_freeList;

+ 1 - 1
gmsrc/src/gm/gmMemFixedSet.cpp

@@ -58,7 +58,7 @@ unsigned int gmMemFixedSet::GetSystemMemUsed() const
   BigMemNode* curNode = m_bigAllocs.GetFirst();
   while(m_bigAllocs.IsValid(curNode))
   {
-    total += curNode->m_size;
+    total += GetDataAllocationSize( curNode->Data() ); // Pass in the Data ptr, not the node ptr so we can offset correctly
     curNode = m_bigAllocs.GetNext(curNode);
   }
   return total;

+ 44 - 16
gmsrc/src/gm/gmMemFixedSet.h

@@ -65,21 +65,49 @@ protected:
   /// \brief Internal data structure for small allocations
   struct SmallMemNode
   {
-    int m_size;                                   ///< Allocation size
-    char* Data() {return (char*)(this + 1);}      ///< Get ptr after this structure
+    // NOTE: IMPORTANT size is NOT stored in m_size but (int*)Data()[-1]
+    //       This allows SmallMemNode and BigMemNode to both check the same memory offset to determine size
+    //       We must allocate AT LEAST enough memory for the size to be stored.
+    private: int m_size_reserved;                         ///< Allocation size (WARNING: Do not directly access)
+    public: char* Data() {return (char*)(this + 1);}      ///< Get ptr after this structure
   };
 
   /// \brief Internal data structure for large allocations
   struct BigMemNode: public gmListDoubleNode<BigMemNode>
   { 
-    int m_size;                                   ///< Allocation size
-    char* Data() {return (char*)(this + 1);}      ///< Get ptr after this structure
+    // NOTE: IMPORTANT size is NOT stored in m_size but (int*)Data()[-1]
+    //       This allows SmallMemNode and BigMemNode to both check the same memory offset to determine size
+    //       We must allocate AT LEAST enough memory for the size to be stored.
+    private: int m_size_reserved;                         ///< Allocation size (WARNING: Do not directly access)
+    public: char* Data() {return (char*)(this + 1);}      ///< Get ptr after this structure
   };
 
   void FreeBigAllocs();                           ///< Free the big allocations
   inline SmallMemNode* GetSmallNodeData(void* a_ptr)  { return ((SmallMemNode*)a_ptr)-1; }
   inline BigMemNode* GetBigNodeData(void* a_ptr)  { return ((BigMemNode*)a_ptr)-1; }
 
+  // NOTE: Pass in the DATA ptr, NOT the Node ptr
+  inline int GetDataAllocationSize(void* a_ptr) const
+  {
+    int* ptrToSize = (int*)a_ptr;
+    return ptrToSize[-1]; 
+  }
+  // NOTE: Pass in the DATA ptr, NOT the Node ptr
+  inline void SetDataAllocationSize(void* a_ptr, int a_size)
+  {
+    int* ptrToSize = (int*)a_ptr;
+    ptrToSize[-1] = a_size; 
+  }
+  inline void SetNodeDataSize(SmallMemNode* a_ptr, int a_size)
+  {
+    SetDataAllocationSize(a_ptr->Data(), a_size);
+  }
+  inline void SetNodeDataSize(BigMemNode* a_ptr, int a_size)
+  {
+    SetDataAllocationSize(a_ptr->Data(), a_size);
+  }
+
+
   gmMemFixed m_mem8;                              ///< Memory for 8 bytes and less
   gmMemFixed m_mem16;                             ///< Memory for 16 bytes and less
   gmMemFixed m_mem24;                             ///< Memory for 24 bytes and less
@@ -123,19 +151,19 @@ void* gmMemFixedSet::Alloc(int a_size)
     if (a_size <= 8)
     {
       node = (SmallMemNode*)m_mem8.Alloc();
-      node->m_size = 8;
+      SetNodeDataSize(node, 8);
       m_memUsed += 8;
     }
     else if (a_size <= 16)
     {
       node = (SmallMemNode*)m_mem16.Alloc();
-      node->m_size = 16;
+      SetNodeDataSize(node, 16);
       m_memUsed += 16;
     }
     else if (a_size <= 24)
     {
       node = (SmallMemNode*)m_mem24.Alloc();
-      node->m_size = 24;
+      SetNodeDataSize(node, 24);
       m_memUsed += 24;
     }
     else // if (a_size <= 32)
@@ -143,7 +171,7 @@ void* gmMemFixedSet::Alloc(int a_size)
       GM_ASSERT(a_size <= 32);
 
       node = (SmallMemNode*)m_mem32.Alloc();
-      node->m_size = 32;
+      SetNodeDataSize(node, 32);
       m_memUsed += 32;
     }
   }
@@ -152,25 +180,25 @@ void* gmMemFixedSet::Alloc(int a_size)
     if (a_size <= 64)
     {
       node = (SmallMemNode*)m_mem64.Alloc();
-      node->m_size = 64;
+      SetNodeDataSize(node, 64);
       m_memUsed += 64;
     }
     else if (a_size <= 128)
     {
       node = (SmallMemNode*)m_mem128.Alloc();
-      node->m_size = 128;
+      SetNodeDataSize(node, 128);
       m_memUsed += 128;
     }
     else if (a_size <= 256)
     {
       node = (SmallMemNode*)m_mem256.Alloc();
-      node->m_size = 256;
+      SetNodeDataSize(node, 256);
       m_memUsed += 256;
     }
     else if (a_size <= 512)
     {
       node = (SmallMemNode*)m_mem512.Alloc();
-      node->m_size = 512;
+      SetNodeDataSize(node, 512);
       m_memUsed += 512;
     }    
     else
@@ -180,7 +208,7 @@ void* gmMemFixedSet::Alloc(int a_size)
       bigNode = (BigMemNode*)GM_NEW( char[a_size + sizeof(*bigNode)] ); // This will be aligned as it calls sys new
 
       m_bigAllocs.InsertFirst(bigNode);
-      bigNode->m_size = a_size;
+      SetNodeDataSize(bigNode, a_size);
       m_memUsed += a_size;
 
       return bigNode->Data();
@@ -193,8 +221,8 @@ void* gmMemFixedSet::Alloc(int a_size)
 
 void gmMemFixedSet::Free(void* a_ptr)
 {
-  SmallMemNode* node = GetSmallNodeData(a_ptr);
-  int size = node->m_size;
+  SmallMemNode* node = GetSmallNodeData(a_ptr); // NOTE: Only valid for small nodes
+  int size = GetDataAllocationSize(a_ptr); // Pass the data ptr, not the node ptr so we can offset correctly
 
   if (size <= 32)
   {
@@ -246,7 +274,7 @@ void gmMemFixedSet::Free(void* a_ptr)
     else
     {
       BigMemNode* bigNode = GetBigNodeData(a_ptr);
-      m_memUsed -= bigNode->m_size;
+      m_memUsed -= size;
       m_bigAllocs.Remove(bigNode);
       delete [] (char*) bigNode;
     }

+ 1 - 1
gmsrc/src/gm/gmOperators.cpp

@@ -345,7 +345,7 @@ inline const char * gmUnknownToString(gmMachine * a_machine, gmVariable * a_unkn
   {
     strcpy(a_buffer, "null");
   }
-  if(a_len) { *a_len = strlen(a_buffer); }
+  if(a_len) { *a_len = (int)strlen(a_buffer); }
   return a_buffer;
 }
 void GM_CDECL gmStringOpAdd(gmThread * a_thread, gmVariable * a_operands)

+ 5 - 5
gmsrc/src/gm/gmParser.y

@@ -741,7 +741,7 @@ identifier
   : IDENTIFIER
     {
       $$ = gmCodeTreeNode::Create(CTNT_EXPRESSION, CTNET_IDENTIFIER, gmlineno);
-      $$->m_data.m_string = (char *) gmCodeTree::Get().Alloc(strlen(gmtext) + 1);
+      $$->m_data.m_string = (char *) gmCodeTree::Get().Alloc((int)strlen(gmtext) + 1);
       strcpy($$->m_data.m_string, gmtext);
     }
   ;
@@ -776,7 +776,7 @@ constant
     {
       $$ = gmCodeTreeNode::Create(CTNT_EXPRESSION, CTNET_CONSTANT, gmlineno, CTNCT_INT);
 
-      char * c = (char *) gmCodeTree::Get().Alloc(strlen(gmtext) + 1);
+      char * c = (char *) gmCodeTree::Get().Alloc((int)strlen(gmtext) + 1);
       strcpy(c, gmtext);
       int result = 0;
       int shr = 0;
@@ -838,7 +838,7 @@ constant_string_list
   : CONSTANT_STRING
     {
       $$ = gmCodeTreeNode::Create(CTNT_EXPRESSION, CTNET_CONSTANT, gmlineno, CTNCT_STRING);
-      $$->m_data.m_string = (char *) gmCodeTree::Get().Alloc(strlen(gmtext) + 1);
+      $$->m_data.m_string = (char *) gmCodeTree::Get().Alloc((int)strlen(gmtext) + 1);
       strcpy($$->m_data.m_string, gmtext);
       if(gmtext[0] == '"')
       {
@@ -852,8 +852,8 @@ constant_string_list
   | constant_string_list CONSTANT_STRING
     {
       $$ = $1;
-      int alen = strlen($$->m_data.m_string);
-      int blen = strlen(gmtext);
+      int alen = (int)strlen($$->m_data.m_string);
+      int blen = (int)strlen(gmtext);
       char * str = (char *) gmCodeTree::Get().Alloc(alen + blen + 1);
       if(str)
       {

+ 14 - 0
gmsrc/src/gm/gmStream.h

@@ -137,6 +137,20 @@ private:
   inline void SwapEndian(gmuint32 &a_x) { a_x = (a_x << 24) | ((a_x << 8) & 0x00ff0000) | ((a_x >> 8) & 0x0000ff00) | ((a_x >> 24) & 0x000000ff); }
   inline void SwapEndian(gmint32 &a_x) { a_x = (a_x << 24) | ((a_x << 8) & 0x00ff0000) | ((a_x >> 8) & 0x0000ff00) | ((a_x >> 24) & 0x000000ff); }
   inline void SwapEndian(gmfloat &a_x) { SwapEndian((gmuint32 &) a_x); }
+#ifdef GT_PTR_SIZE_64  
+  inline void SwapEndian(gmuint64 &a_x) 
+  {
+    a_x =     (a_x << 56) 
+           | ((a_x << 40) & 0x00ff000000000000)
+           | ((a_x << 24) & 0x0000ff0000000000)
+           | ((a_x << 8 ) & 0x000000ff00000000)
+           | ((a_x >> 8 ) & 0x00000000ff000000)
+           | ((a_x >> 24) & 0x0000000000ff0000) 
+           | ((a_x >> 40) & 0x000000000000ff00) 
+           | ((a_x >> 56) & 0x00000000000000ff);
+  }
+  inline void SwapEndian(gmptr &a_x) { SwapEndian((gmuint64 &) a_x); }
+#endif //!GT_PTR_SIZE_64
 };
 
 

+ 1 - 1
gmsrc/src/gm/gmTableObject.h

@@ -118,7 +118,7 @@ private:
   void RemoveAndDeleteAll(gmMachine * a_machine);
   inline gmTableNode * GetAtHashPos(const gmVariable* a_key) const
   {
-    unsigned int hash = a_key->m_value.m_ref;
+    unsigned int hash = (unsigned int)a_key->m_value.m_ref; // Use lower 32 bits for now (NOTE: Alternate hashing method may improve performance)
 
     if(a_key->IsReference())
     {

+ 7 - 6
gmsrc/src/gm/gmThread.cpp

@@ -19,6 +19,7 @@
 
 // helper macros
 
+#define OPCODE_INT(I)  *((gmint *) (I)); (I) += sizeof(gmint);
 #define OPCODE_PTR(I)  *((gmptr *) (I)); (I) += sizeof(gmptr);
 #define OPCODE_PTR_NI(I)  *((gmptr *) I);
 #define OPCODE_FLOAT(I)  *((gmfloat *) I); I += sizeof(gmfloat);
@@ -42,7 +43,7 @@ void gmGetLineFromString(const char * a_string, int a_line, char * a_buffer, int
 
   eol = cp;
   while(*eol && *eol != '\n' && *eol != '\r') ++eol;
-  int len = eol - cp;
+  int len = (int)(eol - cp);
   len = ((a_len - 1) < len) ? (a_len - 1) : len;
   memcpy(a_buffer, cp, len);
   a_buffer[len] = '\0';
@@ -642,7 +643,7 @@ gmThread::State gmThread::Sys_Execute(gmVariable * a_return)
       {
         SetTop(top);
         
-        int numParams = (int) OPCODE_PTR(instruction);
+        int numParams = (int) OPCODE_INT(instruction);
 
         State res = PushStackFrame(numParams, &instruction, &code);
         top = GetTop(); 
@@ -741,7 +742,7 @@ gmThread::State gmThread::Sys_Execute(gmVariable * a_return)
 #endif //GM_USE_FORK
       case BC_FOREACH :
       {
-        gmuint32 localvalue = OPCODE_PTR(instruction);
+        gmuint32 localvalue = OPCODE_INT(instruction);
         gmuint32 localkey = localvalue >> 16;
         localvalue &= 0xffff;
 
@@ -838,7 +839,7 @@ gmThread::State gmThread::Sys_Execute(gmVariable * a_return)
       case BC_PUSHINT :
       {
         top->m_type = GM_INT;
-        top->m_value.m_int = OPCODE_PTR(instruction);
+        top->m_value.m_int = OPCODE_INT(instruction);
         ++top;
         break;
       }
@@ -893,13 +894,13 @@ gmThread::State gmThread::Sys_Execute(gmVariable * a_return)
       }
       case BC_GETLOCAL :
       {
-        gmuint32 offset = OPCODE_PTR(instruction);
+        gmuint32 offset = OPCODE_INT(instruction);
         *(top++) = base[offset];
         break;
       }
       case BC_SETLOCAL :
       {
-        gmuint32 offset = OPCODE_PTR(instruction);
+        gmuint32 offset = OPCODE_INT(instruction);
         base[offset] = *(--top);
         break;
       }

+ 7 - 7
gmsrc/src/gm/gmThread.h

@@ -100,7 +100,7 @@ public:
   inline gmVariable * GetBottom() const { return m_stack; }
 
   /// \brief SetTop() will set the top of stack
-  inline void SetTop(gmVariable * a_top) { m_top = a_top - m_stack; }
+  inline void SetTop(gmVariable * a_top) { m_top = (int)(a_top - m_stack); }
 
   /// \brief GetBase() will return the current stack base.
   inline gmVariable * GetBase() const { return &m_stack[m_base]; }
@@ -129,7 +129,7 @@ public:
   inline gmVariable &Pop() { return m_stack[--m_top]; }
   inline void Push(const gmVariable &a_variable) { m_stack[m_top++] = a_variable; }
   inline void PushNull();
-  inline void PushInt(gmptr a_value);
+  inline void PushInt(gmint a_value);
   inline void PushFloat(gmfloat a_value);
   inline void PushString(gmStringObject * a_string);
   inline void PushTable(gmTableObject * a_table);
@@ -145,8 +145,8 @@ public:
   // Versions that return bool return false if type was invalid, otherwise true, even if param was out of range. NOTE: Could switch to more complex return code, but user could simply check num params for range check if needed.
   // 
 
-  inline int ParamInt(int a_param, gmptr a_default = 0) const;
-  inline bool ParamInt(int a_param, int& a_value, gmptr a_default = 0) const;
+  inline int ParamInt(int a_param, gmint a_default = 0) const;
+  inline bool ParamInt(int a_param, gmint& a_value, gmint a_default = 0) const;
   inline gmfloat ParamFloat(int a_param, gmfloat a_default = 0.0f) const;
   inline bool ParamFloat(int a_param, gmfloat& a_value, gmfloat a_default = 0.0f) const;
   inline gmfloat ParamFloatOrInt(int a_param, gmfloat a_default = 0.0f) const;
@@ -276,7 +276,7 @@ inline void gmThread::PushNull()
 }
 
 
-inline void gmThread::PushInt(gmptr a_value)
+inline void gmThread::PushInt(gmint a_value)
 {
   m_stack[m_top].m_type = GM_INT;
   m_stack[m_top++].m_value.m_int = a_value;
@@ -342,7 +342,7 @@ gmUserObject * gmThread::PushNewUser(void * a_user, int a_userType)
 // Parameter methods. (do not cause an error if the desired parameter is incorrect type)
 //
 
-inline int gmThread::ParamInt(int a_param, gmptr a_default) const
+inline int gmThread::ParamInt(int a_param, gmint a_default) const
 {
   if(a_param >= m_numParameters) return a_default;
   gmVariable * var = m_stack + m_base + a_param;
@@ -350,7 +350,7 @@ inline int gmThread::ParamInt(int a_param, gmptr a_default) const
   return a_default;
 }
 
-inline bool gmThread::ParamInt(int a_param, int& a_value, gmptr a_default) const
+inline bool gmThread::ParamInt(int a_param, gmint& a_value, gmint a_default) const
 {
   // Out of range
   if( a_param >= m_numParameters )

+ 1 - 1
gmsrc/src/gm/gmVariable.cpp

@@ -56,7 +56,7 @@ const char * gmVariable::AsStringWithType(gmMachine * a_machine, char * a_buffer
   _gmsnprintf(a_buffer, a_len, "%s: ", a_machine->GetTypeName(m_type));
 
   // Update for used portion
-  int usedLen = strlen(a_buffer);
+  int usedLen = (int)strlen(a_buffer);
   char* newBufferPos = a_buffer + usedLen;
   int newLen = a_len - usedLen;
 

+ 2 - 2
gmsrc/src/gm/gmVariable.h

@@ -60,8 +60,8 @@ struct gmVariable
   gmType m_type;
   union
   {
-    int m_int;
-    float m_float;
+    gmint m_int;
+    gmfloat m_float;
     gmptr m_ref;
   } m_value;
 

+ 29 - 8
gmsrc/src/platform/win32msvc/gmConfig_p.h

@@ -26,17 +26,29 @@
 // These two are for MSVS 2005 security consciousness until safe std lib funcs are available
 #pragma warning(disable : 4996) // Deprecated functions
 #define _CRT_SECURE_NO_DEPRECATE // Allow old unsecure standard library functions, Disable some 'warning C4996 - function was deprecated'
-#define _USE_32BIT_TIME_T // So system binds can use int for timestamps
 
 #include <malloc.h> // alloca
 #include <new>
 #include <cassert>
 
 // system defines
+#if defined(_XBOX)
+  #define GM_LITTLE_ENDIAN      0
+  #define GM_DEFAULT_ALLOC_ALIGNMENT 4
+#endif //_XBOX
+#if defined(WIN32)
+  #define GM_LITTLE_ENDIAN      1
+  #if defined(_X64) // 64bit target
+    #define GM_DEFAULT_ALLOC_ALIGNMENT 16
+    #define GT_PTR_SIZE_64 // Ptr size is 64bit
+  #else // 32bit target
+    #define GM_DEFAULT_ALLOC_ALIGNMENT 4
+    #define GT_PTR_SIZE_32 // Ptr size is 32bit
+  #endif
+//  #define GM_X86
+#endif //_WIN32
 
-#define GM_LITTLE_ENDIAN      1
-#define GM_COMPILER_MSVC6
-#define GM_X86
+//#define GM_COMPILER_MSVC6
 
 #define GM_CDECL              __cdecl
 #ifdef _DEBUG
@@ -55,12 +67,12 @@
 #endif // _DEBUG
 #define GM_PRINTF             printf
 
-//#define GM_CHECK_USER_BREAK_CALLBACK // Enable this only if a user break callback is set
+#define GM_CHECK_USER_BREAK_CALLBACK // Enable this only if a user break callback is set
 
 #define GM_NEW( alloc_params ) new alloc_params
 #define GM_PLACEMENT_NEW( alloc_params, address ) new(address) alloc_params
 
-#define GM_DEFAULT_ALLOC_ALIGNMENT 4
+//#define GM_DEFAULT_ALLOC_ALIGNMENT 4
 
 #define GM_MAKE_ID32( a, b, c, d )  ( ((d)<<24) | ((c)<<16) | ((b)<<8) | (a))
 
@@ -104,9 +116,18 @@ typedef short gmint16;
 typedef unsigned short gmuint16;
 typedef int gmint32;
 typedef unsigned int gmuint32;
+typedef int gmint;
+typedef unsigned int gmuint;
 typedef float gmfloat;
-typedef int gmptr; // machine pointer size as int
-typedef unsigned int gmuptr; // machine pointer size as int
+#ifdef GT_PTR_SIZE_64
+  typedef __int64 gmptr; // machine pointer size as int
+  typedef unsigned __int64 gmuptr; // machine pointer size as int
+  typedef __int64 gmint64;
+  typedef unsigned __int64 gmuint64;
+#else //!GT_PTR_SIZE_64
+  typedef int gmptr; // machine pointer size as int
+  typedef unsigned int gmuptr; // machine pointer size as int
+#endif //!GT_PTR_SIZE_64
 
 
 #define GM_CRT_DEBUG