Diff for /embedaddon/libxml2/trionan.c between versions 1.1.1.1 and 1.1.1.2

version 1.1.1.1, 2012/02/21 23:37:58 version 1.1.1.2, 2014/06/15 19:53:29
Line 261  trio_pinf(TRIO_NOARGS) Line 261  trio_pinf(TRIO_NOARGS)
   static double result = 0.0;    static double result = 0.0;
   
   if (result == 0.0) {    if (result == 0.0) {
    
 #if defined(INFINITY) && defined(__STDC_IEC_559__)  #if defined(INFINITY) && defined(__STDC_IEC_559__)
     result = (double)INFINITY;      result = (double)INFINITY;
   
Line 283  trio_pinf(TRIO_NOARGS) Line 283  trio_pinf(TRIO_NOARGS)
       /* Force overflow */        /* Force overflow */
       result += HUGE_VAL;        result += HUGE_VAL;
     }      }
    
 # if defined(TRIO_PLATFORM_UNIX)  # if defined(TRIO_PLATFORM_UNIX)
     signal(SIGFPE, signal_handler);      signal(SIGFPE, signal_handler);
 # endif  # endif
Line 326  trio_nan(TRIO_NOARGS) Line 326  trio_nan(TRIO_NOARGS)
   static double result = 0.0;    static double result = 0.0;
   
   if (result == 0.0) {    if (result == 0.0) {
    
 #if defined(TRIO_COMPILER_SUPPORTS_C99)  #if defined(TRIO_COMPILER_SUPPORTS_C99)
     result = nan("");      result = nan("");
   
 #elif defined(NAN) && defined(__STDC_IEC_559__)  #elif defined(NAN) && defined(__STDC_IEC_559__)
     result = (double)NAN;      result = (double)NAN;
  
 #elif defined(USE_IEEE_754)  #elif defined(USE_IEEE_754)
     result = trio_make_double(ieee_754_qnan_array);      result = trio_make_double(ieee_754_qnan_array);
   
Line 349  trio_nan(TRIO_NOARGS) Line 349  trio_nan(TRIO_NOARGS)
 # if defined(TRIO_PLATFORM_UNIX)  # if defined(TRIO_PLATFORM_UNIX)
     void (*signal_handler)(int) = signal(SIGFPE, SIG_IGN);      void (*signal_handler)(int) = signal(SIGFPE, SIG_IGN);
 # endif  # endif
    
     result = trio_pinf() / trio_pinf();      result = trio_pinf() / trio_pinf();
    
 # if defined(TRIO_PLATFORM_UNIX)  # if defined(TRIO_PLATFORM_UNIX)
     signal(SIGFPE, signal_handler);      signal(SIGFPE, signal_handler);
 # endif  # endif
    
 #endif  #endif
   }    }
   return result;    return result;
