瀏覽代碼

HPCC-25212 Add support for unity builds in CMake

Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 3 年之前
父節點
當前提交
72fab49096

+ 1 - 0
common/remote/hooks/git/libgit2.cmake

@@ -24,6 +24,7 @@
 
 
 project( libgit2helper )
+SET(CMAKE_UNITY_BUILD FALSE)
 
 remove_definitions(-fvisibility=hidden)
 

+ 2 - 1
configuration/configmgr/configmgrlib/Utils.cpp

@@ -18,6 +18,7 @@ limitations under the License.
 #include <vector>
 #include <string>
 #include "Exceptions.hpp"
+#include "Utils.hpp"
 
 bool getEnclosedString(const std::string &source, std::string &result, std::size_t startPos, char endDelim, bool throwIfError);
 
@@ -91,7 +92,7 @@ bool getEnclosedString(const std::string &source, std::string &result, std::size
 }
 
 
-std::string trim(const std::string& str, const std::string& whitespace = " \t")
+std::string trim(const std::string& str, const std::string& whitespace)
 {
     const auto strBegin = str.find_first_not_of(whitespace);
     if (strBegin == std::string::npos)

+ 2 - 0
dali/base/CMakeLists.txt

@@ -58,6 +58,8 @@ set (    INCLUDES
          dautils.hpp
     )   
 
+set_source_files_properties(dasds.cpp PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
+
 include_directories ( 
          ${HPCC_SOURCE_DIR}/common/deftype 
          ${HPCC_SOURCE_DIR}/fs/dafsclient

+ 0 - 6
dali/base/dafdesc.cpp

@@ -954,12 +954,6 @@ void getClusterInfo(IPropertyTree &pt, INamedGroupStore *resolver, unsigned flag
     }
 }
 
-inline bool validFNameChar(char c)
-{
-    static const char *invalids = "*\"/:<>?\\|";
-    return (c>=32 && c<127 && !strchr(invalids, c));
-}
-
 inline const char *skipRoot(const char *lname)
 {
     for (;;) {

+ 1 - 1
dali/base/dautils.cpp

@@ -113,7 +113,7 @@ inline void skipSp(const char *&s)
         s++;
 }
 
-inline bool validFNameChar(char c)
+bool validFNameChar(char c)
 {
     static const char *invalids = "*\"/:<>?\\|";
     return (c>=32 && c<127 && !strchr(invalids, c));

+ 1 - 0
dali/base/dautils.hpp

@@ -547,6 +547,7 @@ extern da_decl void setPageCacheTimeoutMilliSeconds(unsigned timeoutSeconds);
 extern da_decl void setMaxPageCacheItems(unsigned _maxPageCacheItems);
 extern da_decl IRemoteConnection* connectXPathOrFile(const char* path, bool safe, StringBuffer& xpath);
 extern da_decl bool expandExternalPath(StringBuffer &dir, StringBuffer &tail, const char * filename, const char * s, bool iswin, IException **e);
+extern da_decl bool validFNameChar(char c); 
 extern da_decl void addStripeDirectory(StringBuffer &out, const char *directory, const char *planeName, unsigned partNum, unsigned lfnHash, unsigned numStripes);
 inline unsigned getFilenameHash(size32_t len, const char *filename)
 {

+ 2 - 0
ecl/hql/CMakeLists.txt

@@ -127,6 +127,8 @@ include_directories (
          ${HPCC_SOURCE_DIR}/system/codesigner
     )
 
+set_source_files_properties(hqlgram.cpp PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
+
 if (WIN32)
     add_custom_command ( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/hqlgram.cpp ${CMAKE_CURRENT_BINARY_DIR}/hqlgram.h
         #${bisonopt} is used to force s/r and r/r errors to abort compiling

+ 2 - 0
ecl/hql/hqlmeta.cpp

@@ -53,6 +53,8 @@ static IHqlExpression * cacheUnorderedAttribute;
 static CHqlMetaProperty * nullMetaProperty;
 static CHqlMetaProperty * nullGroupedMetaProperty;
 
+// Spurious comment needed to make unity builds work...
+
 MODULE_INIT(INIT_PRIORITY_STANDARD)
 {
     IAtom * groupedOrderAtom = createAtom("{group-order}");

+ 2 - 2
ecl/hql/hqlthql.cpp

@@ -59,7 +59,7 @@ bool endsWithDotDotDot(const StringBuffer & s)
     return (memcmp(s.str() + s.length() -3, "...", 3) == 0);
 }
 
-typedef CopyReferenceArrayOf<HqlExprArray> HqlExprArrayArray;
+typedef CopyReferenceArrayOf<HqlExprArray> HqlExprArrayCRArray;
 
 class HqltHql
 {
@@ -179,7 +179,7 @@ private:
     StringBufferArray m_exports;
     StringBufferArray m_service_names;
     StringBufferArray m_export_names;
-    HqlExprArrayArray m_visited_array;
+    HqlExprArrayCRArray m_visited_array;
     PointerArray        scope;
     HqlExprArray    mapped;
     IPointerArray   mapSaved;

+ 0 - 2
ecl/hqlcpp/hqlhtcpp.cpp

@@ -84,12 +84,10 @@
 //#define _SR6_
 
 #define MAX_CSV_RECORD_SIZE     4096
-
 #define ECLRTL_LIB          "eclrtl"
 
 //===========================================================================
 
-
 #ifdef _GATHER_USAGE_STATS
 unsigned activityCounts[TAKlast][TAKlast];
 #endif

+ 0 - 1
ecl/hqlcpp/hqlnlp.cpp

@@ -31,7 +31,6 @@
 #include "hqltcppc.hpp"
 #include "hqlcpputil.hpp"
 
-#define DEFAULT_NLP_DETAIL              1
 #define DEFAULT_PATTERN_MAX_LENGTH      4096
 #ifdef __64BIT__
 #define __DEFINED_64BIT__ true

+ 2 - 2
ecl/hqlcpp/hqlregex.cpp

@@ -2217,7 +2217,7 @@ static inline int compareState(HqlDfaState * left, HqlDfaState * right)
     return left->position.compare(right->position);
 }
 
-static int compareState(CInterface * const * left, CInterface * const * right)
+static int compareDfaState(CInterface * const * left, CInterface * const * right)
 { 
     return compareState((HqlDfaState *)*left, (HqlDfaState *)*right);
 }
@@ -2281,7 +2281,7 @@ void HqlRegexExpr::generateDFAs()
             {
                 bool isNew = false;
                 CInterface * castState = nextState;
-                unsigned matchIndex = dfa->orderedStates.bAdd(castState, compareState, isNew);
+                unsigned matchIndex = dfa->orderedStates.bAdd(castState, compareDfaState, isNew);
                 if (isNew)
                     dfa->states.append(*LINK(nextState));
                 else

+ 2 - 6
ecl/hqlcpp/hqltomita.cpp

@@ -27,10 +27,6 @@
 #include "thortparse.ipp"
 #include "hqlregex.ipp"
 
-//#define DEFAULT_DFA_COMPLEXITY    0
-#define DEFAULT_UNICODE_DFA_COMPLEXITY  0
-#define DEFAULT_DFA_COMPLEXITY  2000
-
 //===========================================================================
 
 template <class T> 
@@ -1636,7 +1632,7 @@ static inline int compareState(HqlLRState * left, HqlLRState * right)
     return left->items.compare(right->items);
 }
 
-static int compareState(CInterface * const * left, CInterface * const * right)
+static int compareLRState(CInterface * const * left, CInterface * const * right)
 { 
     return compareState((HqlLRState *)*left, (HqlLRState *)*right);
 }
@@ -1670,7 +1666,7 @@ HqlLRState * TomitaContext::addState(HqlLRState * state)
 {
     bool isNew = false;
     CInterface * castState = state;
-    unsigned matchIndex = orderedStates.bAdd(castState, compareState, isNew);
+    unsigned matchIndex = orderedStates.bAdd(castState, compareLRState, isNew);
     if (isNew)
         states.append(*LINK(state));
     else

+ 0 - 1
ecl/hqlcpp/hqlttcpp.cpp

@@ -45,7 +45,6 @@
 #include "hqlgram.hpp"
 #include "hqlctrans.hpp"
 
-#define TraceExprPrintLog(x, expr) TOSTRLOG(MCdebugInfo(300), unknownJob, x, (expr)->toString);
 //Following are for code that currently cause problems, but are probably a good idea
 //#define MAP_PROJECT_TO_USERTABLE
 //#define REMOVE_NAMED_SCALARS

+ 2 - 2
esp/clients/roxiecontrol.cpp

@@ -98,7 +98,7 @@ bool sendRoxieControlLock(ISocket *sock, bool allOrNothing, unsigned wait)
     return resp->getPropInt("Lock", 0) != 0;
 }
 
-static inline unsigned remainingMsWait(unsigned wait, unsigned start)
+static inline unsigned remainingMsWaitX(unsigned wait, unsigned start)
 {
     if (wait==0 || wait==(unsigned)-1)
         return wait;
@@ -111,7 +111,7 @@ IPropertyTree *sendRoxieControlAllNodes(ISocket *sock, const char *msg, bool all
     unsigned start = msTick();
     if (!sendRoxieControlLock(sock, allOrNothing, wait))
         throw MakeStringException(-1, "Roxie is too busy (control:lock failed) - please try again later.");
-    return sendRoxieControlQuery(sock, msg, remainingMsWait(wait, start));
+    return sendRoxieControlQuery(sock, msg, remainingMsWaitX(wait, start));
 }
 
 IPropertyTree *sendRoxieControlAllNodes(const SocketEndpoint &ep, const char *msg, bool allOrNothing, unsigned wait)

+ 11 - 11
esp/services/ws_dfu/ws_dfuXRefService.cpp

@@ -28,7 +28,7 @@
 #include "roxiecontrol.hpp"
 
 
-static const char* FEATURE_URL = "DfuXrefAccess";
+static const char* XREF_FEATURE_URL = "DfuXrefAccess";
 
 static void appendReplyMessage(bool json, StringBuffer &reply, const char *href,const char *format,...) __attribute__((format(printf, 4, 5)));
 static void appendReplyMessage(bool json, StringBuffer &reply, const char *href,const char *format,...)
@@ -126,7 +126,7 @@ bool CWsDfuXRefEx::onDFUXRefArrayAction(IEspContext &context, IEspDFUXRefArrayAc
 {
     try
     {
-        context.ensureFeatureAccess(FEATURE_URL, SecAccess_Full, ECLWATCH_DFU_XREF_ACCESS_DENIED, "WsDfuXRef::DFUXRefArrayAction: Permission denied.");
+        context.ensureFeatureAccess(XREF_FEATURE_URL, SecAccess_Full, ECLWATCH_DFU_XREF_ACCESS_DENIED, "WsDfuXRef::DFUXRefArrayAction: Permission denied.");
 
         const char *action = req.getAction();
         const char *type = req.getType();
@@ -251,7 +251,7 @@ bool CWsDfuXRefEx::onDFUXRefLostFiles(IEspContext &context, IEspDFUXRefLostFiles
 {
     try
     {
-        context.ensureFeatureAccess(FEATURE_URL, SecAccess_Read, ECLWATCH_DFU_XREF_ACCESS_DENIED, "WsDfuXRef::DFUXRefLostFiles: Permission denied.");
+        context.ensureFeatureAccess(XREF_FEATURE_URL, SecAccess_Read, ECLWATCH_DFU_XREF_ACCESS_DENIED, "WsDfuXRef::DFUXRefLostFiles: Permission denied.");
 
         Owned<IXRefNode> xRefNode = getXRefNodeByCluster(req.getCluster());
         Owned<IXRefFilesNode> lostFiles = xRefNode->getLostFiles();
@@ -278,7 +278,7 @@ bool CWsDfuXRefEx::onDFUXRefFoundFiles(IEspContext &context, IEspDFUXRefFoundFil
 {
     try
     {
-        context.ensureFeatureAccess(FEATURE_URL, SecAccess_Read, ECLWATCH_DFU_XREF_ACCESS_DENIED, "WsDfuXRef::DFUXRefFoundFiles: Permission denied.");
+        context.ensureFeatureAccess(XREF_FEATURE_URL, SecAccess_Read, ECLWATCH_DFU_XREF_ACCESS_DENIED, "WsDfuXRef::DFUXRefFoundFiles: Permission denied.");
 
         Owned<IXRefNode> xRefNode = getXRefNodeByCluster(req.getCluster());
         Owned<IXRefFilesNode> foundFiles = xRefNode->getFoundFiles();
@@ -304,7 +304,7 @@ bool CWsDfuXRefEx::onDFUXRefOrphanFiles(IEspContext &context, IEspDFUXRefOrphanF
 {
     try
     {
-        context.ensureFeatureAccess(FEATURE_URL, SecAccess_Read, ECLWATCH_DFU_XREF_ACCESS_DENIED, "WsDfuXRef::DFUXRefOrphanFiles: Permission denied.");
+        context.ensureFeatureAccess(XREF_FEATURE_URL, SecAccess_Read, ECLWATCH_DFU_XREF_ACCESS_DENIED, "WsDfuXRef::DFUXRefOrphanFiles: Permission denied.");
 
         Owned<IXRefNode> xRefNode = getXRefNodeByCluster(req.getCluster());
         Owned<IXRefFilesNode> orphanFiles = xRefNode->getOrphanFiles();
@@ -330,7 +330,7 @@ bool CWsDfuXRefEx::onDFUXRefMessages(IEspContext &context, IEspDFUXRefMessagesQu
 {
     try
     {
-        context.ensureFeatureAccess(FEATURE_URL, SecAccess_Read, ECLWATCH_DFU_XREF_ACCESS_DENIED, "WsDfuXRef::DFUXRefMessages: Permission denied.");
+        context.ensureFeatureAccess(XREF_FEATURE_URL, SecAccess_Read, ECLWATCH_DFU_XREF_ACCESS_DENIED, "WsDfuXRef::DFUXRefMessages: Permission denied.");
 
         StringBuffer buf;
         Owned<IXRefNode> xRefNode = getXRefNodeByCluster(req.getCluster());
@@ -352,7 +352,7 @@ bool CWsDfuXRefEx::onDFUXRefCleanDirectories(IEspContext &context, IEspDFUXRefCl
 {
     try
     {
-        context.ensureFeatureAccess(FEATURE_URL, SecAccess_Write, ECLWATCH_DFU_XREF_ACCESS_DENIED, "WsDfuXRef::DFUXRefCleanDirectories: Permission denied.");
+        context.ensureFeatureAccess(XREF_FEATURE_URL, SecAccess_Write, ECLWATCH_DFU_XREF_ACCESS_DENIED, "WsDfuXRef::DFUXRefCleanDirectories: Permission denied.");
 
         StringBuffer err;
         Owned<IXRefNode> xRefNode = getXRefNodeByCluster(req.getCluster());
@@ -373,7 +373,7 @@ bool CWsDfuXRefEx::onDFUXRefDirectories(IEspContext &context, IEspDFUXRefDirecto
 {
     try
     {
-        context.ensureFeatureAccess(FEATURE_URL, SecAccess_Read, ECLWATCH_DFU_XREF_ACCESS_DENIED, "WsDfuXRef::DFUXRefDirectories: Permission denied.");
+        context.ensureFeatureAccess(XREF_FEATURE_URL, SecAccess_Read, ECLWATCH_DFU_XREF_ACCESS_DENIED, "WsDfuXRef::DFUXRefDirectories: Permission denied.");
 
         StringBuffer buf;
         Owned<IXRefNode> xRefNode = getXRefNodeByCluster(req.getCluster());
@@ -439,7 +439,7 @@ bool CWsDfuXRefEx::onDFUXRefBuild(IEspContext &context, IEspDFUXRefBuildRequest
 {
     try
     {
-        context.ensureFeatureAccess(FEATURE_URL, SecAccess_Full, ECLWATCH_DFU_XREF_ACCESS_DENIED, "WsDfuXRef::DFUXRefBuild: Permission denied.");
+        context.ensureFeatureAccess(XREF_FEATURE_URL, SecAccess_Full, ECLWATCH_DFU_XREF_ACCESS_DENIED, "WsDfuXRef::DFUXRefBuild: Permission denied.");
 
         const char *cluster = req.getCluster();
         if (isEmptyString(cluster))
@@ -490,7 +490,7 @@ bool CWsDfuXRefEx::onDFUXRefBuildCancel(IEspContext &context, IEspDFUXRefBuildCa
 {
     try
     {
-        context.ensureFeatureAccess(FEATURE_URL, SecAccess_Full, ECLWATCH_DFU_XREF_ACCESS_DENIED, "WsDfuXRef::DFUXRefBuildCancel: Permission denied.");
+        context.ensureFeatureAccess(XREF_FEATURE_URL, SecAccess_Full, ECLWATCH_DFU_XREF_ACCESS_DENIED, "WsDfuXRef::DFUXRefBuildCancel: Permission denied.");
 
         m_XRefbuilder->cancel();
         StringBuffer returnStr;
@@ -556,7 +556,7 @@ bool CWsDfuXRefEx::onDFUXRefList(IEspContext &context, IEspDFUXRefListRequest &r
 #ifdef _CONTAINERIZED
         IERRLOG("CONTAINERIZED(CWsDfuXRefEx::onDFUXRefList)");
 #else
-        context.ensureFeatureAccess(FEATURE_URL, SecAccess_Read, ECLWATCH_DFU_XREF_ACCESS_DENIED, "WsDfuXRef::DFUXRefList: Permission denied.");
+        context.ensureFeatureAccess(XREF_FEATURE_URL, SecAccess_Read, ECLWATCH_DFU_XREF_ACCESS_DENIED, "WsDfuXRef::DFUXRefList: Permission denied.");
 
         CConstWUClusterInfoArray clusters;
         getEnvironmentClusterInfo(clusters);

+ 1 - 0
esp/services/ws_machine/componentstatus.hpp

@@ -15,6 +15,7 @@
     limitations under the License.
 ############################################################################## */
 
+#pragma once
 #include "jiface.hpp"
 #include "jlib.hpp"
 #include "esp.hpp"

+ 1 - 0
plugins/nlp/CMakeLists.txt

@@ -23,6 +23,7 @@
 #####################################################
 
 project(nlp)
+SET(CMAKE_UNITY_BUILD FALSE)
 
 if(USE_NLP)
 

+ 0 - 6
roxie/ccd/ccdfile.cpp

@@ -2096,12 +2096,6 @@ public:
     }
 
     virtual StringAttrMapping *queryFileErrorList() { return &fileErrorList; }  // returns list of files that could not be open
-
-    static inline bool validFNameChar(char c)
-    {
-        static const char *invalids = "*\"/:<>?\\|";
-        return (c>=32 && c<127 && !strchr(invalids, c));
-    }
 };
 
 #ifdef _CONTAINERIZED

+ 4 - 4
roxie/ccd/ccdlistener.cpp

@@ -675,12 +675,12 @@ public:
     }
 };
 
-static Owned<IActiveQueryLimiterFactory> queryLimiterFactory;
+static Owned<IActiveQueryLimiterFactory> theQueryLimiterFactory;
 IActiveQueryLimiterFactory *ensureLimiterFactory()
 {
-    if (!queryLimiterFactory)
-        queryLimiterFactory.setown(new CActiveQueryLimiterFactory());
-    return queryLimiterFactory;
+    if (!theQueryLimiterFactory)
+        theQueryLimiterFactory.setown(new CActiveQueryLimiterFactory());
+    return theQueryLimiterFactory;
 }
 
 //================================================================================================================================

+ 4 - 0
roxie/udplib/udpmsgpk.hpp

@@ -15,6 +15,9 @@
     limitations under the License.
 ############################################################################## */
 
+#ifndef __UDPMSGPK__
+#define __UDPMSGPK__
+
 #include "roxiemem.hpp"
 #include <queue>
 
@@ -59,3 +62,4 @@ public:
     bool attach_data(const void *data, unsigned len);
     void noteDuplicate(bool isResend);
 };
+#endif // __UDPMSGPK__

+ 1 - 1
rtl/eclrtl/rtlfield.cpp

@@ -72,7 +72,7 @@ inline const char * queryName(const RtlFieldInfo * field) { return field ? field
 
 //-------------------------------------------------------------------------------------------------------------------
 
-static bool incrementBuffer(byte *buf, size32_t size)
+bool incrementBuffer(byte *buf, size32_t size)
 {
     int i = size;
     while (i--)

+ 1 - 0
rtl/eclrtl/rtlfield.hpp

@@ -756,4 +756,5 @@ extern bool ECLRTL_API containsKeyedSignedInt(const RtlTypeInfo * type);
 
 extern size32_t translateScalar(ARowBuilder &builder, size32_t offset, const RtlFieldInfo *field, const RtlTypeInfo &destType, const RtlTypeInfo &sourceType, const byte *source);
 
+extern bool incrementBuffer(byte *buff, size32_t size);
 #endif

+ 0 - 14
rtl/eclrtl/rtlnewkey.cpp

@@ -196,20 +196,6 @@ void getStretchedValue(MemoryBuffer & target, const RtlTypeInfo & newType, const
 
 //---------------------------------------------------------------------------------------------------------------------
 
-static bool incrementBuffer(byte *buf, size32_t size)
-{
-    int i = size;
-    while (i--)
-    {
-        buf[i]++;
-        if (buf[i]!=0)
-            return true;
-    }
-    return false;
-}
-
-//---------------------------------------------------------------------------------------------------------------------
-
 bool needToApplySubString(const RtlTypeInfo & type, const byte * value, size32_t subLength)
 {
     if (subLength == MatchFullString)

+ 1 - 0
system/CMakeLists.txt

@@ -32,6 +32,7 @@ if (NOT JLIB_ONLY)
    
    if (USE_AERON)
       project (aeron_include)
+      SET(CMAKE_UNITY_BUILD FALSE)
       remove_definitions(-fvisibility=hidden)
       if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX)
           SET (CMAKE_SAVED_AERON_CXX_FLAGS "${CMAKE_CXX_FLAGS}")

+ 4 - 0
system/globalid/lnuid.h

@@ -15,6 +15,8 @@
    limitations under the License.
 ############################################################################## */
 
+#ifndef __LNUID_INCL__
+#define __LNUID_INCL__
 #include <ctime>
 #include <string>
 
@@ -51,3 +53,5 @@ namespace ln_uid {
 
     int get_utc_offset();
 };
+
+#endif

+ 2 - 0
system/jlib/CMakeLists.txt

@@ -185,6 +185,8 @@ set (    INCLUDES
         ${HPCC_SOURCE_DIR}/system/security/cryptohelper/ske.cpp
         )
 
+set_source_files_properties(jmd5.cpp jsort.cpp PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
+
 if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
     set_property (SOURCE jencrypt.cpp APPEND_STRING PROPERTY COMPILE_FLAGS " -fno-strict-aliasing")
 endif ()

+ 10 - 10
system/jlib/jarray.cpp

@@ -24,9 +24,9 @@
 
 #include <assert.h>
 
-#define FIRST_CHUNK_SIZE  8
-#define DOUBLE_LIMIT      0x100000          // must be a power of 2
-#define ALLOCA_LIMIT      64
+constexpr unsigned ARRAY_FIRST_CHUNK_SIZE=8;
+constexpr unsigned ARRAY_CHUNK_DOUBLE_LIMIT=0x100000;          // must be a power of 2
+constexpr unsigned ARRAY_ALLOCA_LIMIT=64;
 
 void Allocator::_space(size32_t iSize)
 {
@@ -55,10 +55,10 @@ void Allocator::_reallocate(aindex_t newLen, size32_t itemSize)
 {
     size32_t newMax = max;
     if (newMax == 0)
-        newMax = FIRST_CHUNK_SIZE;
-    if (newLen > DOUBLE_LIMIT)
+        newMax = ARRAY_FIRST_CHUNK_SIZE;
+    if (newLen > ARRAY_CHUNK_DOUBLE_LIMIT)
     {
-        newMax = (newLen + DOUBLE_LIMIT) & ~(DOUBLE_LIMIT-1);
+        newMax = (newLen + ARRAY_CHUNK_DOUBLE_LIMIT) & ~(ARRAY_CHUNK_DOUBLE_LIMIT-1);
         if (newLen >= newMax) // wraparound
         {
             IERRLOG("Out of memory (overflow) in Array allocator: itemSize = %u, trying to allocate %u items", itemSize, newLen);
@@ -118,13 +118,13 @@ void Allocator::_doRotateR(aindex_t pos1, aindex_t pos2, size32_t iSize, aindex_
     char * head= (char *)_head;
     char * lower = head + pos1 * iSize;
     char * upper = lower + (blockSize - saveSize);
-    char * temp = (char *)((saveSize <= ALLOCA_LIMIT) ? alloca(saveSize) : malloc(saveSize));
+    char * temp = (char *)((saveSize <= ARRAY_ALLOCA_LIMIT) ? alloca(saveSize) : malloc(saveSize));
 
     memcpy(temp, upper, saveSize);
     memmove(lower + saveSize, lower, blockSize-saveSize);
     memcpy(lower, temp, saveSize);
 
-    if (saveSize > ALLOCA_LIMIT)
+    if (saveSize > ARRAY_ALLOCA_LIMIT)
         free(temp);
 }
 
@@ -139,13 +139,13 @@ void Allocator::_doRotateL(aindex_t pos1, aindex_t pos2, size32_t iSize, size32_
     char * head= (char *)_head;
     char * lower = head + pos1 * iSize;
     char * upper = lower + (blockSize - saveSize);
-    char * temp = (char *)((saveSize <= ALLOCA_LIMIT) ? alloca(saveSize) : malloc(saveSize));
+    char * temp = (char *)((saveSize <= ARRAY_ALLOCA_LIMIT) ? alloca(saveSize) : malloc(saveSize));
 
     memcpy(temp, lower, saveSize);
     memmove(lower, lower + saveSize, blockSize - saveSize);
     memcpy(upper, temp, saveSize);
 
-    if (saveSize > ALLOCA_LIMIT)
+    if (saveSize > ARRAY_ALLOCA_LIMIT)
         free(temp);
 }
 

+ 3 - 0
system/jlib/javahash.tpp

@@ -15,6 +15,8 @@
     limitations under the License.
 ############################################################################## */
 
+#ifndef __JAVAHASH_TPP__
+#define __JAVAHASH_TPP__
 
 template <class ELEMENT>
 void JavaHashTableOf<ELEMENT>::onAdd(void * et)
@@ -103,3 +105,4 @@ ELEMENT *JavaHashTableOf<ELEMENT>::findCompare(ICompare *icmp,void * (ELEMENT::*
 }
 
 #endif
+#endif

+ 19 - 17
system/jlib/jbuff.cpp

@@ -51,14 +51,15 @@
 
 
 #if 1
-#define ChunkSize         0x10000
-#define DOUBLE_LIMIT      0x7fffffff    // avoid doubling hitting 0 and infinite loop
+constexpr unsigned ChunkSize=0x10000;
+constexpr unsigned BUFF_DOUBLE_LIMIT=0x7fffffff;    // avoid doubling hitting 0 and infinite loop
 #else
-#define ChunkSize         2048
-#define DOUBLE_LIMIT      4096
+// For testing
+constexpr unsigned ChunkSize=2048;
+constexpr unsigned BUFF_DOUBLE_LIMIT=4096;
 #endif
-#define FIRST_CHUNK_SIZE  8
-#define DETACH_GRANULARITY 16
+constexpr unsigned BUFF_FIRST_CHUNK_SIZE=8;
+constexpr unsigned BUFF_DETACH_GRANULARITY=16;
 
 
 #ifdef _DEBUG
@@ -255,10 +256,10 @@ void MemoryBuffer::_realloc(size32_t newLen)
         assertex(ownBuffer);
         size32_t newMax = maxLen;
         //double up to a certain size, otherwise go up in chunks.
-        if (newLen < DOUBLE_LIMIT)
+        if (newLen < BUFF_DOUBLE_LIMIT)
         {
             if (newMax == 0)
-                newMax = FIRST_CHUNK_SIZE;
+                newMax = BUFF_FIRST_CHUNK_SIZE;
             while (newLen > newMax)
             {
                 size32_t newMaxTmp = checkMemoryBufferOverflow(newMax, newMax);
@@ -407,7 +408,7 @@ void *MemoryBuffer::detach()
 {
     void *ret;
     if (ownBuffer) { 
-        if (maxLen>curLen+DETACH_GRANULARITY)
+        if (maxLen>curLen+BUFF_DETACH_GRANULARITY)
             buffer = (char *)realloc(buffer,curLen);
         ret = buffer;
     }
@@ -450,17 +451,18 @@ void MemoryBuffer::setWritePos(unsigned len)
     curLen = len;
 }
 
-#define SWAP(x, y, t)  { t t_##x = x; x = y; y = t_##x; }
+#define SWAPMEM(x, y, t)  { t t_##x = x; x = y; y = t_##x; }
 void MemoryBuffer::swapWith(MemoryBuffer & other)
 {
     //swap two string buffers.  Used for efficiently moving a string on in a pipeline etc.
-    SWAP(buffer, other.buffer, char *);
-    SWAP(curLen, other.curLen, size32_t);
-    SWAP(maxLen, other.maxLen, size32_t);
-    SWAP(readPos, other.readPos, size32_t);
-    SWAP(swapEndian, other.swapEndian, bool);
-    SWAP(ownBuffer, other.ownBuffer, bool);
-}
+    SWAPMEM(buffer, other.buffer, char *);
+    SWAPMEM(curLen, other.curLen, size32_t);
+    SWAPMEM(maxLen, other.maxLen, size32_t);
+    SWAPMEM(readPos, other.readPos, size32_t);
+    SWAPMEM(swapEndian, other.swapEndian, bool);
+    SWAPMEM(ownBuffer, other.ownBuffer, bool);
+}
+#undef SWAPMEM
 
 bool MemoryBuffer::matches(const MemoryBuffer & other) const
 {

+ 5 - 0
system/jlib/jfcmp.hpp

@@ -15,6 +15,9 @@
     limitations under the License.
 ############################################################################## */
 
+#ifndef __JFCMP__
+#define __JFCMP__
+
 #include "platform.h"
 #include "jlzw.hpp"
 
@@ -473,3 +476,5 @@ public:
         return baseio->getStatistic(kind);
     }
 };
+
+#endif

+ 1 - 2
system/jlib/jio.cpp

@@ -38,8 +38,7 @@
 #define MAX_RANDOM_CACHE_SIZE               0x10000
 #define RANDOM_CACHE_DEPTH                  10
 
-#define threshold 1024
-#define timelimit 100
+constexpr unsigned timelimit=100;
 
 #define MINCOMPRESSEDROWSIZE 16
 #define MAXCOMPRESSEDROWSIZE 0x4000

+ 3 - 3
system/jlib/jlzw.cpp

@@ -2662,7 +2662,7 @@ IExpander *createAESExpander(const void *key, unsigned keylen)
     return new CAESExpander(key,keylen);
 }
 
-#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (8 - (n))))
+#define ROTATE_BYTE_LEFT(x, n) (((x) << (n)) | ((x) >> (8 - (n))))
 
 
 inline void padKey32(byte *keyout,size32_t len, const byte *key)
@@ -2671,13 +2671,13 @@ inline void padKey32(byte *keyout,size32_t len, const byte *key)
         memset(keyout,0xcc,32);
     else if (len<=32) {
         for (unsigned i=0;i<32;i++)
-            keyout[i] = (i<len)?key[i%len]:ROTATE_LEFT(key[i%len],i/len);
+            keyout[i] = (i<len)?key[i%len]:ROTATE_BYTE_LEFT(key[i%len],i/len);
     }
     else {
         memcpy(keyout,key,32);
         // xor excess rotated
         for (unsigned i=32;i<len;i++) 
-            keyout[i%32] ^= ROTATE_LEFT(key[i],(i/8)%8);
+            keyout[i%32] ^= ROTATE_BYTE_LEFT(key[i],(i/8)%8);
     }
 }
 

+ 5 - 5
system/jlib/jmd5.cpp

@@ -221,7 +221,7 @@ md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/)
 #endif
     }
 
-#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32 - (n))))
+#define ROTATE_LEFT_32(x, n) (((x) << (n)) | ((x) >> (32 - (n))))
 
     /* Round 1. */
     /* Let [abcd k s i] denote the operation
@@ -229,7 +229,7 @@ md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/)
 #define F(x, y, z) (((x) & (y)) | (~(x) & (z)))
 #define SET(a, b, c, d, k, s, Ti)\
   t = a + F(b,c,d) + X[k] + Ti;\
-  a = ROTATE_LEFT(t, s) + b
+  a = ROTATE_LEFT_32(t, s) + b
     /* Do the following 16 operations. */
     SET(a, b, c, d,  0,  7,  T1);
     SET(d, a, b, c,  1, 12,  T2);
@@ -255,7 +255,7 @@ md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/)
 #define G(x, y, z) (((x) & (z)) | ((y) & ~(z)))
 #define SET(a, b, c, d, k, s, Ti)\
   t = a + G(b,c,d) + X[k] + Ti;\
-  a = ROTATE_LEFT(t, s) + b
+  a = ROTATE_LEFT_32(t, s) + b
      /* Do the following 16 operations. */
     SET(a, b, c, d,  1,  5, T17);
     SET(d, a, b, c,  6,  9, T18);
@@ -281,7 +281,7 @@ md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/)
 #define H(x, y, z) ((x) ^ (y) ^ (z))
 #define SET(a, b, c, d, k, s, Ti)\
   t = a + H(b,c,d) + X[k] + Ti;\
-  a = ROTATE_LEFT(t, s) + b
+  a = ROTATE_LEFT_32(t, s) + b
      /* Do the following 16 operations. */
     SET(a, b, c, d,  5,  4, T33);
     SET(d, a, b, c,  8, 11, T34);
@@ -307,7 +307,7 @@ md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/)
 #define I(x, y, z) ((y) ^ ((x) | ~(z)))
 #define SET(a, b, c, d, k, s, Ti)\
   t = a + I(b,c,d) + X[k] + Ti;\
-  a = ROTATE_LEFT(t, s) + b
+  a = ROTATE_LEFT_32(t, s) + b
      /* Do the following 16 operations. */
     SET(a, b, c, d,  0,  6, T49);
     SET(d, a, b, c,  7, 10, T50);

+ 3 - 3
system/jlib/jmutex.cpp

@@ -147,7 +147,7 @@ inline bool write_data(int fd, const void *buf, size_t nbytes)
     return true;
 }
 
-#define POLLTIME (1000*15)
+constexpr unsigned MUTEX_POLLTIME=(1000*15);
 
 static bool lock_file(const char *lfpath) 
 {
@@ -232,7 +232,7 @@ void NamedMutex::lock()
     for (;;) {
         if (lock_file(mutexfname))
             return;
-        Sleep(POLLTIME);
+        Sleep(MUTEX_POLLTIME);
     }
 }
 
@@ -251,7 +251,7 @@ bool NamedMutex::lockWait(unsigned timeout)
             threadmutex.unlock();
             break;
         }
-        Sleep((timeout-elapsed)>POLLTIME?POLLTIME:(timeout-elapsed));
+        Sleep((timeout-elapsed)>MUTEX_POLLTIME ? MUTEX_POLLTIME : (timeout-elapsed));
     }
     return false;
 

+ 3 - 5
system/jlib/jsocket.cpp

@@ -1372,9 +1372,7 @@ ISocket*  ISocket::connect_timeout(const SocketEndpoint &ep,unsigned timeout)
     return sock.getClear();
 }
 
-#define POLLTIME 50
-
-
+#define SOCKET_POLLTIME 50
 
 void CSocket::connect_wait(unsigned timems)
 {
@@ -1485,8 +1483,8 @@ void CSocket::connect_wait(unsigned timems)
                     polltime = timeoutms;
                 Sleep(polltime);                    // sleeps 1-50ms (to let other threads run)
                 timeoutms -= polltime;
-                if (polltime>POLLTIME/2)
-                    polltime = POLLTIME;
+                if (polltime>SOCKET_POLLTIME/2)
+                    polltime = SOCKET_POLLTIME;
                 else
                     polltime *= 2;
     #endif

+ 7 - 7
system/jlib/jstring.cpp

@@ -45,9 +45,9 @@
 
 static const char * TheNullStr = "";
 
-#define FIRST_CHUNK_SIZE  8
-#define DOUBLE_LIMIT      0x100000          // must be a power of 2
-#define DETACH_GRANULARITY 16
+constexpr unsigned STRING_FIRST_CHUNK_SIZE=8;
+constexpr unsigned STRING_DOUBLE_LIMIT = 0x100000;          // must be a power of 2
+constexpr unsigned STRING_DETACH_GRANULARITY = 16;
 
 //===========================================================================
 
@@ -136,10 +136,10 @@ void StringBuffer::_realloc(size_t newLen)
     {
         size_t newMax = maxLen;
         if (newMax == 0)
-            newMax = FIRST_CHUNK_SIZE;
-        if (newLen > DOUBLE_LIMIT)
+            newMax = STRING_FIRST_CHUNK_SIZE;
+        if (newLen > STRING_DOUBLE_LIMIT)
         {
-            newMax = (newLen + DOUBLE_LIMIT) & ~(DOUBLE_LIMIT-1);
+            newMax = (newLen + STRING_DOUBLE_LIMIT) & ~(STRING_DOUBLE_LIMIT-1);
             if (newLen >= newMax)
                 throw MakeStringException(MSGAUD_operator, -1, "StringBuffer::_realloc: Request for %zu bytes oldMax = %zu", newLen, maxLen);
         }
@@ -176,7 +176,7 @@ char * StringBuffer::detach()
     }
     else
     {
-        if (maxLen>curLen+1+DETACH_GRANULARITY)
+        if (maxLen>curLen+1+STRING_DETACH_GRANULARITY)
             buffer = (char *)realloc(buffer,curLen+1); // shrink
         result = buffer;
     }

+ 3 - 3
system/jlib/jutil.cpp

@@ -2196,11 +2196,11 @@ static inline void encode3_64(byte *in,StringBuffer &out)
 
 
 
-static NonReentrantSpinLock lock;
+static NonReentrantSpinLock uuidLock;
 static unsigned uuidbin[5] = {0,0,0,0,0};
 StringBuffer &genUUID(StringBuffer &out, bool nocase)
 { // returns a 24 char UUID for nocase=false or 32 char for nocase=true
-    lock.enter();
+    uuidLock.enter();
     // could be quicker using statics
     if (uuidbin[0]==0) {
         queryHostIP().getNetAddress(sizeof(uuidbin[0]),uuidbin);
@@ -2230,7 +2230,7 @@ StringBuffer &genUUID(StringBuffer &out, bool nocase)
         encode3_64(tmp,out);
         encode3_64(in+17,out);
     }
-    lock.leave();
+    uuidLock.leave();
     return out;
 }
 

+ 2 - 2
system/lzma/CMakeLists.txt

@@ -23,8 +23,8 @@
 #####################################################
 
 
-project( lzma ) 
-
+project( lzma )
+SET(CMAKE_UNITY_BUILD FALSE)
 set ( SRCS
         LzFind.cpp
         LzmaDec.cpp

+ 2 - 0
system/security/zcrypt/CMakeLists.txt

@@ -25,6 +25,8 @@
 
 project( zcrypt ) 
 
+SET(CMAKE_UNITY_BUILD FALSE)
+
 set ( SRCS
       aes.cpp
       base64.cpp

+ 1 - 1
system/yaml/CMakeLists.txt

@@ -15,7 +15,7 @@
 ################################################################################
 
 project( yaml_include)
-
+SET(CMAKE_UNITY_BUILD FALSE)
 remove_definitions(-fvisibility=hidden)
 
 if(WIN32 OR APPLE)

+ 1 - 0
tools/esdlcmd/CMakeLists.txt

@@ -24,6 +24,7 @@
 
 
 project( esdlcmd )
+SET(CMAKE_UNITY_BUILD FALSE)
 
 include(${HPCC_SOURCE_DIR}/esp/scm/smcscm.cmake)