فهرست منبع

Merge pull request #8212 from ghalliday/issue14665

HPCC-14665 Fix compile errors and warnings on windows

Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 9 سال پیش
والد
کامیت
d79c4fabe0

+ 2 - 0
cmake_modules/commonSetup.cmake

@@ -329,6 +329,8 @@ IF ("${COMMONSETUP_DONE}" STREQUAL "")
         set ( GIT_COMMAND "git.cmd" )
     endif ()
 
+    SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHa")
+
     if (USE_SIGNED_CHAR AND USE_UNSIGNED_CHAR )
         message (FATAL_ERROR "Can't use USE_SIGNED_CHAR and USE_UNSIGNED_CHAR together!")
     else()

+ 12 - 12
common/remote/sockfile.cpp

@@ -3021,25 +3021,27 @@ static CriticalSection ClientCountSect;
 
 class CClientStats : public CInterface
 {
-    SpinLock spin;
 public:
-    CClientStats(const char *_client) : client(_client) { count = 0; bRead = 0; bWritten = 0; }
+    CClientStats(const char *_client) : client(_client), count(0), bRead(0), bWritten(0) { }
     const char *queryFindString() const { return client; }
-    inline void addRead(unsigned len)
+    inline void addRead(unsigned __int64 len)
     {
-        SpinBlock b(spin); // rare event, but we should change to a atomic<__int64> for >= c++11
         bRead += len;
     }
-    inline void addWrite(unsigned len)
+    inline void addWrite(unsigned __int64 len)
     {
-        SpinBlock b(spin); // rare event, but we should change to a atomic<__int64> for >= c++11
         bWritten += len;
     }
+    void getStatus(StringBuffer & info) const
+    {
+        info.appendf("Client %s - %" I64F "d requests handled, bytes read = %" I64F "d, bytes written = % " I64F "d",
+            client.get(), count, bRead.load(), bWritten.load()).newline();
+    }
 
     StringAttr client;
     unsigned __int64 count;
-    unsigned __int64 bRead;
-    unsigned __int64 bWritten;
+    std::atomic<unsigned __int64> bRead;
+    std::atomic<unsigned __int64> bWritten;
 };
 class CClientStatsTable : public OwningStringSuperHashTableOf<CClientStats>
 {
@@ -3119,8 +3121,7 @@ public:
                 for (unsigned e=0; e<max; e++)
                 {
                     const CClientStats &element = *elements.item(e);
-                    info.appendf("Client %s - %" I64F "d requests handled, bytes read = %" I64F "d, bytes written = % " I64F "d",
-                            element.client.get(), element.count, element.bRead, element.bWritten).newline();
+                    element.getStatus(info);
                 }
             }
             else // list all
@@ -3129,8 +3130,7 @@ public:
                 ForEachItemIn(e, elements)
                 {
                     const CClientStats &element = *elements.item(e);
-                    info.appendf("Client %s - %" I64F "d requests handled, bytes read = %" I64F "d, bytes written = % " I64F "d",
-                            element.client.get(), element.count, element.bRead, element.bWritten).newline();
+                    element.getStatus(info);
                 }
             }
         }

+ 1 - 1
common/thorhelper/roxiehelper.cpp

@@ -1642,7 +1642,7 @@ int readHttpHeaderLine(IBufferedSocket *linereader, char *headerline, unsigned m
     int bytesread = linereader->readline(headerline, maxlen, true, me);
     if (me->ordinality())
         throw me.getClear();
-    if(bytesread <= 0 || bytesread > maxlen)
+    if(bytesread <= 0 || (unsigned)bytesread > maxlen)
         throw MakeStringException(THORHELPER_DATA_ERROR, "HTTP-GET Bad Request");
     return bytesread;
 }

+ 1 - 1
common/thorhelper/thorcommon.hpp

