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.

66 lines
2.2 KiB

  1. From fb90eacb808c3b1719d6a5f2deefe88c82589bfb 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 3/4] 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. diff --git a/disas/libvixl/vixl/utils.h b/disas/libvixl/vixl/utils.h
  9. index 5ab134e240..df30663df8 100644
  10. --- a/disas/libvixl/vixl/utils.h
  11. +++ b/disas/libvixl/vixl/utils.h
  12. @@ -118,11 +118,17 @@ double double_pack(uint64_t sign, uint64_t exp, uint64_t mantissa);
  13. // An fpclassify() function for 16-bit half-precision floats.
  14. int float16classify(float16 value);
  15. +#ifdef isnan
  16. +#define isnan_ isnan
  17. +#else
  18. +#define isnan_ std::isnan
  19. +#endif
  20. +
  21. // NaN tests.
  22. inline bool IsSignallingNaN(double num) {
  23. const uint64_t kFP64QuietNaNMask = UINT64_C(0x0008000000000000);
  24. uint64_t raw = double_to_rawbits(num);
  25. - if (std::isnan(num) && ((raw & kFP64QuietNaNMask) == 0)) {
  26. + if (isnan_(num) && ((raw & kFP64QuietNaNMask) == 0)) {
  27. return true;
  28. }
  29. return false;
  30. @@ -132,7 +138,7 @@ inline bool IsSignallingNaN(double num) {
  31. inline bool IsSignallingNaN(float num) {
  32. const uint32_t kFP32QuietNaNMask = 0x00400000;
  33. uint32_t raw = float_to_rawbits(num);
  34. - if (std::isnan(num) && ((raw & kFP32QuietNaNMask) == 0)) {
  35. + if (isnan_(num) && ((raw & kFP32QuietNaNMask) == 0)) {
  36. return true;
  37. }
  38. return false;
  39. @@ -148,21 +154,21 @@ inline bool IsSignallingNaN(float16 num) {
  40. template <typename T>
  41. inline bool IsQuietNaN(T num) {
  42. - return std::isnan(num) && !IsSignallingNaN(num);
  43. + return isnan_(num) && !IsSignallingNaN(num);
  44. }
  45. // Convert the NaN in 'num' to a quiet NaN.
  46. inline double ToQuietNaN(double num) {
  47. const uint64_t kFP64QuietNaNMask = UINT64_C(0x0008000000000000);
  48. - VIXL_ASSERT(std::isnan(num));
  49. + VIXL_ASSERT(isnan_(num));
  50. return rawbits_to_double(double_to_rawbits(num) | kFP64QuietNaNMask);
  51. }
  52. inline float ToQuietNaN(float num) {
  53. const uint32_t kFP32QuietNaNMask = 0x00400000;
  54. - VIXL_ASSERT(std::isnan(num));
  55. + VIXL_ASSERT(isnan_(num));
  56. return rawbits_to_float(float_to_rawbits(num) | kFP32QuietNaNMask);
  57. }