Line 381  TRIO_ARGS1((number), Line 381  TRIO_ARGS1((number),
    * the conservative approach and only use it for UNIX95.     * the conservative approach and only use it for UNIX95.
    */     */
   return isnan(number);    return isnan(number);
  
 #elif defined(TRIO_COMPILER_MSVC) || defined(TRIO_COMPILER_BCB)  #elif defined(TRIO_COMPILER_MSVC) || defined(TRIO_COMPILER_BCB)
   /*    /*
    * Microsoft Visual C++ and Borland C++ Builder have an _isnan()     * Microsoft Visual C++ and Borland C++ Builder have an _isnan()
Line 398  TRIO_ARGS1((number), Line 398  TRIO_ARGS1((number),
   int is_special_quantity;    int is_special_quantity;
   
   is_special_quantity = trio_is_special_quantity(number, &has_mantissa);    is_special_quantity = trio_is_special_quantity(number, &has_mantissa);
  
   return (is_special_quantity && has_mantissa);    return (is_special_quantity && has_mantissa);
  
 #else  #else
   /*    /*
    * Fallback solution     * Fallback solution
    */     */
   int status;    int status;
   double integral, fraction;    double integral, fraction;
  
 # if defined(TRIO_PLATFORM_UNIX)  # if defined(TRIO_PLATFORM_UNIX)
   void (*signal_handler)(int) = signal(SIGFPE, SIG_IGN);    void (*signal_handler)(int) = signal(SIGFPE, SIG_IGN);
 # endif  # endif
  
   status = (/*    status = (/*
              * NaN is the only number which does not compare to itself               * NaN is the only number which does not compare to itself
              */               */
Line 422  TRIO_ARGS1((number), Line 422  TRIO_ARGS1((number),
             ((number != 0.0) &&              ((number != 0.0) &&
              (fraction = modf(number, &integral),               (fraction = modf(number, &integral),
               integral == fraction)));                integral == fraction)));
  
 # if defined(TRIO_PLATFORM_UNIX)  # if defined(TRIO_PLATFORM_UNIX)
   signal(SIGFPE, signal_handler);    signal(SIGFPE, signal_handler);
 # endif  # endif
  
   return status;    return status;
  
 #endif  #endif
 }  }
   
Line 459  TRIO_ARGS1((number), Line 459  TRIO_ARGS1((number),
   return isinf(number)    return isinf(number)
     ? ((number > 0.0) ? 1 : -1)      ? ((number > 0.0) ? 1 : -1)
     : 0;      : 0;
  
 #elif defined(TRIO_COMPILER_MSVC) || defined(TRIO_COMPILER_BCB)  #elif defined(TRIO_COMPILER_MSVC) || defined(TRIO_COMPILER_BCB)
   /*    /*
    * Microsoft Visual C++ and Borland C++ Builder have an _fpclass()     * Microsoft Visual C++ and Borland C++ Builder have an _fpclass()
Line 478  TRIO_ARGS1((number), Line 478  TRIO_ARGS1((number),
   int is_special_quantity;    int is_special_quantity;
   
   is_special_quantity = trio_is_special_quantity(number, &has_mantissa);    is_special_quantity = trio_is_special_quantity(number, &has_mantissa);
  
   return (is_special_quantity && !has_mantissa)    return (is_special_quantity && !has_mantissa)
     ? ((number < 0.0) ? -1 : 1)      ? ((number < 0.0) ? -1 : 1)
     : 0;      : 0;
Line 488  TRIO_ARGS1((number), Line 488  TRIO_ARGS1((number),
    * Fallback solution.     * Fallback solution.
    */     */
   int status;    int status;
  
 # if defined(TRIO_PLATFORM_UNIX)  # if defined(TRIO_PLATFORM_UNIX)
   void (*signal_handler)(int) = signal(SIGFPE, SIG_IGN);    void (*signal_handler)(int) = signal(SIGFPE, SIG_IGN);
 # endif  # endif
  
   double infinity = trio_pinf();    double infinity = trio_pinf();
  
   status = ((number == infinity)    status = ((number == infinity)
             ? 1              ? 1
             : ((number == -infinity) ? -1 : 0));              : ((number == -infinity) ? -1 : 0));
  
 # if defined(TRIO_PLATFORM_UNIX)  # if defined(TRIO_PLATFORM_UNIX)
   signal(SIGFPE, signal_handler);    signal(SIGFPE, signal_handler);
 # endif  # endif
  
   return status;    return status;
  
 #endif  #endif
 }  }
   
Line 526  TRIO_ARGS1((number), Line 526  TRIO_ARGS1((number),
    * C99 defines isfinite() as a macro.     * C99 defines isfinite() as a macro.
    */     */
   return isfinite(number);    return isfinite(number);
  
 #elif defined(TRIO_COMPILER_MSVC) || defined(TRIO_COMPILER_BCB)  #elif defined(TRIO_COMPILER_MSVC) || defined(TRIO_COMPILER_BCB)
   /*    /*
    * Microsoft Visual C++ and Borland C++ Builder use _finite().     * Microsoft Visual C++ and Borland C++ Builder use _finite().
Line 547  TRIO_ARGS1((number), Line 547  TRIO_ARGS1((number),
    * Fallback solution.     * Fallback solution.
    */     */
   return ((trio_isinf(number) == 0) && (trio_isnan(number) == 0));    return ((trio_isinf(number) == 0) && (trio_isnan(number) == 0));
  
 #endif  #endif
 }  }
   
Line 596  TRIO_ARGS2((number, is_negative), Line 596  TRIO_ARGS2((number, is_negative),
 #  define TRIO_NEGATIVE_ZERO FP_NEG_ZERO  #  define TRIO_NEGATIVE_ZERO FP_NEG_ZERO
 #  define TRIO_POSITIVE_NORMAL FP_POS_NORM  #  define TRIO_POSITIVE_NORMAL FP_POS_NORM
 #  define TRIO_NEGATIVE_NORMAL FP_NEG_NORM  #  define TRIO_NEGATIVE_NORMAL FP_NEG_NORM
  
 # elif defined(TRIO_COMPILER_MSVC) || defined(TRIO_COMPILER_BCB)  # elif defined(TRIO_COMPILER_MSVC) || defined(TRIO_COMPILER_BCB)
   /*    /*
    * Microsoft Visual C++ and Borland C++ Builder have an _fpclass()     * Microsoft Visual C++ and Borland C++ Builder have an _fpclass()
Line 613  TRIO_ARGS2((number, is_negative), Line 613  TRIO_ARGS2((number, is_negative),
 #  define TRIO_NEGATIVE_ZERO _FPCLASS_NZ  #  define TRIO_NEGATIVE_ZERO _FPCLASS_NZ
 #  define TRIO_POSITIVE_NORMAL _FPCLASS_PN  #  define TRIO_POSITIVE_NORMAL _FPCLASS_PN
 #  define TRIO_NEGATIVE_NORMAL _FPCLASS_NN  #  define TRIO_NEGATIVE_NORMAL _FPCLASS_NN
  
 # elif defined(FP_PLUS_NORM)  # elif defined(FP_PLUS_NORM)
   /*    /*
    * HP-UX 9.x and 10.x have an fpclassify() function, that is different     * HP-UX 9.x and 10.x have an fpclassify() function, that is different
Line 678  TRIO_ARGS2((number, is_negative), Line 678  TRIO_ARGS2((number, is_negative),
     *is_negative = (number < 0.0);      *is_negative = (number < 0.0);
     return TRIO_FP_NORMAL;      return TRIO_FP_NORMAL;
   }    }
  
 # else  # else
   /*    /*
    * Fallback solution.     * Fallback solution.
    */     */
   int rc;    int rc;
  
   if (number == 0.0) {    if (number == 0.0) {
     /*      /*
      * In IEEE 754 the sign of zero is ignored in comparisons, so we       * In IEEE 754 the sign of zero is ignored in comparisons, so we
Line 716  TRIO_ARGS2((number, is_negative), Line 716  TRIO_ARGS2((number, is_negative),
   }    }
   *is_negative = (number < 0.0);    *is_negative = (number < 0.0);
   return TRIO_FP_NORMAL;    return TRIO_FP_NORMAL;
  
 # endif  # endif
 #endif  #endif
 }  }
Line 734  TRIO_ARGS1((number), Line 734  TRIO_ARGS1((number),
            double number)             double number)
 {  {
   int is_negative;    int is_negative;
  
   (void)trio_fpclassify_and_signbit(number, &is_negative);    (void)trio_fpclassify_and_signbit(number, &is_negative);
   return is_negative;    return is_negative;
 }  }
Line 753  TRIO_ARGS1((number), Line 753  TRIO_ARGS1((number),
            double number)             double number)
 {  {
   int dummy;    int dummy;
  
   return trio_fpclassify_and_signbit(number, &dummy);    return trio_fpclassify_and_signbit(number, &dummy);
 }  }
   
Line 828  int main(TRIO_NOARGS) Line 828  int main(TRIO_NOARGS)
   print_class("NNorm", -1.0);    print_class("NNorm", -1.0);
   print_class("PSub", 1.01e-307 - 1.00e-307);    print_class("PSub", 1.01e-307 - 1.00e-307);
   print_class("NSub", 1.00e-307 - 1.01e-307);    print_class("NSub", 1.00e-307 - 1.01e-307);
  
   printf("NaN : %4g 0x%02x%02x%02x%02x%02x%02x%02x%02x (%2d, %2d)\n",    printf("NaN : %4g 0x%02x%02x%02x%02x%02x%02x%02x%02x (%2d, %2d)\n",
          my_nan,           my_nan,
          ((unsigned char *)&my_nan)[0],           ((unsigned char *)&my_nan)[0],
Line 862  int main(TRIO_NOARGS) Line 862  int main(TRIO_NOARGS)
          ((unsigned char *)&my_ninf)[6],           ((unsigned char *)&my_ninf)[6],
          ((unsigned char *)&my_ninf)[7],           ((unsigned char *)&my_ninf)[7],
          trio_isnan(my_ninf), trio_isinf(my_ninf));           trio_isnan(my_ninf), trio_isinf(my_ninf));
  
 # if defined(TRIO_PLATFORM_UNIX)  # if defined(TRIO_PLATFORM_UNIX)
   signal_handler = signal(SIGFPE, SIG_IGN);    signal_handler = signal(SIGFPE, SIG_IGN);
 # endif  # endif
  
   my_pinf = DBL_MAX + DBL_MAX;    my_pinf = DBL_MAX + DBL_MAX;
   my_ninf = -my_pinf;    my_ninf = -my_pinf;
   my_nan = my_pinf / my_pinf;    my_nan = my_pinf / my_pinf;
Line 874  int main(TRIO_NOARGS) Line 874  int main(TRIO_NOARGS)
 # if defined(TRIO_PLATFORM_UNIX)  # if defined(TRIO_PLATFORM_UNIX)
   signal(SIGFPE, signal_handler);    signal(SIGFPE, signal_handler);
 # endif  # endif
  
   printf("NaN : %4g 0x%02x%02x%02x%02x%02x%02x%02x%02x (%2d, %2d)\n",    printf("NaN : %4g 0x%02x%02x%02x%02x%02x%02x%02x%02x (%2d, %2d)\n",
          my_nan,           my_nan,
          ((unsigned char *)&my_nan)[0],           ((unsigned char *)&my_nan)[0],
Line 908  int main(TRIO_NOARGS) Line 908  int main(TRIO_NOARGS)
          ((unsigned char *)&my_ninf)[6],           ((unsigned char *)&my_ninf)[6],
          ((unsigned char *)&my_ninf)[7],           ((unsigned char *)&my_ninf)[7],
          trio_isnan(my_ninf), trio_isinf(my_ninf));           trio_isnan(my_ninf), trio_isinf(my_ninf));
  
   return 0;    return 0;
 }  }
 #endif  #endif

Removed from v.1.1.1.1  
changed lines
  Added in v.1.1.1.2


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>