@@ -133,7 +133,7 @@ extern THORHELPER_API IDiskMerger *createDiskMerger(IRowInterfaces *rowInterface
 
 
 #define TIME_ACTIVITIES
-class ActivityTimeAccumulator
+class THORHELPER_API ActivityTimeAccumulator
 {
     friend class ActivityTimer;
 public:

+ 1 - 1
common/thorhelper/thorstrand.hpp

@@ -23,7 +23,7 @@
 #include "roxiestream.hpp"
 #include "roxiemem.hpp"
 
-class IStrandJunction : extends IInterface
+interface IStrandJunction : extends IInterface
 {
 public:
     virtual IEngineRowStream * queryOutput(unsigned n) = 0;

+ 1 - 1
esp/bindings/SOAP/Platform/soapmessage.cpp

@@ -1001,7 +1001,7 @@ bool CSoapValue::get_value(const char* path, FloatArray& value)
 
             StringBuffer tmpval;
             onechild.serializeContent(tmpval, NULL);
-            value.append(atof(tmpval));
+            value.append((float)atof(tmpval));
         }
     }
     return (sv != NULL);

+ 1 - 1
esp/bindings/http/platform/mime.cpp

@@ -418,7 +418,7 @@ void CMimeMultiPart::unserialize(const char* contenttype, __int64 text_length, c
         if(be <= bb)
             continue;
 
-        body.append(be - bb, text + bb);
+        body.append((unsigned)(be - bb), text + bb);
 
         CMimeBodyPart* onepart = new CMimeBodyPart(ctype.str(), encoding.str(), cid.str(), "", &body, cdisp.str());
 

+ 1 - 1
esp/services/ws_machine/componentstatus.cpp

@@ -55,7 +55,7 @@ CESPComponentStatusInfo::CESPComponentStatusInfo(const char* _reporter)
     { //A status report should be expired if it was reported >csCacheMinutes ago.
         CDateTime timeNow;
         timeNow.setNow();
-        timeNow.adjustTime(-csCacheMinutes);
+        timeNow.adjustTime(-(int)csCacheMinutes);
         expireTimeStamp = timeNow.getSimple();
     }
 }

+ 1 - 1
esp/services/ws_packageprocess/ws_packageprocessService.cpp

@@ -217,7 +217,7 @@ public:
 
     inline bool checkFlag(unsigned check)
     {
-        return flags & check;
+        return (flags & check) != 0;
     }
 
     inline void setFlag(unsigned flag, bool on=true)

+ 0 - 1
esp/test/httptest/httptest.cpp

@@ -22,7 +22,6 @@
 #ifdef _WIN32
 #include "winsock.h"
 #define ERRNO() WSAGetLastError()
-#define EWOULDBLOCK WSAEWOULDBLOCK
 #else
 #define ERRNO() (errno)
 #endif

+ 8 - 4
roxie/ccd/ccdkey.cpp

@@ -76,12 +76,10 @@ class PtrToOffsetMapper
         // MORE - could cache last hit
         unsigned int a = 0;
         int b = numBases;
-        int rc;
         while ((int)a<b)
         {
             int i = (a+b+1)/2;
-            rc = pos - fragments[i-1].baseOffset;
-            if (rc>=0)
+            if (pos >= fragments[i-1].baseOffset)
                 a = i;
             else
                 b = i-1;
@@ -1222,10 +1220,16 @@ public:
         }
         if (preload && !loadedIntoMemory) // loaded but NOT originally seen as preload, lets try to generate keys...
         {
+            if ((size_t)totalSize != totalSize)
+            {
+                IException *E = makeStringException(ROXIE_MEMORY_ERROR, "Preload file is larger than maximum object size");
+                EXCLOG(MCoperatorError, E);
+                throw E;
+            }
             if (traceLevel > 2)
                 DBGLOG("Loading in-memory file, size %" I64F "d", totalSize);
             // MORE - 32-bit systems could wrap here if totalSize > 2^32
-            fileEnd = fileStart = (char *) malloc(totalSize);
+            fileEnd = fileStart = (char *) malloc((size_t)totalSize);
             if (!fileStart)
             {
                 IException *E = MakeStringException(ROXIE_MEMORY_ERROR, "Insufficient memory to preload file");

+ 1 - 1
roxie/roxieclient/roxieclient.cpp

@@ -593,7 +593,7 @@ void CRoxieClient::runQuery(const char* query, bool trim)
             qxml.append(query);
     }
 
-    int i;
+    unsigned i;
 
     for (i=0; i< m_numThreads; i++)
     {

+ 6 - 6
rtl/eclrtl/eclrtl.cpp

@@ -3347,7 +3347,7 @@ bool rtlCodepageToCodepage(unsigned outlen, char * out, unsigned inlen, char con
     unsigned len = target - out;
     if(len < outlen)
         codepageBlankFill(outcodepage, target, outlen-len);
-    return U_SUCCESS(err);
+    return U_SUCCESS(err) != FALSE;
 }
 
 bool rtlCodepageToCodepageX(unsigned & outlen, char * & out, unsigned maxoutlen, unsigned inlen, char const * in, char const * outcodepage, char const * incodepage)
@@ -3370,7 +3370,7 @@ bool rtlCodepageToCodepageX(unsigned & outlen, char * & out, unsigned maxoutlen,
         if (!out)
             out = tempBuffer;
     }
-    return U_SUCCESS(err);
+    return U_SUCCESS(err) != FALSE;
 }
 
 int rtlSingleUtf8ToCodepage(char * out, unsigned inlen, char const * in, char const * outcodepage)
@@ -5030,7 +5030,7 @@ public:
 
         sample.setTo(_str + _from, _len);
         matcher->reset(sample);
-        matched = matcher->find();
+        matched = matcher->find() != FALSE;
         if (matched)
             matchedSize = (unsigned)matcher->groupCount() + 1;
     }
@@ -5414,7 +5414,7 @@ public:
         srccnv = ucnv_open(sourceName, &uerr);
         tgtcnv = ucnv_open(targetName, &uerr);
         tgtMaxRatio = ucnv_getMaxCharSize(tgtcnv);
-        failed = U_FAILURE(uerr);
+        failed = U_FAILURE(uerr) != FALSE;
     }
     ~rtlCodepageConverter()
     {
@@ -5449,14 +5449,14 @@ public:
             targetLength = ucnv_fromUChars(tgtcnv, target, ulen*tgtMaxRatio, ubuff, ulen, &uerr);
         }
         free(ubuff);
