Skip to content

Commit 5364e05

Browse files
committed
Merge branch 'develop' of github.com:cheesema/AdaptiveParticleRepresentation into develop
ooops
2 parents aa49635 + 18928e2 commit 5364e05

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,11 @@ if(APR_BUILD_SHARED_LIB)
183183
if (APPLE)
184184
target_link_libraries(${SHARED_TARGET_NAME} PRIVATE -Wl,-force_load,$<TARGET_FILE:blosc_static>)
185185
else()
186-
target_link_libraries(${SHARED_TARGET_NAME} PRIVATE -Wl,--whole-archive $<TARGET_FILE:blosc_static> -Wl,--no-whole-archive)
186+
if(WIN32)
187+
target_link_libraries(${SHARED_TARGET_NAME} PRIVATE blosc_static)
188+
else()
189+
target_link_libraries(${SHARED_TARGET_NAME} PRIVATE -Wl,--whole-archive $<TARGET_FILE:blosc_static> -Wl,--no-whole-archive)
190+
endif()
187191
endif()
188192
endif()
189193
endif()

src/algorithm/LocalParticleCellSet.hpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,50 @@
55
#ifndef PARTPLAY_LOCAL_PARTICLE_SET_HPP
66
#define PARTPLAY_LOCAL_PARTICLE_SET_HPP
77

8+
#ifdef _MSC_VER
9+
#include <intrin.h>
10+
11+
// from https://github.com/llvm-mirror/libcxx/blob/9dcbb46826fd4d29b1485f25e8986d36019a6dca/include/support/win32/support.h#L106-L182
12+
// (c) Copyright (c) 2009-2017 by the contributors listed in https://github.com/llvm-mirror/libcxx/blob/9dcbb46826fd4d29b1485f25e8986d36019a6dca/CREDITS.TXT
13+
// Returns the number of leading 0-bits in x, starting at the most significant
14+
// bit position. If x is 0, the result is undefined.
15+
inline int __builtin_clzll(unsigned long long mask)
16+
{
17+
unsigned long where;
18+
// BitScanReverse scans from MSB to LSB for first set bit.
19+
// Returns 0 if no set bit is found.
20+
#if defined(_LIBCPP_HAS_BITSCAN64)
21+
if (_BitScanReverse64(&where, mask))
22+
return static_cast<int>(63 - where);
23+
#else
24+
// Scan the high 32 bits.
25+
if (_BitScanReverse(&where, static_cast<unsigned long>(mask >> 32)))
26+
return static_cast<int>(63 -
27+
(where + 32)); // Create a bit offset from the MSB.
28+
// Scan the low 32 bits.
29+
if (_BitScanReverse(&where, static_cast<unsigned long>(mask)))
30+
return static_cast<int>(63 - where);
31+
#endif
32+
return 64; // Undefined Behavior.
33+
}
34+
35+
inline int __builtin_clzl(unsigned long mask)
36+
{
37+
unsigned long where;
38+
// Search from LSB to MSB for first set bit.
39+
// Returns zero if no set bit is found.
40+
if (_BitScanReverse(&where, mask))
41+
return static_cast<int>(31 - where);
42+
return 32; // Undefined Behavior.
43+
}
44+
45+
inline int __builtin_clz(unsigned int x)
46+
{
47+
return __builtin_clzl(x);
48+
}
49+
50+
#endif
51+
852
class LocalParticleCellSet {
953

1054
public:

0 commit comments

Comments
 (0)