Browse Source

Checking _64BIT_ flags, adding ARMFIX

Checking all _64BIT_ flags and adding relevant ARMFIX comments around to
make sure we fix them at the same time. There are a number of different
ARMFIX comments, each one with an explanation of what has to be done to
make it work on ARM. Other comments were added for clarification of why
that particular _64BIT_ flag is not at all platform specific.
Renato Golin 11 years ago
parent
commit
c392b68f3e

+ 1 - 1
common/remote/sockfile.cpp

@@ -3328,7 +3328,7 @@ public:
         selecthandler.setown(createSocketSelectHandler(NULL));
         threads.setown(createThreadPool("CRemoteFileServerPool",this,NULL,MAX_THREADS,60*1000,
 #ifdef __64BIT__
-            0,
+            0, // Unlimited stack size
 #else
             0x10000,
 #endif

+ 1 - 1
common/thorhelper/thorcommon.cpp

@@ -1314,7 +1314,7 @@ IExtRowStream *createRowStream(IFile *file, IRowInterfaces *rowIf, unsigned rwFl
     return createRowStreamEx(file, rowIf, 0, (offset_t)-1, (unsigned __int64)-1, rwFlags, eexp);
 }
 
-
+// Memory map sizes can be big, restrict to 64-bit platforms.
 void useMemoryMappedRead(bool on)
 {
 #if defined(_DEBUG) || defined(__64BIT__)

+ 1 - 0
common/thorhelper/thorrparse.cpp

@@ -1979,6 +1979,7 @@ void RegexNamedPattern::getTraceText(StringBuffer & s)
 RegexMatchAction RegexNamedPattern::match(RegexState & state)
 {
 #ifdef __64BIT__
+    // 64-bit systems have more space for stack
     RegexMatchState matched(def);
     return def->match(state, &end, matched);
 #else

+ 1 - 0
dali/dafilesrv/dafilesrv.cpp

@@ -328,6 +328,7 @@ int main(int argc,char **argv)
     InitModuleObjects();
     EnableSEHtoExceptionMapping();
 #ifndef __64BIT__
+    // Restrict stack sizes on 32-bit systems
     Thread::setDefaultStackSize(0x10000);   // 64K stack (also set in windows DSP)
 #endif
     Owned<IFile> sentinelFile = createSentinelTarget();

+ 2 - 1
dali/rfs/rfsmysql/rfsmysql.cpp

@@ -64,7 +64,8 @@ static int _memicmp (const void *s1, const void *s2, size_t len)
 }
 
 #endif
-#if defined(_M_X64) || defined ( __x86_64) || __WORDSIZE==64
+#if defined(_M_X64) || defined ( __x86_64) || \
+    defined(__aarch64__) || __WORDSIZE==64
 #define __64BIT__
 typedef unsigned long memsize_t;
 #else

+ 2 - 1
dali/rfs/rfspostgres/rfspostgres.cpp

@@ -75,7 +75,8 @@ static char *_itoa(unsigned long n, char *str, int b)
 
 
 #endif
-#if defined(_M_X64) || defined ( __x86_64) || __WORDSIZE==64
+#if defined(_M_X64) || defined ( __x86_64) || \
+    defined(__aarch64__) || __WORDSIZE==64
 #define __64BIT__
 typedef unsigned long memsize_t;
 #else

+ 1 - 0
dali/sasha/saserver.cpp

@@ -263,6 +263,7 @@ int main(int argc, const char* argv[])
     sashaProgramName = argv[0];
 
 #ifndef __64BIT__
+    // Restrict stack sizes on 32-bit systems
     Thread::setDefaultStackSize(0x20000);
 #endif
     setDaliServixSocketCaching(true);

+ 1 - 0
dali/server/daserver.cpp

@@ -143,6 +143,7 @@ int main(int argc, char* argv[])
 
         EnableSEHtoExceptionMapping();
 #ifndef __64BIT__
+        // Restrict stack sizes on 32-bit systems
         Thread::setDefaultStackSize(0x20000);
 #endif
         setAllocHook(true);

+ 3 - 0
ecl/hql/hqlfold.cpp

@@ -773,7 +773,10 @@ IValue * foldExternalCall(IHqlExpression* expr, unsigned foldOptions, ITemplateC
 
     // Get the length and address of the stack
     unsigned len = fstack.getSp();
+// ARMFIX: All 5 __64BIT__ usages in this file could be replaced by one at the top
+// regarding the type of a few local variables via typedef
 #ifdef __64BIT__
+    // ARMFIX: This will have to change for ARM. See info below.
     while (len<6*REGSIZE) 
         len = fstack.pushPtr(NULL);         // ensure enough to fill 6 registers
 #endif

+ 1 - 0
ecl/hql/hqlstack.cpp

@@ -24,6 +24,7 @@ FuncCallStack::FuncCallStack() {
     stackbuf = (char *)malloc(tos);
     numToFree = 0;
 #ifdef __64BIT__
+    // ARMFIX: See the header file for more comments
     numFpRegs = 0;
     for (unsigned i=0;i<MAXFPREGS;i++)
         fpRegs[i] = 0.0;

+ 2 - 0
ecl/hql/hqlstack.hpp

@@ -47,6 +47,8 @@ private:
     char*      toFree[MAXARGS];
     int        numToFree;
 #ifdef __64BIT__
+    // ARMFIX: If this is related to VFP registers in procedure call
+    // than both ARM32 and ARM64 use it and we'll need to account for it
     double      fpRegs[MAXFPREGS];
     unsigned    numFpRegs;
 #endif

+ 1 - 0
ecl/hql/hqlutil.cpp

@@ -7082,6 +7082,7 @@ class Vs6CppNameMangler
 public:
     Vs6CppNameMangler()
     {
+// Assuming Windows on ARM64 will have the same mangling
 #ifdef __64BIT__
         pointerBaseCode.set("E");
 #endif

+ 2 - 0
ecl/hqlcpp/hqlcpp.cpp

@@ -1330,6 +1330,8 @@ void HqlCppInstance::flushResources(const char *filename, ICodegenContextCallbac
         StringBuffer ln;
         ln.append(path).append(SharedObjectPrefix).append(trailing).append(LibraryExtension);
 #ifdef __64BIT__
+        // ARMFIX: Map all the uses of this property and make sure
+        // they're not used to mean x86_64 (it shouldn't, though)
         bool target64bit = workunit->getDebugValueBool("target64bit", true);
 #else
         bool target64bit = workunit->getDebugValueBool("target64bit", false);

+ 17 - 2
ecl/hqlcpp/hqlecl.cpp

@@ -514,6 +514,8 @@ bool HqlDllGenerator::doCompile(ICppCompiler * compiler)
             compiler->setOptimizeLevel(optimizeLevel);
     }
 #ifdef __64BIT__
+    // ARMFIX: Map all the uses of this property and make sure
+    // they're not used to mean x86_64 (it shouldn't, though)
     bool target64bit = wu->getDebugValueBool("target64bit", true);
 #else
     bool target64bit = wu->getDebugValueBool("target64bit", false);
@@ -678,8 +680,21 @@ void setWorkunitHash(IWorkUnit * wu, IHqlExpression * expr)
 #ifdef _WIN32
     cacheCRC++; // make sure CRC is different in windows/linux
 #endif
-#ifdef __64BIT__
-    cacheCRC += 2; // make sure CRC is different for different host platform (shouldn't really matter if cross-compiling working properly, but fairly harmless)
+// make sure CRC is different for different host platform
+// shouldn't really matter if cross-compiling working properly,
+// but fairly harmless.
+#ifdef _ARCH_X86_
+    cacheCRC += 1;
+#endif
+#ifdef _ARCH_X86_64_
+    cacheCRC += 2;
+#endif
+// In theory, ARM and x86 workunits should be totally different, but...
+#ifdef _ARCH_ARM32_
+    cacheCRC += 3;
+#endif
+#ifdef _ARCH_ARM64_
+    cacheCRC += 4;
 #endif
     IExtendedWUInterface *ewu = queryExtendedWU(wu);
     cacheCRC = ewu->calculateHash(cacheCRC);

+ 1 - 0
roxie/ccd/ccdmain.cpp

@@ -458,6 +458,7 @@ int STARTQUERY_API start_query(int argc, const char *argv[])
 #endif
 
 #ifndef __64BIT__
+    // Restrict stack sizes on 32-bit systems
     Thread::setDefaultStackSize(0x10000);   // NB under windows requires linker setting (/stack:)
 #endif
     srand( (unsigned)time( NULL ) );

+ 1 - 0
roxie/roxiemem/roxiemem.cpp

@@ -4636,6 +4636,7 @@ protected:
 #ifdef __64BIT__
     enum { numBitmapThreads = 20, maxBitmapSize = (unsigned)(I64C(0xFFFFFFFFFF) / HEAP_ALIGNMENT_SIZE / UNSIGNED_BITS) };      // Test larger range - in case we ever reduce the granularity
 #else
+    // Restrict heap sizes on 32-bit systems
     enum { numBitmapThreads = 20, maxBitmapSize = (unsigned)(I64C(0xFFFFFFFF) / HEAP_ALIGNMENT_SIZE / UNSIGNED_BITS) };      // 4Gb
 #endif
     class BitmapAllocatorThread : public Thread

+ 1 - 0
services/runagent/frunssh.cpp

@@ -51,6 +51,7 @@ int main( int argc, char *argv[] )
     InitModuleObjects();
 
 #ifndef __64BIT__
+    // Restrict stack sizes on 32-bit systems
     Thread::setDefaultStackSize(0x10000);   // NB under windows requires linker setting (/stack:)
 #endif
 

+ 1 - 0
system/jlib/jdebug.cpp

@@ -68,6 +68,7 @@ static unsigned memArea[32];
 #endif
 #endif
 
+// FIXME: Make sure this is still relevant, and if not, delete
 #ifndef _WIN32
 #ifndef __64BIT__
 #define USE_OLD_PU

+ 4 - 4
system/jlib/jexcept.cpp

@@ -819,7 +819,7 @@ static void PrintExceptionReport( PEXCEPTION_POINTERS pExceptionInfo)
     PrintLog( "SS:ESP:%04X:%08X  EBP:%08X",
         pCtx->SegSs, pCtx->Esp, pCtx->Ebp );
 #else
-    // ARMFIX
+    // ARMFIX: Implement register bank dump for ARM.
     PrintLog("Register bank not implemented for your platform");
 #endif
     
@@ -831,7 +831,7 @@ static void PrintExceptionReport( PEXCEPTION_POINTERS pExceptionInfo)
 #elif defined(_ARCH_X86_)
     doPrintStackReport(pCtx->Eip, pCtx->Ebp,pCtx->Esp);
 #else
-    // ARMFIX
+    // ARMFIX: Implement stack dump for ARM.
     PrintLog("Stack report not implemented for your platform");
 #endif
     if (SEHtermOnSystemDLLs || SEHtermAlways) {
@@ -885,7 +885,7 @@ public:
 #elif defined(_ARCH_X86_)
         sprintf(s,"SEH Exception(%08X) at %04X:%08X\n",u,pExp->ContextRecord->SegCs,pExp->ContextRecord->Eip);
 #else
-        // ARMFIX
+        // ARMFIX: Implement exception dump for ARM.
         sprintf(s,"SEH Exception");
 #endif
 #endif
@@ -1052,7 +1052,7 @@ void excsighandler(int signum, siginfo_t *info, void *extra)
         bp = nextbp;
     }
 #else
-    // ARMFIX
+    // ARMFIX: Implement signal dump for ARM.
     PROGLOG("================================================");
     PROGLOG("Signal:    %d %s",signum,strsignal(signum));
     PROGLOG("More information unavailable on your platform");

+ 1 - 0
system/jlib/jfile.cpp

@@ -70,6 +70,7 @@
 #ifdef __64BIT__
 #define DEFAULT_STREAM_BUFFER_SIZE 0x100000
 #else
+// Restrict buffer sizes on 32-bit systems
 #define DEFAULT_STREAM_BUFFER_SIZE 0x10000
 #endif
 

+ 1 - 0
thorlcr/master/thmastermain.cpp

@@ -487,6 +487,7 @@ int main( int argc, char *argv[]  )
 
     EnableSEHtoExceptionMapping(); 
 #ifndef __64BIT__
+    // Restrict stack sizes on 32-bit systems
     Thread::setDefaultStackSize(0x10000);   // NB under windows requires linker setting (/stack:)
 #endif
     const char *thorname = NULL;

+ 1 - 0
thorlcr/slave/thslavemain.cpp

@@ -249,6 +249,7 @@ int main( int argc, char *argv[]  )
 
     dummyProc();
 #ifndef __64BIT__
+    // Restrict stack sizes on 32-bit systems
     Thread::setDefaultStackSize(0x10000);   // NB under windows requires linker setting (/stack:)
 #endif