-        failed = U_FAILURE(uerr);
+        failed = U_FAILURE(uerr) != FALSE;
     }
     unsigned convert(unsigned targetLength, char * target, unsigned sourceLength, char const * source, bool & failed)
     {
         char * tgtStart = target;
         ucnv_convertEx(tgtcnv, srccnv, &target, target+targetLength, &source, source+sourceLength, 0, 0, 0, 0, true, true, &uerr);
         int32_t ret = target-tgtStart;
-        failed = U_FAILURE(uerr);
+        failed = U_FAILURE(uerr) != FALSE;
         return ret;
     }
 

+ 19 - 0
system/jlib/jstats.cpp

@@ -250,6 +250,25 @@ static void formatTimeStamp(StringBuffer & out, unsigned __int64 value)
     out.append(timeStamp).appendf(".%03uZ", us / 1000);
 }
 
+void formatTimeStampAsLocalTime(StringBuffer & out, unsigned __int64 value)
+{
+    time_t seconds = value / 1000000;
+    unsigned us = value % 1000000;
+    char timeStamp[64];
+    time_t tNow = seconds;
+#ifdef _WIN32
+    struct tm *gmtNow;
+    gmtNow = localtime(&tNow);
+    strftime(timeStamp, 64, "%H:%M:%S", gmtNow);
+#else
+    struct tm gmtNow;
+    localtime_r(&tNow, &gmtNow);
+    strftime(timeStamp, 64, "%H:%M:%S", &gmtNow);
+#endif //_WIN32
+    out.append(timeStamp).appendf(".%03u", us / 1000);
+}
+
+
 static const unsigned oneKb = 1024;
 static const unsigned oneMb = 1024 * 1024;
 static const unsigned oneGb = 1024 * 1024 * 1024;

+ 2 - 0
system/jlib/jstats.h

@@ -447,6 +447,8 @@ extern jlib_decl unsigned __int64 getTimeStampNowValue();
 extern jlib_decl unsigned __int64 getIPV4StatsValue(const IpAddress & ip);
 extern jlib_decl void formatStatistic(StringBuffer & out, unsigned __int64 value, StatisticMeasure measure);
 extern jlib_decl void formatStatistic(StringBuffer & out, unsigned __int64 value, StatisticKind kind);
+extern jlib_decl void formatTimeStampAsLocalTime(StringBuffer & out, unsigned __int64 value);
+
 extern jlib_decl unsigned __int64 mergeStatistic(StatisticMeasure measure, unsigned __int64 value, unsigned __int64 otherValue);
 extern jlib_decl unsigned __int64 mergeStatisticValue(unsigned __int64 prevValue, unsigned __int64 newValue, StatsMergeAction mergeAction);
 

+ 1 - 1
thorlcr/activities/hashdistrib/thhashdistribslave.cpp

