Skip to content

Commit 361d363

Browse files
committed
a separate .cpp for supporting objects
1 parent 6dcf2cb commit 361d363

File tree

3 files changed

+42
-8
lines changed

3 files changed

+42
-8
lines changed

library/src/safe_ptr.cpp

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/* -------------------------------------------------------------------------------
2+
* Copyright (c) 2018, OLogN Technologies AG
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
* * Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* * Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
* * Neither the name of the OLogN Technologies AG nor the
13+
* names of its contributors may be used to endorse or promote products
14+
* derived from this software without specific prior written permission.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
* DISCLAIMED. IN NO EVENT SHALL OLogN Technologies AG BE LIABLE FOR ANY
20+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
* -------------------------------------------------------------------------------*/
27+
28+
#include "safe_ptr.h"
29+
30+
#ifdef NODECPP_ENABLE_ONSTACK_SOFTPTR_COUNTING
31+
thread_local size_t nodecpp::safememory::onStackSafePtrCreationCount = 0;
32+
thread_local size_t nodecpp::safememory::onStackSafePtrDestructionCount = 0;
33+
#endif // NODECPP_ENABLE_ONSTACK_SOFTPTR_COUNTING
34+
35+
thread_local void* nodecpp::safememory::thg_stackPtrForMakeOwningCall = 0;

library/test/build/TestSafePointers.vcxproj

+7-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@
1919
</ProjectConfiguration>
2020
</ItemGroup>
2121
<ItemGroup>
22-
<ClCompile Include="..\..\gcc_lto_workaround\gcc_lto_workaround.cpp" />
22+
<ClCompile Include="..\..\gcc_lto_workaround\gcc_lto_workaround.cpp">
23+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
24+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
25+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
26+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
27+
</ClCompile>
2328
<ClCompile Include="..\..\src\iibmalloc\src\foundation\3rdparty\fmt\src\format.cc" />
2429
<ClCompile Include="..\..\src\iibmalloc\src\foundation\src\log.cpp" />
2530
<ClCompile Include="..\..\src\iibmalloc\src\foundation\src\safe_memory_error.cpp" />
@@ -47,6 +52,7 @@
4752
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
4853
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
4954
</ClCompile>
55+
<ClCompile Include="..\..\src\safe_ptr.cpp" />
5056
<ClCompile Include="..\test_safe_pointers.cpp" />
5157
</ItemGroup>
5258
<ItemGroup>

library/test/test_safe_pointers.cpp

-7
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,6 @@
4040
//template<> struct nodecpp::safememory::safeness_declarator<double> { static constexpr bool is_safe = false; }; // user-defined exclusion
4141
//template<> struct nodecpp::safememory::safeness_declarator<nodecpp::safememory::testing::dummy_objects::StructureWithSoftPtrDeclaredUnsafe> { static constexpr bool is_safe = false; }; // user-defined exclusion
4242

43-
#ifdef NODECPP_ENABLE_ONSTACK_SOFTPTR_COUNTING
44-
thread_local size_t nodecpp::safememory::onStackSafePtrCreationCount;
45-
thread_local size_t nodecpp::safememory::onStackSafePtrDestructionCount;
46-
#endif // NODECPP_ENABLE_ONSTACK_SOFTPTR_COUNTING
47-
48-
thread_local void* nodecpp::safememory::thg_stackPtrForMakeOwningCall = 0;
49-
5043
using namespace nodecpp::safememory;
5144
using namespace nodecpp::safememory::testing::dummy_objects;
5245

0 commit comments

Comments
 (0)