You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
2.0 KiB

  1. From 26dd9766757895c04b33a89865e3886f18146332 Mon Sep 17 00:00:00 2001
  2. From: Yousong Zhou <yszhou4tech@gmail.com>
  3. Date: Sat, 24 Feb 2018 13:45:25 +0800
  4. Subject: [PATCH] disas: fix compilation failure when isnan is a macro
  5. ---
  6. disas/libvixl/vixl/utils.h | 16 +++++++++++-----
  7. 1 file changed, 11 insertions(+), 5 deletions(-)
  8. --- a/disas/libvixl/vixl/utils.h
  9. +++ b/disas/libvixl/vixl/utils.h
  10. @@ -118,11 +118,17 @@ double double_pack(uint64_t sign, uint64
  11. // An fpclassify() function for 16-bit half-precision floats.
  12. int float16classify(float16 value);
  13. +#ifdef isnan
  14. +#define isnan_ isnan
  15. +#else
  16. +#define isnan_ std::isnan
  17. +#endif
  18. +
  19. // NaN tests.
  20. inline bool IsSignallingNaN(double num) {
  21. const uint64_t kFP64QuietNaNMask = UINT64_C(0x0008000000000000);
  22. uint64_t raw = double_to_rawbits(num);
  23. - if (std::isnan(num) && ((raw & kFP64QuietNaNMask) == 0)) {
  24. + if (isnan_(num) && ((raw & kFP64QuietNaNMask) == 0)) {
  25. return true;
  26. }
  27. return false;
  28. @@ -132,7 +138,7 @@ inline bool IsSignallingNaN(double num)
  29. inline bool IsSignallingNaN(float num) {
  30. const uint32_t kFP32QuietNaNMask = 0x00400000;
  31. uint32_t raw = float_to_rawbits(num);
  32. - if (std::isnan(num) && ((raw & kFP32QuietNaNMask) == 0)) {
  33. + if (isnan_(num) && ((raw & kFP32QuietNaNMask) == 0)) {
  34. return true;
  35. }
  36. return false;
  37. @@ -148,21 +154,21 @@ inline bool IsSignallingNaN(float16 num)
  38. template <typename T>
  39. inline bool IsQuietNaN(T num) {
  40. - return std::isnan(num) && !IsSignallingNaN(num);
  41. + return isnan_(num) && !IsSignallingNaN(num);
  42. }
  43. // Convert the NaN in 'num' to a quiet NaN.
  44. inline double ToQuietNaN(double num) {
  45. const uint64_t kFP64QuietNaNMask = UINT64_C(0x0008000000000000);
  46. - VIXL_ASSERT(std::isnan(num));
  47. + VIXL_ASSERT(isnan_(num));
  48. return rawbits_to_double(double_to_rawbits(num) | kFP64QuietNaNMask);
  49. }
  50. inline float ToQuietNaN(float num) {
  51. const uint32_t kFP32QuietNaNMask = 0x00400000;
  52. - VIXL_ASSERT(std::isnan(num));
  53. + VIXL_ASSERT(isnan_(num));
  54. return rawbits_to_float(float_to_rawbits(num) | kFP32QuietNaNMask);
  55. }