File tree Expand file tree Collapse file tree 3 files changed +38
-3
lines changed
include/rapidjson/internal Expand file tree Collapse file tree 3 files changed +38
-3
lines changed Original file line number Diff line number Diff line change 17
17
18
18
#include " ../rapidjson.h"
19
19
20
- #if defined(_MSC_VER)
20
+ #if defined(_MSC_VER) && !defined(UNDER_CE)
21
21
#include < intrin.h>
22
22
#if defined(_WIN64)
23
23
#pragma intrinsic(_BitScanReverse64)
@@ -34,7 +34,7 @@ inline uint32_t clzll(uint64_t x) {
34
34
// infinite loop in the software implementation.
35
35
RAPIDJSON_ASSERT (x != 0 );
36
36
37
- #if defined(_MSC_VER)
37
+ #if defined(_MSC_VER) && !defined(UNDER_CE)
38
38
unsigned long r = 0 ;
39
39
#if defined(_WIN64)
40
40
_BitScanReverse64 (&r, x);
@@ -53,7 +53,7 @@ inline uint32_t clzll(uint64_t x) {
53
53
return static_cast <uint32_t >(__builtin_clzll (x));
54
54
#else
55
55
// naive version
56
- uint32_t r;
56
+ uint32_t r = 0 ;
57
57
while (!(x & (static_cast <uint64_t >(1 ) << 63 ))) {
58
58
x <<= 1 ;
59
59
++r;
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ include(CheckCXXCompilerFlag)
3
3
set (UNITTEST_SOURCES
4
4
allocatorstest.cpp
5
5
bigintegertest.cpp
6
+ clzlltest.cpp
6
7
cursorstreamwrappertest.cpp
7
8
documenttest.cpp
8
9
dtoatest.cpp
Original file line number Diff line number Diff line change
1
+ // Tencent is pleased to support the open source community by making RapidJSON available.
2
+ //
3
+ // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
4
+ //
5
+ // Licensed under the MIT License (the "License"); you may not use this file except
6
+ // in compliance with the License. You may obtain a copy of the License at
7
+ //
8
+ // http://opensource.org/licenses/MIT
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software distributed
11
+ // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12
+ // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13
+ // specific language governing permissions and limitations under the License.
14
+
15
+ #include " unittest.h"
16
+ #include " rapidjson/internal/clzll.h"
17
+
18
+ #ifdef __GNUC__
19
+ RAPIDJSON_DIAG_PUSH
20
+ #endif
21
+
22
+ using namespace rapidjson ::internal;
23
+
24
+ TEST (clzll, normal) {
25
+ EXPECT_EQ (clzll (1 ), 63U );
26
+ EXPECT_EQ (clzll (2 ), 62U );
27
+ EXPECT_EQ (clzll (12 ), 60U );
28
+ EXPECT_EQ (clzll (0x0000000080000001UL ), 32U );
29
+ EXPECT_EQ (clzll (0x8000000000000001UL ), 0U );
30
+ }
31
+
32
+ #ifdef __GNUC__
33
+ RAPIDJSON_DIAG_POP
34
+ #endif
You can’t perform that action at this time.
0 commit comments