@@ -672,7 +672,7 @@ protected:
             rowcount_t totalSent = 0;
             try
             {
-                while (!aborted && atomic_read(&numFinished) < owner.numnodes)
+                while (!aborted && (unsigned)atomic_read(&numFinished) < owner.numnodes)
                 {
                     while (queryTotalSz() >= owner.inputBufferSize)
                     {

+ 1 - 1
thorlcr/activities/lookupjoin/thlookupjoinslave.cpp

@@ -1936,7 +1936,7 @@ protected:
                 throw e;
             IOutputMetaData *inputOutputMeta = rightITDL->queryFromActivity()->queryContainer().queryHelper()->queryOutputMeta();
             // rows may either be in separate slave row arrays or in single rhs array, or split.
-            rowidx_t total = rowLoader ? rowLoader->numRows() : (getGlobalRHSTotal() + rhs.ordinality());
+            rowcount_t total = rowLoader ? rowLoader->numRows() : (getGlobalRHSTotal() + rhs.ordinality());
             throw checkAndCreateOOMContextException(this, e, "gathering RHS rows for lookup join", total, inputOutputMeta, NULL);
         }
     }

+ 2 - 2
thorlcr/slave/slwatchdog.cpp

@@ -144,12 +144,12 @@ public:
 
         // Split edge string in activityId and edgeIdx
         const char *pEdge=edgeString.str();
-        const activity_id actId = _atoi64(pEdge);
+        const activity_id actId = (activity_id)_atoi64(pEdge);
         if (!actId) return;
 
         while (*pEdge && *pEdge!='_')  ++pEdge;
         if (!*pEdge) return;
-        const unsigned edgeIdx = _atoi64(++pEdge);
+        const unsigned edgeIdx = (unsigned)_atoi64(++pEdge);
 
         CriticalBlock b(crit);
         ForEachItemIn(g, activeGraphs) // NB: 1 for each slavesPerProcess

+ 5 - 14
thorlcr/slave/traceslave.hpp

@@ -18,10 +18,9 @@
 #ifndef TRACESLAVE_HPP
 #define TRACESLAVE_HPP
 
-#include <sys/time.h>
 #include "thmem.hpp"
+#include "jstats.h"
 
-class tm;
 class CTracingThorDataLink : implements CInterfaceOf<IThorDataLink>
 {
 private:
@@ -40,18 +39,10 @@ private:
         }
         inline void getTimeStamp(StringBuffer &retTimeStamp) const
         {
-            struct timeval tvNow, tvAdjust, tvResult;
-            struct tm tm;
-
-            gettimeofday(&tvNow, NULL);
-
-            const __int64 diffUSec = cycle_to_microsec(get_cycles_now() - cycleStamp);
-            tvAdjust.tv_sec = diffUSec / 1000000;
-            tvAdjust.tv_usec = diffUSec % 1000000;
-            timersub(&tvNow, &tvAdjust, &tvResult);
-
-            localtime_r(&tvResult.tv_sec, &tm);
-            retTimeStamp.setf("%d:%02d:%02d.%d", tm.tm_hour, tm.tm_min, tm.tm_sec, (int)(tvResult.tv_usec/1000));
+            unsigned __int64 nowUSec = getTimeStampNowValue();
+            __int64 diffUSec = cycle_to_microsec(get_cycles_now() - cycleStamp);
+            unsigned __int64 adjustedTime = nowUSec - diffUSec;
+            formatTimeStampAsLocalTime(retTimeStamp, adjustedTime);
         }
         inline const void * get() const      { return row.get(); }
         inline void clear()                  { row.clear(); }

+ 4 - 1
tools/esdlcmd/CMakeLists.txt

@@ -61,7 +61,10 @@ include_directories (
          ${HPCC_SOURCE_DIR}/esp/esdllib
     )
 
-ADD_DEFINITIONS( -D_CONSOLE -O0 )
+ADD_DEFINITIONS( -D_CONSOLE )
+if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX)
+    ADD_DEFINITIONS( -O0 )
+endif ()
 
 HPCC_ADD_EXECUTABLE ( esdl ${SRCS} )
 

+ 4 - 4
tools/testsocket/testsocket.cpp

@@ -129,12 +129,12 @@ void sendFileChunk(const char * filename, offset_t offset, ISocket * socket)
     if (in)
     {
         fseek(in, 0, SEEK_END);
-        size = ftell(in);
+        offset_t endOffset = ftell(in);
         fseek(in, offset, SEEK_SET);
-        if (size < offset)
+        if (endOffset < offset)
             size = 0;
         else
-            size -= offset;
+            size = (unsigned)(endOffset - offset);
         if (size > CHUNK_SIZE)
             size = CHUNK_SIZE;
         buff = malloc(size);
@@ -862,7 +862,7 @@ int main(int argc, char **argv)
                                 queryTime.setNow();
                                 queryTime.setTimeString(buffer, &query);
                                 nowTime.setNow();
-                                int sleeptime = (queryTime.getSimple()-firstTime.getSimple()) - (nowTime.getSimple()-startTime.getSimple());
+                                int sleeptime = (int)((queryTime.getSimple()-firstTime.getSimple()) - (nowTime.getSimple()-startTime.getSimple()));
                                 if (sleeptime < 0)
                                     DBGLOG("Running behind %d seconds", -sleeptime);
                                 else if (sleeptime)