Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
d5f5725c
Unverified
Commit
d5f5725c
authored
Mar 14, 2018
by
Feng Xiao
Committed by
GitHub
Mar 14, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4310 from KindDragon/patch-1
Support using MSVC intrinsics in Log2FloorNonZero
parents
89b5333a
22c477d9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
6 deletions
+9
-6
port.h
src/google/protobuf/stubs/port.h
+9
-6
No files found.
src/google/protobuf/stubs/port.h
View file @
d5f5725c
...
...
@@ -91,6 +91,7 @@
// These #includes are for the byte swap functions declared later on.
#ifdef _MSC_VER
#include <stdlib.h> // NOLINT(build/include)
#include <intrin.h>
#elif defined(__APPLE__)
#include <libkern/OSByteOrder.h>
#elif defined(__GLIBC__) || defined(__CYGWIN__)
...
...
@@ -394,12 +395,10 @@ class Bits {
static
uint32
Log2FloorNonZero
(
uint32
n
)
{
#if defined(__GNUC__)
return
31
^
static_cast
<
uint32
>
(
__builtin_clz
(
n
));
#elif defined(COMPILER_MSVC) && defined(_M_IX86)
_asm
{
bsr
ebx
,
n
mov
n
,
ebx
}
return
n
;
#elif defined(_MSC_VER)
unsigned
long
where
;
_BitScanReverse
(
&
where
,
n
);
return
where
;
#else
return
Log2FloorNonZero_Portable
(
n
);
#endif
...
...
@@ -414,6 +413,10 @@ class Bits {
// implementation instead.
#if defined(__GNUC__) && !defined(GOOGLE_PROTOBUF_USE_PORTABLE_LOG2)
return
63
^
static_cast
<
uint32
>
(
__builtin_clzll
(
n
));
#elif defined(_MSC_VER) && defined(_M_X64)
unsigned
long
where
;
_BitScanReverse64
(
&
where
,
n
);
return
where
;
#else
return
Log2FloorNonZero64_Portable
(
n
);
#endif
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment