File tree 3 files changed +87
-9
lines changed
ruby/ext/google/protobuf_c
3 files changed +87
-9
lines changed Original file line number Diff line number Diff line change @@ -6256,9 +6256,35 @@ bool _upb_mapsorter_pushexts(_upb_mapsorter* s,
6256
6256
6257
6257
// Must be last.
6258
6258
6259
- const float kUpb_FltInfinity = INFINITY;
6260
- const double kUpb_Infinity = INFINITY;
6261
- const double kUpb_NaN = NAN;
6259
+ // The latest win32 SDKs have an invalid definition of NAN.
6260
+ // https://developercommunity.visualstudio.com/t/NAN-is-no-longer-compile-time-constant-i/10688907
6261
+ //
6262
+ // Unfortunately, the `0.0 / 0.0` workaround doesn't work in Clang under C23, so
6263
+ // try __builtin_nan first, if that exists.
6264
+ #ifdef _WIN32
6265
+ #ifdef __has_builtin
6266
+ #if __has_builtin(__builtin_nan)
6267
+ #define UPB_NAN __builtin_nan("0")
6268
+ #endif
6269
+ #if __has_builtin(__builtin_inf)
6270
+ #define UPB_INFINITY __builtin_inf()
6271
+ #endif
6272
+ #endif
6273
+ #ifndef UPB_NAN
6274
+ #define UPB_NAN 0.0 / 0.0
6275
+ #endif
6276
+ #ifndef UPB_INFINITY
6277
+ #define UPB_INFINITY 1.0 / 0.0
6278
+ #endif
6279
+ #else
6280
+ // For !_WIN32, assume math.h works.
6281
+ #define UPB_NAN NAN
6282
+ #define UPB_INFINITY INFINITY
6283
+ #endif
6284
+
6285
+ const float kUpb_FltInfinity = UPB_INFINITY;
6286
+ const double kUpb_Infinity = UPB_INFINITY;
6287
+ const double kUpb_NaN = UPB_NAN;
6262
6288
6263
6289
static const size_t overhead = sizeof(upb_Message_InternalData);
6264
6290
Original file line number Diff line number Diff line change @@ -5771,9 +5771,35 @@ bool _upb_mapsorter_pushexts(_upb_mapsorter* s,
5771
5771
5772
5772
// Must be last.
5773
5773
5774
- const float kUpb_FltInfinity = INFINITY ;
5775
- const double kUpb_Infinity = INFINITY ;
5776
- const double kUpb_NaN = NAN ;
5774
+ // The latest win32 SDKs have an invalid definition of NAN.
5775
+ // https://developercommunity.visualstudio.com/t/NAN-is-no-longer-compile-time-constant-i/10688907
5776
+ //
5777
+ // Unfortunately, the `0.0 / 0.0` workaround doesn't work in Clang under C23, so
5778
+ // try __builtin_nan first, if that exists.
5779
+ #ifdef _WIN32
5780
+ #ifdef __has_builtin
5781
+ #if __has_builtin (__builtin_nan )
5782
+ #define UPB_NAN __builtin_nan("0")
5783
+ #endif
5784
+ #if __has_builtin (__builtin_inf )
5785
+ #define UPB_INFINITY __builtin_inf()
5786
+ #endif
5787
+ #endif
5788
+ #ifndef UPB_NAN
5789
+ #define UPB_NAN 0.0 / 0.0
5790
+ #endif
5791
+ #ifndef UPB_INFINITY
5792
+ #define UPB_INFINITY 1.0 / 0.0
5793
+ #endif
5794
+ #else
5795
+ // For !_WIN32, assume math.h works.
5796
+ #define UPB_NAN NAN
5797
+ #define UPB_INFINITY INFINITY
5798
+ #endif
5799
+
5800
+ const float kUpb_FltInfinity = UPB_INFINITY ;
5801
+ const double kUpb_Infinity = UPB_INFINITY ;
5802
+ const double kUpb_NaN = UPB_NAN ;
5777
5803
5778
5804
static const size_t overhead = sizeof (upb_Message_InternalData );
5779
5805
Original file line number Diff line number Diff line change 15
15
// Must be last.
16
16
#include "upb/port/def.inc"
17
17
18
- const float kUpb_FltInfinity = INFINITY ;
19
- const double kUpb_Infinity = INFINITY ;
20
- const double kUpb_NaN = NAN ;
18
+ // The latest win32 SDKs have an invalid definition of NAN.
19
+ // https://developercommunity.visualstudio.com/t/NAN-is-no-longer-compile-time-constant-i/10688907
20
+ //
21
+ // Unfortunately, the `0.0 / 0.0` workaround doesn't work in Clang under C23, so
22
+ // try __builtin_nan first, if that exists.
23
+ #ifdef _WIN32
24
+ #ifdef __has_builtin
25
+ #if __has_builtin (__builtin_nan )
26
+ #define UPB_NAN __builtin_nan("0")
27
+ #endif
28
+ #if __has_builtin (__builtin_inf )
29
+ #define UPB_INFINITY __builtin_inf()
30
+ #endif
31
+ #endif
32
+ #ifndef UPB_NAN
33
+ #define UPB_NAN 0.0 / 0.0
34
+ #endif
35
+ #ifndef UPB_INFINITY
36
+ #define UPB_INFINITY 1.0 / 0.0
37
+ #endif
38
+ #else
39
+ // For !_WIN32, assume math.h works.
40
+ #define UPB_NAN NAN
41
+ #define UPB_INFINITY INFINITY
42
+ #endif
43
+
44
+ const float kUpb_FltInfinity = UPB_INFINITY ;
45
+ const double kUpb_Infinity = UPB_INFINITY ;
46
+ const double kUpb_NaN = UPB_NAN ;
21
47
22
48
static const size_t overhead = sizeof (upb_Message_InternalData );
23
49
You can’t perform that action at this time.
0 commit comments