| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef PLATFORM_C99_SUPPORT_WIN_H_ | 5 #ifndef PLATFORM_C99_SUPPORT_WIN_H_ |
| 6 #define PLATFORM_C99_SUPPORT_WIN_H_ | 6 #define PLATFORM_C99_SUPPORT_WIN_H_ |
| 7 | 7 |
| 8 #if defined(_MSC_VER) && (_MSC_VER < 1800) | 8 #if defined(_MSC_VER) && (_MSC_VER < 1800) |
| 9 | 9 |
| 10 // Before Visual Studio 2013 Visual C++ was missing a bunch of C99 math macros | 10 // Before Visual Studio 2013 Visual C++ was missing a bunch of C99 math macros |
| 11 // and functions. Define them here. | 11 // and functions. Define them here. |
| 12 | 12 |
| 13 #include <float.h> | 13 #include <float.h> |
| 14 #include <string.h> | 14 #include <string.h> |
| 15 | 15 |
| 16 #include <cmath> |
| 17 |
| 16 static const unsigned __int64 kQuietNaNMask = | 18 static const unsigned __int64 kQuietNaNMask = |
| 17 static_cast<unsigned __int64>(0xfff) << 51; | 19 static_cast<unsigned __int64>(0xfff) << 51; |
| 18 | 20 |
| 19 | 21 |
| 20 #ifndef va_copy | 22 #ifndef va_copy |
| 21 #define va_copy(dst, src) (memmove(&(dst), &(src), sizeof(dst))) | 23 #define va_copy(dst, src) (memmove(&(dst), &(src), sizeof(dst))) |
| 22 #endif /* va_copy */ | 24 #endif /* va_copy */ |
| 23 | 25 |
| 24 | 26 |
| 25 #define INFINITY HUGE_VAL | 27 #define INFINITY HUGE_VAL |
| 26 #define NAN \ | 28 #define NAN \ |
| 27 *reinterpret_cast<const double*>(&kQuietNaNMask) | 29 *reinterpret_cast<const double*>(&kQuietNaNMask) |
| 28 | 30 |
| 31 namespace std { |
| 32 |
| 29 static inline int isinf(double x) { | 33 static inline int isinf(double x) { |
| 30 return (_fpclass(x) & (_FPCLASS_PINF | _FPCLASS_NINF)) != 0; | 34 return (_fpclass(x) & (_FPCLASS_PINF | _FPCLASS_NINF)) != 0; |
| 31 } | 35 } |
| 32 | 36 |
| 33 static inline int isnan(double x) { | 37 static inline int isnan(double x) { |
| 34 return _isnan(x); | 38 return _isnan(x); |
| 35 } | 39 } |
| 36 | 40 |
| 37 static inline int signbit(double x) { | 41 static inline int signbit(double x) { |
| 38 if (x == 0) { | 42 if (x == 0) { |
| 39 return _fpclass(x) & _FPCLASS_NZ; | 43 return _fpclass(x) & _FPCLASS_NZ; |
| 40 } else { | 44 } else { |
| 41 return x < 0; | 45 return x < 0; |
| 42 } | 46 } |
| 43 } | 47 } |
| 44 | 48 |
| 49 } // namespace std |
| 50 |
| 45 static inline double trunc(double x) { | 51 static inline double trunc(double x) { |
| 46 if (x < 0) { | 52 if (x < 0) { |
| 47 return ceil(x); | 53 return ceil(x); |
| 48 } else { | 54 } else { |
| 49 return floor(x); | 55 return floor(x); |
| 50 } | 56 } |
| 51 } | 57 } |
| 52 | 58 |
| 53 static inline double round(double x) { | 59 static inline double round(double x) { |
| 54 if (!_finite(x)) { | 60 if (!_finite(x)) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 68 } | 74 } |
| 69 | 75 |
| 70 // Windows does not have strtoll defined. | 76 // Windows does not have strtoll defined. |
| 71 #if defined(_MSC_VER) | 77 #if defined(_MSC_VER) |
| 72 #define strtoll _strtoi64 | 78 #define strtoll _strtoi64 |
| 73 #endif | 79 #endif |
| 74 | 80 |
| 75 #endif | 81 #endif |
| 76 | 82 |
| 77 #endif // PLATFORM_C99_SUPPORT_WIN_H_ | 83 #endif // PLATFORM_C99_SUPPORT_WIN_H_ |
| OLD | NEW |