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
ce3f7699
Commit
ce3f7699
authored
Sep 19, 2020
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge intrinsic blocks
parent
3b6248f6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
36 deletions
+8
-36
include/fmt/format-inl.h
include/fmt/format-inl.h
+0
-5
include/fmt/format.h
include/fmt/format.h
+8
-31
No files found.
include/fmt/format-inl.h
View file @
ce3f7699
...
@@ -40,11 +40,6 @@
...
@@ -40,11 +40,6 @@
# pragma warning(disable : 4702) // unreachable code
# pragma warning(disable : 4702) // unreachable code
#endif
#endif
// For x64-specific MSVC intrinsics
#if defined(_MSC_VER) && defined(_M_X64)
# include <intrin.h>
#endif
// Dummy implementations of strerror_r and strerror_s called if corresponding
// Dummy implementations of strerror_r and strerror_s called if corresponding
// system functions are not available.
// system functions are not available.
inline
fmt
::
detail
::
null
<>
strerror_r
(
int
,
char
*
,
...)
{
return
{};
}
inline
fmt
::
detail
::
null
<>
strerror_r
(
int
,
char
*
,
...)
{
return
{};
}
...
...
include/fmt/format.h
View file @
ce3f7699
...
@@ -189,12 +189,14 @@ FMT_END_NAMESPACE
...
@@ -189,12 +189,14 @@ FMT_END_NAMESPACE
# define FMT_BUILTIN_CTZLL(n) __builtin_ctzll(n)
# define FMT_BUILTIN_CTZLL(n) __builtin_ctzll(n)
#endif
#endif
#if FMT_MSC_VER
# include <intrin.h> // _BitScanReverse[64], _BitScanForward[64], _umul128
#endif
// Some compilers masquerade as both MSVC and GCC-likes or otherwise support
// 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
// __builtin_clz and __builtin_clzll, so only define FMT_BUILTIN_CLZ using the
// MSVC intrinsics if the clz and clzll builtins are not available.
// MSVC intrinsics if the clz and clzll builtins are not available.
#if FMT_MSC_VER && !defined(FMT_BUILTIN_CLZLL) && !defined(_MANAGED)
#if FMT_MSC_VER && !defined(FMT_BUILTIN_CLZLL) && !defined(FMT_BUILTIN_CTZLL) && !defined(_MANAGED)
# include <intrin.h> // _BitScanReverse, _BitScanReverse64
FMT_BEGIN_NAMESPACE
FMT_BEGIN_NAMESPACE
namespace
detail
{
namespace
detail
{
// Avoid Clang with Microsoft CodeGen's -Wunknown-pragmas warning.
// Avoid Clang with Microsoft CodeGen's -Wunknown-pragmas warning.
...
@@ -204,7 +206,6 @@ namespace detail {
...
@@ -204,7 +206,6 @@ namespace detail {
inline
int
clz
(
uint32_t
x
)
{
inline
int
clz
(
uint32_t
x
)
{
unsigned
long
r
=
0
;
unsigned
long
r
=
0
;
_BitScanReverse
(
&
r
,
x
);
_BitScanReverse
(
&
r
,
x
);
FMT_ASSERT
(
x
!=
0
,
""
);
FMT_ASSERT
(
x
!=
0
,
""
);
// Static analysis complains about using uninitialized data
// Static analysis complains about using uninitialized data
// "r", but the only way that can happen is if "x" is 0,
// "r", but the only way that can happen is if "x" is 0,
...
@@ -225,29 +226,15 @@ inline int clzll(uint64_t x) {
...
@@ -225,29 +226,15 @@ inline int clzll(uint64_t x) {
# else
# else
// Scan the high 32 bits.
// Scan the high 32 bits.
if
(
_BitScanReverse
(
&
r
,
static_cast
<
uint32_t
>
(
x
>>
32
)))
return
63
-
(
r
+
32
);
if
(
_BitScanReverse
(
&
r
,
static_cast
<
uint32_t
>
(
x
>>
32
)))
return
63
-
(
r
+
32
);
// Scan the low 32 bits.
// Scan the low 32 bits.
_BitScanReverse
(
&
r
,
static_cast
<
uint32_t
>
(
x
));
_BitScanReverse
(
&
r
,
static_cast
<
uint32_t
>
(
x
));
# endif
# endif
FMT_ASSERT
(
x
!=
0
,
""
);
FMT_ASSERT
(
x
!=
0
,
""
);
// Static analysis complains about using uninitialized data
FMT_SUPPRESS_MSC_WARNING
(
6102
)
// Suppress a bogus static analysis warning.
// "r", but the only way that can happen is if "x" is 0,
// which the callers guarantee to not happen.
FMT_SUPPRESS_MSC_WARNING
(
6102
)
return
63
-
static_cast
<
int
>
(
r
);
return
63
-
static_cast
<
int
>
(
r
);
}
}
# define FMT_BUILTIN_CLZLL(n) detail::clzll(n)
# define FMT_BUILTIN_CLZLL(n) detail::clzll(n)
}
// namespace detail
FMT_END_NAMESPACE
#endif
// Same for __builtin_ctz and __builtin_ctzll
#if FMT_MSC_VER && !defined(FMT_BUILTIN_CTZLL) && !defined(_MANAGED)
# include <intrin.h> // _BitScanReverse, _BitScanReverse64
FMT_BEGIN_NAMESPACE
namespace
detail
{
// Avoid Clang with Microsoft CodeGen's -Wunknown-pragmas warning.
// Avoid Clang with Microsoft CodeGen's -Wunknown-pragmas warning.
# ifndef __clang__
# ifndef __clang__
# pragma intrinsic(_BitScanForward)
# pragma intrinsic(_BitScanForward)
...
@@ -255,12 +242,8 @@ namespace detail {
...
@@ -255,12 +242,8 @@ namespace detail {
inline
int
ctz
(
uint32_t
x
)
{
inline
int
ctz
(
uint32_t
x
)
{
unsigned
long
r
=
0
;
unsigned
long
r
=
0
;
_BitScanForward
(
&
r
,
x
);
_BitScanForward
(
&
r
,
x
);
FMT_ASSERT
(
x
!=
0
,
""
);
FMT_ASSERT
(
x
!=
0
,
""
);
// Static analysis complains about using uninitialized data
FMT_SUPPRESS_MSC_WARNING
(
6102
)
// Suppress a bogus static analysis warning.
// "r", but the only way that can happen is if "x" is 0,
// which the callers guarantee to not happen.
FMT_SUPPRESS_MSC_WARNING
(
6102
)
return
static_cast
<
int
>
(
r
);
return
static_cast
<
int
>
(
r
);
}
}
# define FMT_BUILTIN_CTZ(n) detail::ctz(n)
# define FMT_BUILTIN_CTZ(n) detail::ctz(n)
...
@@ -272,23 +255,17 @@ inline int ctz(uint32_t x) {
...
@@ -272,23 +255,17 @@ inline int ctz(uint32_t x) {
inline
int
ctzll
(
uint64_t
x
)
{
inline
int
ctzll
(
uint64_t
x
)
{
unsigned
long
r
=
0
;
unsigned
long
r
=
0
;
FMT_ASSERT
(
x
!=
0
,
""
);
FMT_ASSERT
(
x
!=
0
,
""
);
// Static analysis complains about using uninitialized data
FMT_SUPPRESS_MSC_WARNING
(
6102
)
// Suppress a bogus static analysis warning.
// "r", but the only way that can happen is if "x" is 0,
// which the callers guarantee to not happen.
FMT_SUPPRESS_MSC_WARNING
(
6102
)
# ifdef _WIN64
# ifdef _WIN64
_BitScanForward64
(
&
r
,
x
);
_BitScanForward64
(
&
r
,
x
);
# else
# else
// Scan the low 32 bits.
// Scan the low 32 bits.
if
(
_BitScanForward
(
&
r
,
static_cast
<
uint32_t
>
(
x
)))
if
(
_BitScanForward
(
&
r
,
static_cast
<
uint32_t
>
(
x
)))
return
static_cast
<
int
>
(
r
);
return
static_cast
<
int
>
(
r
);
// Scan the high 32 bits.
// Scan the high 32 bits.
_BitScanForward
(
&
r
,
static_cast
<
uint32_t
>
(
x
>>
32
));
_BitScanForward
(
&
r
,
static_cast
<
uint32_t
>
(
x
>>
32
));
r
+=
32
;
r
+=
32
;
# endif
# endif
return
static_cast
<
int
>
(
r
);
return
static_cast
<
int
>
(
r
);
}
}
# define FMT_BUILTIN_CTZLL(n) detail::ctzll(n)
# define FMT_BUILTIN_CTZLL(n) detail::ctzll(n)
...
...
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