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
ee354022
Commit
ee354022
authored
Jun 29, 2015
by
Karol Ostrovsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MinGW64+MSYS2 compilation issues and portable isnan using MathLimits
parent
d40a0db2
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
21 additions
and
31 deletions
+21
-31
csharp_field_base.cc
src/google/protobuf/compiler/csharp/csharp_field_base.cc
+3
-7
common.h
src/google/protobuf/stubs/common.h
+8
-8
strutil.cc
src/google/protobuf/stubs/strutil.cc
+3
-7
text_format_unittest.cc
src/google/protobuf/text_format_unittest.cc
+3
-7
datapiece.cc
src/google/protobuf/util/internal/datapiece.cc
+2
-1
utility.cc
src/google/protobuf/util/internal/utility.cc
+2
-1
No files found.
src/google/protobuf/compiler/csharp/csharp_field_base.cc
View file @
ee354022
...
...
@@ -38,6 +38,7 @@
#include <google/protobuf/io/printer.h>
#include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/mathlimits.h>
#include <google/protobuf/compiler/csharp/csharp_field_base.h>
#include <google/protobuf/compiler/csharp/csharp_helpers.h>
...
...
@@ -248,11 +249,6 @@ bool FieldGeneratorBase::is_nullable_type() {
}
}
inline
bool
IsNaN
(
double
value
)
{
// NaN is never equal to anything, even itself.
return
value
!=
value
;
}
bool
AllPrintableAscii
(
const
std
::
string
&
text
)
{
for
(
int
i
=
0
;
i
<
text
.
size
();
i
++
)
{
if
(
text
[
i
]
<
0x20
||
text
[
i
]
>
0x7e
)
{
...
...
@@ -309,7 +305,7 @@ std::string FieldGeneratorBase::default_value() {
return
"double.PositiveInfinity"
;
}
else
if
(
value
==
-
numeric_limits
<
double
>::
infinity
())
{
return
"double.NegativeInfinity"
;
}
else
if
(
IsNaN
(
value
))
{
}
else
if
(
MathLimits
<
double
>::
IsNaN
(
value
))
{
return
"double.NaN"
;
}
return
SimpleDtoa
(
value
)
+
"D"
;
...
...
@@ -320,7 +316,7 @@ std::string FieldGeneratorBase::default_value() {
return
"float.PositiveInfinity"
;
}
else
if
(
value
==
-
numeric_limits
<
float
>::
infinity
())
{
return
"float.NegativeInfinity"
;
}
else
if
(
IsNaN
(
value
))
{
}
else
if
(
MathLimits
<
float
>::
IsNaN
(
value
))
{
return
"float.NaN"
;
}
return
SimpleFtoa
(
value
)
+
"F"
;
...
...
src/google/protobuf/stubs/common.h
View file @
ee354022
...
...
@@ -1459,14 +1459,14 @@ static inline uint32 bswap_32(uint32 x) {
}
#define bswap_32(x) bswap_32(x)
static
inline
uint64
bswap_64
(
uint64
x
)
{
return
(((
x
&
G
G
_ULONGLONG
(
0xFF
))
<<
56
)
|
((
x
&
G
G
_ULONGLONG
(
0xFF00
))
<<
40
)
|
((
x
&
G
G
_ULONGLONG
(
0xFF0000
))
<<
24
)
|
((
x
&
G
G
_ULONGLONG
(
0xFF000000
))
<<
8
)
|
((
x
&
G
G
_ULONGLONG
(
0xFF00000000
))
>>
8
)
|
((
x
&
G
G
_ULONGLONG
(
0xFF0000000000
))
>>
24
)
|
((
x
&
G
G
_ULONGLONG
(
0xFF000000000000
))
>>
40
)
|
((
x
&
G
G
_ULONGLONG
(
0xFF00000000000000
))
>>
56
));
return
(((
x
&
G
OOGLE
_ULONGLONG
(
0xFF
))
<<
56
)
|
((
x
&
G
OOGLE
_ULONGLONG
(
0xFF00
))
<<
40
)
|
((
x
&
G
OOGLE
_ULONGLONG
(
0xFF0000
))
<<
24
)
|
((
x
&
G
OOGLE
_ULONGLONG
(
0xFF000000
))
<<
8
)
|
((
x
&
G
OOGLE
_ULONGLONG
(
0xFF00000000
))
>>
8
)
|
((
x
&
G
OOGLE
_ULONGLONG
(
0xFF0000000000
))
>>
24
)
|
((
x
&
G
OOGLE
_ULONGLONG
(
0xFF000000000000
))
>>
40
)
|
((
x
&
G
OOGLE
_ULONGLONG
(
0xFF00000000000000
))
>>
56
));
}
#define bswap_64(x) bswap_64(x)
...
...
src/google/protobuf/stubs/strutil.cc
View file @
ee354022
...
...
@@ -31,6 +31,7 @@
// from google3/strings/strutil.cc
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/mathlimits.h>
#include <errno.h>
#include <float.h> // FLT_DIG and DBL_DIG
...
...
@@ -58,11 +59,6 @@
namespace
google
{
namespace
protobuf
{
inline
bool
IsNaN
(
double
value
)
{
// NaN is never equal to anything, even itself.
return
value
!=
value
;
}
// These are defined as macros on some platforms. #undef them so that we can
// redefine them.
#undef isxdigit
...
...
@@ -1210,7 +1206,7 @@ char* DoubleToBuffer(double value, char* buffer) {
}
else
if
(
value
==
-
numeric_limits
<
double
>::
infinity
())
{
strcpy
(
buffer
,
"-inf"
);
return
buffer
;
}
else
if
(
IsNaN
(
value
))
{
}
else
if
(
MathLimits
<
double
>::
IsNaN
(
value
))
{
strcpy
(
buffer
,
"nan"
);
return
buffer
;
}
...
...
@@ -1328,7 +1324,7 @@ char* FloatToBuffer(float value, char* buffer) {
}
else
if
(
value
==
-
numeric_limits
<
double
>::
infinity
())
{
strcpy
(
buffer
,
"-inf"
);
return
buffer
;
}
else
if
(
IsNaN
(
value
))
{
}
else
if
(
MathLimits
<
float
>::
IsNaN
(
value
))
{
strcpy
(
buffer
,
"nan"
);
return
buffer
;
}
...
...
src/google/protobuf/text_format_unittest.cc
View file @
ee354022
...
...
@@ -46,6 +46,7 @@
#include <google/protobuf/io/tokenizer.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/mathlimits.h>
#include <google/protobuf/stubs/substitute.h>
#include <google/protobuf/testing/googletest.h>
#include <gtest/gtest.h>
...
...
@@ -57,11 +58,6 @@ namespace protobuf {
// Can't use an anonymous namespace here due to brokenness of Tru64 compiler.
namespace
text_format_unittest
{
inline
bool
IsNaN
(
double
value
)
{
// NaN is never equal to anything, even itself.
return
value
!=
value
;
}
// A basic string with different escapable characters for testing.
const
string
kEscapeTestString
=
"
\"
A string with ' characters
\n
and
\r
newlines and
\t
tabs and
\001
"
...
...
@@ -898,8 +894,8 @@ TEST_F(TextFormatTest, ParseExotic) {
EXPECT_EQ
(
message
.
repeated_double
(
8
),
numeric_limits
<
double
>::
infinity
());
EXPECT_EQ
(
message
.
repeated_double
(
9
),
-
numeric_limits
<
double
>::
infinity
());
EXPECT_EQ
(
message
.
repeated_double
(
10
),
-
numeric_limits
<
double
>::
infinity
());
EXPECT_TRUE
(
IsNaN
(
message
.
repeated_double
(
11
)));
EXPECT_TRUE
(
IsNaN
(
message
.
repeated_double
(
12
)));
EXPECT_TRUE
(
MathLimits
<
double
>::
IsNaN
(
message
.
repeated_double
(
11
)));
EXPECT_TRUE
(
MathLimits
<
double
>::
IsNaN
(
message
.
repeated_double
(
12
)));
// Note: Since these string literals have \0's in them, we must explicitly
// pass their sizes to string's constructor.
...
...
src/google/protobuf/util/internal/datapiece.cc
View file @
ee354022
...
...
@@ -36,6 +36,7 @@
#include <google/protobuf/util/internal/utility.h>
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/mathutil.h>
#include <google/protobuf/stubs/mathlimits.h>
namespace
google
{
namespace
protobuf
{
...
...
@@ -78,7 +79,7 @@ StatusOr<To> NumberConvertAndCheck(From before) {
// For conversion between double and float only.
template
<
typename
To
,
typename
From
>
StatusOr
<
To
>
FloatingPointConvertAndCheck
(
From
before
)
{
if
(
isnan
(
before
))
return
std
::
numeric_limits
<
To
>::
quiet_NaN
();
if
(
MathLimits
<
From
>::
IsNaN
(
before
))
return
std
::
numeric_limits
<
To
>::
quiet_NaN
();
To
after
=
static_cast
<
To
>
(
before
);
if
(
MathUtil
::
AlmostEquals
<
To
>
(
after
,
before
))
{
...
...
src/google/protobuf/util/internal/utility.cc
View file @
ee354022
...
...
@@ -41,6 +41,7 @@
#include <google/protobuf/util/internal/constants.h>
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/map_util.h>
#include <google/protobuf/stubs/mathlimits.h>
namespace
google
{
namespace
protobuf
{
...
...
@@ -302,7 +303,7 @@ bool IsMap(const google::protobuf::Field& field,
string
DoubleAsString
(
double
value
)
{
if
(
value
==
std
::
numeric_limits
<
double
>::
infinity
())
return
"Infinity"
;
if
(
value
==
-
std
::
numeric_limits
<
double
>::
infinity
())
return
"-Infinity"
;
if
(
::
isnan
(
value
))
return
"NaN"
;
if
(
google
::
protobuf
::
MathLimits
<
double
>::
IsNaN
(
value
))
return
"NaN"
;
return
SimpleDtoa
(
value
);
}
...
...
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