Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fmt
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
fmt
Commits
979e70f1
Commit
979e70f1
authored
Jan 08, 2016
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #259 from mwinterb/unknown_pragma_bsr
Fixed unknown pragma warnings for _BitScanReverse.
parents
39438034
b203beb6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
70 deletions
+61
-70
format.h
format.h
+61
-70
No files found.
format.h
View file @
979e70f1
...
...
@@ -75,52 +75,6 @@ typedef __int64 intmax_t;
# define FMT_API
#endif
#if defined(_MSC_VER)
# include <intrin.h> // _BitScanReverse, _BitScanReverse64
namespace
fmt
{
namespace
internal
{
# pragma intrinsic(_BitScanReverse)
inline
uint32_t
clz
(
uint32_t
x
)
{
unsigned
long
r
=
0
;
_BitScanReverse
(
&
r
,
x
);
assert
(
x
!=
0
);
// Static analysis complains about using uninitialized data
// "r", but the only way that can happen is if "x" is 0,
// which the callers guarantee to not happen.
#pragma warning(suppress: 6102)
return
31
-
r
;
}
# ifdef _WIN64
# pragma intrinsic(_BitScanReverse64)
# endif
inline
uint32_t
clzll
(
uint64_t
x
)
{
unsigned
long
r
=
0
;
# ifdef _WIN64
_BitScanReverse64
(
&
r
,
x
);
# else
// Scan the high 32 bits.
if
(
_BitScanReverse
(
&
r
,
static_cast
<
uint32_t
>
(
x
>>
32
)))
return
63
-
(
r
+
32
);
// Scan the low 32 bits.
_BitScanReverse
(
&
r
,
static_cast
<
uint32_t
>
(
x
));
# endif
assert
(
x
!=
0
);
// Static analysis complains about using uninitialized data
// "r", but the only way that can happen is if "x" is 0,
// which the callers guarantee to not happen.
#pragma warning(suppress: 6102)
return
63
-
r
;
}
}
}
#endif
#ifdef __GNUC__
# define FMT_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
# define FMT_GCC_EXTENSION __extension__
...
...
@@ -262,6 +216,67 @@ inline uint32_t clzll(uint64_t x) {
# define FMT_ASSERT(condition, message) assert((condition) && message)
#endif
#if FMT_GCC_VERSION >= 400 || FMT_HAS_BUILTIN(__builtin_clz)
# define FMT_BUILTIN_CLZ(n) __builtin_clz(n)
#endif
#if FMT_GCC_VERSION >= 400 || FMT_HAS_BUILTIN(__builtin_clzll)
# define FMT_BUILTIN_CLZLL(n) __builtin_clzll(n)
#endif
// Some compilers masquerade as both MSVC and GCC-likes or
// otherwise support __builtin_clz and __builtin_clzll, so
// only define FMT_BUILTIN_CLZ using the MSVC intrinsics
// if the clz and clzll builtins are not available.
#if defined(_MSC_VER) && !defined(FMT_BUILTIN_CLZLL)
# include <intrin.h> // _BitScanReverse, _BitScanReverse64
namespace
fmt
{
namespace
internal
{
# pragma intrinsic(_BitScanReverse)
inline
uint32_t
clz
(
uint32_t
x
)
{
unsigned
long
r
=
0
;
_BitScanReverse
(
&
r
,
x
);
assert
(
x
!=
0
);
// Static analysis complains about using uninitialized data
// "r", but the only way that can happen is if "x" is 0,
// which the callers guarantee to not happen.
# pragma warning(suppress: 6102)
return
31
-
r
;
}
# define FMT_BUILTIN_CLZ(n) fmt::internal::clz(n)
# ifdef _WIN64
# pragma intrinsic(_BitScanReverse64)
# endif
inline
uint32_t
clzll
(
uint64_t
x
)
{
unsigned
long
r
=
0
;
# ifdef _WIN64
_BitScanReverse64
(
&
r
,
x
);
# else
// Scan the high 32 bits.
if
(
_BitScanReverse
(
&
r
,
static_cast
<
uint32_t
>
(
x
>>
32
)))
return
63
-
(
r
+
32
);
// Scan the low 32 bits.
_BitScanReverse
(
&
r
,
static_cast
<
uint32_t
>
(
x
));
# endif
assert
(
x
!=
0
);
// Static analysis complains about using uninitialized data
// "r", but the only way that can happen is if "x" is 0,
// which the callers guarantee to not happen.
# pragma warning(suppress: 6102)
return
63
-
r
;
}
# define FMT_BUILTIN_CLZLL(n) fmt::internal::clzll(n)
}
}
#endif
namespace
fmt
{
namespace
internal
{
struct
DummyInt
{
...
...
@@ -803,30 +818,6 @@ struct FMT_API BasicData {
typedef
BasicData
<>
Data
;
#if FMT_GCC_VERSION >= 400 || FMT_HAS_BUILTIN(__builtin_clz)
# define FMT_BUILTIN_CLZ(n) __builtin_clz(n)
#endif
#if FMT_GCC_VERSION >= 400 || FMT_HAS_BUILTIN(__builtin_clzll)
# define FMT_BUILTIN_CLZLL(n) __builtin_clzll(n)
#endif
#if defined(_MSC_VER)
// Some compilers masquerade as both MSVC and GCC-likes or
// otherwise support __builtin_clz and __builtin_clzll, so
// only define FMT_BUILTIN_CLZ using the MSVC intrinsics
// if the clz and clzll builtins are not available.
#if !defined(FMT_BUILTIN_CLZ)
# define FMT_BUILTIN_CLZ(n) fmt::internal::clz(n)
#endif
#if !defined(FMT_BUILTIN_CLZLL)
# define FMT_BUILTIN_CLZLL(n) fmt::internal::clzll(n)
#endif
#endif
#ifdef FMT_BUILTIN_CLZLL
// Returns the number of decimal digits in n. Leading zeros are not counted
...
...
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