diff --git a/.teamcity/Windows/Project.kt b/.teamcity/Windows/Project.kt index 232769a..6aa6203 100644 --- a/.teamcity/Windows/Project.kt +++ b/.teamcity/Windows/Project.kt @@ -36,7 +36,7 @@ object Project : Project({ }) -class CarbonBuildWindows(buildName: String, configType: String, preset: String) : BuildType({ +class CarbonBuildWindows(buildName: String, configType: String, preset: String, vsDevBatSwitches: String = "-arch=x64 -vcvars_ver=14.51") : BuildType({ id(buildName.toId()) this.name = buildName @@ -46,8 +46,7 @@ class CarbonBuildWindows(buildName: String, configType: String, preset: String) param("env.GIT_TAG_HASH_OVERRIDE", "") param("github_checkout_folder", "github") param("env.CTEST_JUNIT_OUTPUT_FILE", "ctest_results.xml") - select("env.VISUAL_STUDIO_PLATFORM_TOOLSET", "v141", label = "Visual Studio Platform Toolset", description = "Specify the toolset for the build. e.g. v141 or v143.", - options = listOf("v141 (2017)" to "v141", "v143 (2022)" to "v143")) + param("VS_DEV_BAT_SWITCHES", vsDevBatSwitches) param("env.CMAKE_BUILD_TARGETS", "all") param("project", "eve-frontier") param("env.CMAKE_INSTALL_PREFIX", ".build-artifact") @@ -90,7 +89,7 @@ class CarbonBuildWindows(buildName: String, configType: String, preset: String) scriptContent = """ REM unfortunately ninja does not find the VS environment otherwise REM NB: the exported PATH also contains the location where we installed sentry-cli, e.g. teamcity.agent.work.dir - call "%%ProgramFiles(x86)%%\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\vsdevcmd.bat" -arch=x64 + call "%env.VSDEV_BAT_PATH%" %VS_DEV_BAT_SWITCHES% echo ##teamcity[setParameter name='env.INCLUDE' value='%%INCLUDE%%'] echo ##teamcity[setParameter name='env.LIB' value='%%LIB%%'] echo ##teamcity[setParameter name='env.LIBPATH' value='%%LIBPATH%%'] diff --git a/BlockAllocator.h b/BlockAllocator.h index b711de4..45af676 100644 --- a/BlockAllocator.h +++ b/BlockAllocator.h @@ -70,7 +70,7 @@ class StlPoolAllocator : template struct rebind { - typedef StlPoolAllocator other; + using other = StlPoolAllocator; }; T* allocate(size_t _Count, const void *hint) { diff --git a/CMakePresets.json b/CMakePresets.json index 7417d79..3a5a05f 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -15,7 +15,7 @@ "VCPKG_OVERLAY_TRIPLETS": "${sourceDir}/vendor/github.com/carbonengine/vcpkg-registry/triplets" }, "environment": { - "VCPKG_ROOT": "${sourceDir}/vendor/github.com/microsoft/vcpkg" + "PATH_TO_VCPKG_ROOT": "${sourceDir}/vendor/github.com/microsoft/vcpkg" }, "hidden": true }, @@ -33,7 +33,7 @@ "name": "x64-windows", "inherits": "windows", "cacheVariables": { - "VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "${sourceDir}/vendor/github.com/carbonengine/vcpkg-registry/toolchains/x64-windows-carbon.cmake" + "VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "${sourceDir}/vendor/github.com/carbonengine/vcpkg-registry/toolchains/x64-windows-145-carbon.cmake" }, "hidden": true }, @@ -42,8 +42,8 @@ "inherits": "x64-windows", "cacheVariables": { "CMAKE_BUILD_TYPE": "Internal", - "VCPKG_TARGET_TRIPLET": "x64-windows-internal", - "VCPKG_HOST_TRIPLET": "x64-windows-internal" + "VCPKG_TARGET_TRIPLET": "x64-windows-145-internal", + "VCPKG_HOST_TRIPLET": "x64-windows-145-internal" } }, { @@ -51,8 +51,8 @@ "inherits": "x64-windows", "cacheVariables": { "CMAKE_BUILD_TYPE": "Release", - "VCPKG_TARGET_TRIPLET": "x64-windows-release", - "VCPKG_HOST_TRIPLET": "x64-windows-release" + "VCPKG_TARGET_TRIPLET": "x64-windows-145-release", + "VCPKG_HOST_TRIPLET": "x64-windows-145-release" } }, { @@ -60,8 +60,8 @@ "inherits": "x64-windows", "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug", - "VCPKG_TARGET_TRIPLET": "x64-windows-debug", - "VCPKG_HOST_TRIPLET": "x64-windows-debug" + "VCPKG_TARGET_TRIPLET": "x64-windows-145-debug", + "VCPKG_HOST_TRIPLET": "x64-windows-145-debug" } }, { @@ -69,8 +69,8 @@ "inherits": "x64-windows", "cacheVariables": { "CMAKE_BUILD_TYPE": "TrinityDev", - "VCPKG_TARGET_TRIPLET": "x64-windows-trinitydev", - "VCPKG_HOST_TRIPLET": "x64-windows-trinitydev" + "VCPKG_TARGET_TRIPLET": "x64-windows-145-trinitydev", + "VCPKG_HOST_TRIPLET": "x64-windows-145-trinitydev" } } ] diff --git a/NSession.cpp b/NSession.cpp index 86c054a..6f025ff 100644 --- a/NSession.cpp +++ b/NSession.cpp @@ -220,7 +220,7 @@ PyObject *NSession::Execute(PyObject *args) if (noblock && !mAllowSync) //this is a tasklet that cannot block, so execution might as well be done on this thread - return PyErr_SetString(PyExc_RuntimeError, "This tasklet cannot block, and synchronous calls are not allowed"), 0; + return PyErr_SetString(PyExc_RuntimeError, "This tasklet cannot block, and synchronous calls are not allowed"), nullptr; BluePy result; if (noblock) { diff --git a/SqlCommand.cpp b/SqlCommand.cpp index 70fe641..093061b 100644 --- a/SqlCommand.cpp +++ b/SqlCommand.cpp @@ -743,5 +743,5 @@ PyObject* SQLCommand::Raise(const char *msg, HRESULT hr, const CDBErrorInfo *err sql?sql:(wchar_t*)L"", paramErrors, columnErrors)); if (!errorArgs) return 0; - return PyErr_SetObject(Utilities::ErrorClass(hr), errorArgs), 0; + return PyErr_SetObject(Utilities::ErrorClass(hr), errorArgs), nullptr; } diff --git a/StringStore.h b/StringStore.h index ba24f2f..b815479 100644 --- a/StringStore.h +++ b/StringStore.h @@ -24,7 +24,7 @@ #ifndef STRINGSTORE_H #define STRINGSTORE_H -#include +#include #include "DelayedException.h" #include "BlockAllocator.h" @@ -45,7 +45,7 @@ class InternalStoreElement : public StoreElementBase mPython = false; mData = data; mElements = elems; - mHash = Hash(); + mHash = hash(); } InternalStoreElement(const InternalStoreElement& o) @@ -120,7 +120,7 @@ class InternalStoreElement : public StoreElementBase } memcpy( tmp, mData, mElements * elen ); mData = tmp; - return 0; + return nullptr; } PyObject* GetPython() override @@ -133,21 +133,23 @@ class InternalStoreElement : public StoreElementBase return mObject; } + size_t hash() const + { + // hash range of elements + size_t hash = 2166136261U; + const size_t maxHash = 64; + DataType* begin = mData; + DataType* end = mData + min(mElements, maxHash); + while (begin != end) + hash = 16777619U * hash ^ (size_t)*begin++; + + return hash; + } + + private: bool ToPython(); - size_t Hash() const - { - // hash range of elements - size_t hash = 2166136261U; - const size_t maxHash = 64; - DataType* begin = mData; - DataType* end = mData + min(mElements, maxHash); - while (begin != end) - hash = 16777619U * hash ^ (size_t)*begin++; - - return hash; - } // raw data and python object are stored in a mutually exclusive manner for memory efficiency union @@ -168,17 +170,45 @@ class InternalStoreElement : public StoreElementBase -typedef InternalStoreElement StringStoreElement; // utf-8 storage element -typedef InternalStoreElement ByteStoreElement; // byte storage element -typedef InternalStoreElement WStringStoreElement; // unicode storage element +using StringStoreElement = InternalStoreElement; // utf-8 storage element +using ByteStoreElement = InternalStoreElement; // byte storage element +using WStringStoreElement = InternalStoreElement; // unicode storage element + +template<> +struct std::hash +{ + std::size_t operator()(const StringStoreElement& s) const noexcept + { + return s.hash(); + } +}; + +template<> +struct std::hash +{ + std::size_t operator()(const ByteStoreElement& s) const noexcept + { + return s.hash(); + } +}; + +template<> +struct std::hash +{ + std::size_t operator()(const WStringStoreElement& s) const noexcept + { + return s.hash(); + } +}; + template class InternalStore { public: explicit InternalStore(SimplePoolAllocator& allocator) : - mAllocator( allocator ), - mSet( traits_t(), allocator_t( allocator ) ) + m_stlAllocator(allocator), + mSet( m_stlAllocator ) { mMemSaved = 0; } @@ -203,7 +233,7 @@ class InternalStore res = 0; if(r.second) { - DelayedException* e = el.Claim( mAllocator ); + DelayedException* e = el.Claim( m_stlAllocator.mA ); if(e) { return e; @@ -220,13 +250,14 @@ class InternalStore size_t GetMemSaved() const { return mMemSaved; } private: - typedef stdext::hash_compare traits_t; - typedef StlPoolAllocator allocator_t; + using traits_t = std::hash; + using keyEqual = std::equal_to; + using allocator_t = StlPoolAllocator; - SimplePoolAllocator& mAllocator; - typedef stdext::hash_set InternalStoreSet_t; - typedef typename InternalStoreSet_t::iterator InternalStoreSet_iterator; + using InternalStoreSet_t = std::unordered_set; + using InternalStoreSet_iterator = typename InternalStoreSet_t::iterator; + allocator_t m_stlAllocator; InternalStoreSet_t mSet; size_t mMemSaved; // how much memory (without overhead) saved by the reuse }; diff --git a/tests/TestTools.cpp b/tests/TestTools.cpp index ff76b33..f3dbd32 100644 --- a/tests/TestTools.cpp +++ b/tests/TestTools.cpp @@ -18,7 +18,7 @@ PyObject* TestTools::TestParameter( int db_type, PyObject* value ) return nullptr; BluePy getMem = BluePy( PyImport_Import( BluePyStr( "sys" ) ) ); if( !getMem ) - return false; + return nullptr; getMem = BluePy( PyObject_GetAttrString( getMem, "getpymalloced" ) ); if( !getMem ) PyErr_Clear(); // not supported, continue diff --git a/vcpkg.json b/vcpkg.json index c2214b2..e830227 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -18,10 +18,6 @@ { "name": "openssl", "version": "1.1.1k#8" - }, - { - "name": "protobuf", - "version": "3.6.0.1" } ] } \ No newline at end of file diff --git a/vendor/github.com/carbonengine/vcpkg-registry b/vendor/github.com/carbonengine/vcpkg-registry index de86dca..2647de9 160000 --- a/vendor/github.com/carbonengine/vcpkg-registry +++ b/vendor/github.com/carbonengine/vcpkg-registry @@ -1 +1 @@ -Subproject commit de86dcad60458ef170911adb5c42a053fc5d9117 +Subproject commit 2647de96bab1a4134c8edb27a0868d2fa38ab51b diff --git a/vendor/github.com/microsoft/vcpkg b/vendor/github.com/microsoft/vcpkg index 53b9816..6d9d7df 160000 --- a/vendor/github.com/microsoft/vcpkg +++ b/vendor/github.com/microsoft/vcpkg @@ -1 +1 @@ -Subproject commit 53b9816594558d0b78529ecce2bf4a97d0a0729e +Subproject commit 6d9d7df564a1ccdaa994e4ad39ccd4a32360867b