Document two argument form of gdb.Value constructor
[deliverable/binutils-gdb.git] / libdecnumber / decNumber.c
index ebc7cf0fb50bffbdde33e0ab071b484bfd3bd24d..e4194211fdcaf2df1239c53b18ec8f4481cc0520 100644 (file)
@@ -1,32 +1,27 @@
 /* Decimal number arithmetic module for the decNumber C Library.
 /* Decimal number arithmetic module for the decNumber C Library.
-   Copyright (C) 2005, 2007 Free Software Foundation, Inc.
+   Copyright (C) 2005-2018 Free Software Foundation, Inc.
    Contributed by IBM Corporation.  Author Mike Cowlishaw.
 
    This file is part of GCC.
 
    GCC is free software; you can redistribute it and/or modify it under
    the terms of the GNU General Public License as published by the Free
    Contributed by IBM Corporation.  Author Mike Cowlishaw.
 
    This file is part of GCC.
 
    GCC is free software; you can redistribute it and/or modify it under
    the terms of the GNU General Public License as published by the Free
-   Software Foundation; either version 2, or (at your option) any later
+   Software Foundation; either version 3, or (at your option) any later
    version.
 
    version.
 
-   In addition to the permissions in the GNU General Public License,
-   the Free Software Foundation gives you unlimited permission to link
-   the compiled version of this file into combinations with other
-   programs, and to distribute those combinations without any
-   restriction coming from the use of this file.  (The General Public
-   License restrictions do apply in other respects; for example, they
-   cover modification of the file, and distribution when not linked
-   into a combine executable.)
-
    GCC is distributed in the hope that it will be useful, but WITHOUT ANY
    WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    for more details.
 
    GCC is distributed in the hope that it will be useful, but WITHOUT ANY
    WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    for more details.
 
-   You should have received a copy of the GNU General Public License
-   along with GCC; see the file COPYING.  If not, write to the Free
-   Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA.  */
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
 
 /* ------------------------------------------------------------------ */
 /* Decimal Number arithmetic module                                  */
 
 /* ------------------------------------------------------------------ */
 /* Decimal Number arithmetic module                                  */
@@ -716,7 +711,7 @@ decNumber * decNumberFromString(decNumber *dn, const char chars[],
     /* decNumberShow(dn); */
     } while(0);                        /* [for break] */
 
     /* decNumberShow(dn); */
     } while(0);                        /* [for break] */
 
-  if (allocres!=NULL) free(allocres);  /* drop any storage used */
+  free(allocres);      /* drop any storage used */
   if (status!=0) decStatus(dn, status, set);
   return dn;
   } /* decNumberFromString */
   if (status!=0) decStatus(dn, status, set);
   return dn;
   } /* decNumberFromString */
@@ -975,8 +970,8 @@ decNumber * decNumberCompareTotalMag(decNumber *res, const decNumber *lhs,
     decCompareOp(res, lhs, rhs, set, COMPTOTAL, &status);
     } while(0);                        /* end protected */
 
     decCompareOp(res, lhs, rhs, set, COMPTOTAL, &status);
     } while(0);                        /* end protected */
 
-  if (allocbufa!=NULL) free(allocbufa); /* drop any storage used */
-  if (allocbufb!=NULL) free(allocbufb); /* .. */
+  free(allocbufa); /* drop any storage used */
+  free(allocbufb); /* .. */
   if (status!=0) decStatus(res, status, set);
   return res;
   } /* decNumberCompareTotalMag */
   if (status!=0) decStatus(res, status, set);
   return res;
   } /* decNumberCompareTotalMag */
@@ -1079,7 +1074,7 @@ decNumber * decNumberExp(decNumber *res, const decNumber *rhs,
     } while(0);                        /* end protected */
 
   #if DECSUBSET
     } while(0);                        /* end protected */
 
   #if DECSUBSET
-  if (allocrhs !=NULL) free(allocrhs); /* drop any storage used */
+  free(allocrhs);      /* drop any storage used */
   #endif
   /* apply significant status */
   if (status!=0) decStatus(res, status, set);
   #endif
   /* apply significant status */
   if (status!=0) decStatus(res, status, set);
@@ -1174,7 +1169,7 @@ decNumber * decNumberFMA(decNumber *res, const decNumber *lhs,
     decAddOp(res, acc, fhs, set, 0, &status);
     } while(0);                        /* end protected */
 
     decAddOp(res, acc, fhs, set, 0, &status);
     } while(0);                        /* end protected */
 
-  if (allocbufa!=NULL) free(allocbufa); /* drop any storage used */
+  free(allocbufa); /* drop any storage used */
   if (status!=0) decStatus(res, status, set);
   #if DECCHECK
   decCheckInexact(res, set);
   if (status!=0) decStatus(res, status, set);
   #if DECCHECK
   decCheckInexact(res, set);
@@ -1301,7 +1296,7 @@ decNumber * decNumberLn(decNumber *res, const decNumber *rhs,
     } while(0);                        /* end protected */
 
   #if DECSUBSET
     } while(0);                        /* end protected */
 
   #if DECSUBSET
-  if (allocrhs !=NULL) free(allocrhs); /* drop any storage used */
+  free(allocrhs);      /* drop any storage used */
   #endif
   /* apply significant status */
   if (status!=0) decStatus(res, status, set);
   #endif
   /* apply significant status */
   if (status!=0) decStatus(res, status, set);
@@ -1514,10 +1509,10 @@ decNumber * decNumberLog10(decNumber *res, const decNumber *rhs,
     decDivideOp(res, a, b, &aset, DIVIDE, &status); /* into result */
     } while(0);                        /* [for break] */
 
     decDivideOp(res, a, b, &aset, DIVIDE, &status); /* into result */
     } while(0);                        /* [for break] */
 
-  if (allocbufa!=NULL) free(allocbufa); /* drop any storage used */
-  if (allocbufb!=NULL) free(allocbufb); /* .. */
+  free(allocbufa); /* drop any storage used */
+  free(allocbufb); /* .. */
   #if DECSUBSET
   #if DECSUBSET
-  if (allocrhs !=NULL) free(allocrhs); /* .. */
+  free(allocrhs);      /* .. */
   #endif
   /* apply significant status */
   if (status!=0) decStatus(res, status, set);
   #endif
   /* apply significant status */
   if (status!=0) decStatus(res, status, set);
@@ -2176,7 +2171,7 @@ decNumber * decNumberPower(decNumber *res, const decNumber *lhs,
       /* if a negative power the constant 1 is needed, and if not subset */
       /* invert the lhs now rather than inverting the result later */
       if (decNumberIsNegative(rhs)) {  /* was a **-n [hence digits>0] */
       /* if a negative power the constant 1 is needed, and if not subset */
       /* invert the lhs now rather than inverting the result later */
       if (decNumberIsNegative(rhs)) {  /* was a **-n [hence digits>0] */
-       decNumber *inv=invbuff;         /* asssume use fixed buffer */
+       decNumber *inv=invbuff;         /* assume use fixed buffer */
        decNumberCopy(&dnOne, dac);     /* dnOne=1;  [needed now or later] */
        #if DECSUBSET
        if (set->extended) {            /* need to calculate 1/lhs */
        decNumberCopy(&dnOne, dac);     /* dnOne=1;  [needed now or later] */
        #if DECSUBSET
        if (set->extended) {            /* need to calculate 1/lhs */
@@ -2258,11 +2253,11 @@ decNumber * decNumberPower(decNumber *res, const decNumber *lhs,
     #endif
     } while(0);                        /* end protected */
 
     #endif
     } while(0);                        /* end protected */
 
-  if (allocdac!=NULL) free(allocdac);  /* drop any storage used */
-  if (allocinv!=NULL) free(allocinv);  /* .. */
+  free(allocdac);      /* drop any storage used */
+  free(allocinv);      /* .. */
   #if DECSUBSET
   #if DECSUBSET
-  if (alloclhs!=NULL) free(alloclhs);  /* .. */
-  if (allocrhs!=NULL) free(allocrhs);  /* .. */
+  free(alloclhs);      /* .. */
+  free(allocrhs);      /* .. */
   #endif
   if (status!=0) decStatus(res, status, set);
   #if DECCHECK
   #endif
   if (status!=0) decStatus(res, status, set);
   #if DECCHECK
@@ -2354,7 +2349,7 @@ decNumber * decNumberReduce(decNumber *res, const decNumber *rhs,
     } while(0);                             /* end protected */
 
   #if DECSUBSET
     } while(0);                             /* end protected */
 
   #if DECSUBSET
-  if (allocrhs !=NULL) free(allocrhs);      /* .. */
+  free(allocrhs);           /* .. */
   #endif
   if (status!=0) decStatus(res, status, set);/* then report status */
   return res;
   #endif
   if (status!=0) decStatus(res, status, set);/* then report status */
   return res;
@@ -3116,11 +3111,11 @@ decNumber * decNumberSquareRoot(decNumber *res, const decNumber *rhs,
     decNumberCopy(res, a);                  /* a is now the result */
     } while(0);                             /* end protected */
 
     decNumberCopy(res, a);                  /* a is now the result */
     } while(0);                             /* end protected */
 
-  if (allocbuff!=NULL) free(allocbuff);      /* drop any storage used */
-  if (allocbufa!=NULL) free(allocbufa);      /* .. */
-  if (allocbufb!=NULL) free(allocbufb);      /* .. */
+  free(allocbuff);      /* drop any storage used */
+  free(allocbufa);      /* .. */
+  free(allocbufb);      /* .. */
   #if DECSUBSET
   #if DECSUBSET
-  if (allocrhs !=NULL) free(allocrhs);      /* .. */
+  free(allocrhs);           /* .. */
   #endif
   if (status!=0) decStatus(res, status, set);/* then report status */
   #if DECCHECK
   #endif
   if (status!=0) decStatus(res, status, set);/* then report status */
   #if DECCHECK
@@ -4135,10 +4130,10 @@ static decNumber * decAddOp(decNumber *res, const decNumber *lhs,
       }
     } while(0);                             /* end protected */
 
       }
     } while(0);                             /* end protected */
 
-  if (allocacc!=NULL) free(allocacc);       /* drop any storage used */
+  free(allocacc);           /* drop any storage used */
   #if DECSUBSET
   #if DECSUBSET
-  if (allocrhs!=NULL) free(allocrhs);       /* .. */
-  if (alloclhs!=NULL) free(alloclhs);       /* .. */
+  free(allocrhs);           /* .. */
+  free(alloclhs);           /* .. */
   #endif
   return res;
   } /* decAddOp */
   #endif
   return res;
   } /* decAddOp */
@@ -4787,11 +4782,11 @@ static decNumber * decDivideOp(decNumber *res,
     #endif
     } while(0);                             /* end protected */
 
     #endif
     } while(0);                             /* end protected */
 
-  if (varalloc!=NULL) free(varalloc);  /* drop any storage used */
-  if (allocacc!=NULL) free(allocacc);  /* .. */
+  free(varalloc);      /* drop any storage used */
+  free(allocacc);      /* .. */
   #if DECSUBSET
   #if DECSUBSET
-  if (allocrhs!=NULL) free(allocrhs);  /* .. */
-  if (alloclhs!=NULL) free(alloclhs);  /* .. */
+  free(allocrhs);      /* .. */
+  free(alloclhs);      /* .. */
   #endif
   return res;
   } /* decDivideOp */
   #endif
   return res;
   } /* decDivideOp */
@@ -5132,14 +5127,14 @@ static decNumber * decMultiplyOp(decNumber *res, const decNumber *lhs,
     decFinish(res, set, &residue, status);   /* final cleanup */
     } while(0);                        /* end protected */
 
     decFinish(res, set, &residue, status);   /* final cleanup */
     } while(0);                        /* end protected */
 
-  if (allocacc!=NULL) free(allocacc);  /* drop any storage used */
+  free(allocacc);      /* drop any storage used */
   #if DECSUBSET
   #if DECSUBSET
-  if (allocrhs!=NULL) free(allocrhs);  /* .. */
-  if (alloclhs!=NULL) free(alloclhs);  /* .. */
+  free(allocrhs);      /* .. */
+  free(alloclhs);      /* .. */
   #endif
   #if FASTMUL
   #endif
   #if FASTMUL
-  if (allocrhi!=NULL) free(allocrhi);  /* .. */
-  if (alloclhi!=NULL) free(alloclhi);  /* .. */
+  free(allocrhi);      /* .. */
+  free(alloclhi);      /* .. */
   #endif
   return res;
   } /* decMultiplyOp */
   #endif
   return res;
   } /* decMultiplyOp */
@@ -5202,7 +5197,7 @@ static decNumber * decMultiplyOp(decNumber *res, const decNumber *lhs,
 /*    exp(-x) where x can be the tiniest number (Ntiny).             */
 /*                                                                   */
 /* 2. Normalizing x to be <=0.1 (instead of <=1) reduces loop        */
 /*    exp(-x) where x can be the tiniest number (Ntiny).             */
 /*                                                                   */
 /* 2. Normalizing x to be <=0.1 (instead of <=1) reduces loop        */
-/*    iterations by appoximately a third with additional (although    */
+/*    iterations by approximately a third with additional (although    */
 /*    diminishing) returns as the range is reduced to even smaller    */
 /*    fractions.  However, h (the power of 10 used to correct the     */
 /*    result at the end, see below) must be kept <=8 as otherwise     */
 /*    diminishing) returns as the range is reduced to even smaller    */
 /*    fractions.  However, h (the power of 10 used to correct the     */
 /*    result at the end, see below) must be kept <=8 as otherwise     */
@@ -5488,9 +5483,9 @@ decNumber * decExpOp(decNumber *res, const decNumber *rhs,
     decFinish(res, set, &residue, status);      /* cleanup/set flags */
     } while(0);                        /* end protected */
 
     decFinish(res, set, &residue, status);      /* cleanup/set flags */
     } while(0);                        /* end protected */
 
-  if (allocrhs !=NULL) free(allocrhs); /* drop any storage used */
-  if (allocbufa!=NULL) free(allocbufa); /* .. */
-  if (allocbuft!=NULL) free(allocbuft); /* .. */
+  free(allocrhs);      /* drop any storage used */
+  free(allocbufa); /* .. */
+  free(allocbuft); /* .. */
   /* [status is handled by caller] */
   return res;
   } /* decExpOp */
   /* [status is handled by caller] */
   return res;
   } /* decExpOp */
@@ -5799,8 +5794,8 @@ decNumber * decLnOp(decNumber *res, const decNumber *rhs,
     decFinish(res, set, &residue, status);      /* cleanup/set flags */
     } while(0);                        /* end protected */
 
     decFinish(res, set, &residue, status);      /* cleanup/set flags */
     } while(0);                        /* end protected */
 
-  if (allocbufa!=NULL) free(allocbufa); /* drop any storage used */
-  if (allocbufb!=NULL) free(allocbufb); /* .. */
+  free(allocbufa); /* drop any storage used */
+  free(allocbufb); /* .. */
   /* [status is handled by caller] */
   return res;
   } /* decLnOp */
   /* [status is handled by caller] */
   return res;
   } /* decLnOp */
@@ -5964,8 +5959,8 @@ static decNumber * decQuantizeOp(decNumber *res, const decNumber *lhs,
     } while(0);                        /* end protected */
 
   #if DECSUBSET
     } while(0);                        /* end protected */
 
   #if DECSUBSET
-  if (allocrhs!=NULL) free(allocrhs);  /* drop any storage used */
-  if (alloclhs!=NULL) free(alloclhs);  /* .. */
+  free(allocrhs);      /* drop any storage used */
+  free(alloclhs);      /* .. */
   #endif
   return res;
   } /* decQuantizeOp */
   #endif
   return res;
   } /* decQuantizeOp */
@@ -6034,11 +6029,11 @@ decNumber * decCompareOp(decNumber *res, const decNumber *lhs,
 
     /* If total ordering then handle differing signs 'up front' */
     if (op==COMPTOTAL) {               /* total ordering */
 
     /* If total ordering then handle differing signs 'up front' */
     if (op==COMPTOTAL) {               /* total ordering */
-      if (decNumberIsNegative(lhs) & !decNumberIsNegative(rhs)) {
+      if (decNumberIsNegative(lhs) && !decNumberIsNegative(rhs)) {
        result=-1;
        break;
        }
        result=-1;
        break;
        }
-      if (!decNumberIsNegative(lhs) & decNumberIsNegative(rhs)) {
+      if (!decNumberIsNegative(lhs) && decNumberIsNegative(rhs)) {
        result=+1;
        break;
        }
        result=+1;
        break;
        }
@@ -6147,8 +6142,8 @@ decNumber * decCompareOp(decNumber *res, const decNumber *lhs,
       }
     }
   #if DECSUBSET
       }
     }
   #if DECSUBSET
-  if (allocrhs!=NULL) free(allocrhs);  /* free any storage used */
-  if (alloclhs!=NULL) free(alloclhs);  /* .. */
+  free(allocrhs);      /* free any storage used */
+  free(alloclhs);      /* .. */
   #endif
   return res;
   } /* decCompareOp */
   #endif
   return res;
   } /* decCompareOp */
@@ -6282,7 +6277,7 @@ static Int decUnitCompare(const Unit *a, Int alength,
     result=(*u==0 ? 0 : +1);
     }
   /* clean up and return the result */
     result=(*u==0 ? 0 : +1);
     }
   /* clean up and return the result */
-  if (allocacc!=NULL) free(allocacc);  /* drop any storage used */
+  free(allocacc);      /* drop any storage used */
   return result;
   } /* decUnitCompare */
 
   return result;
   } /* decUnitCompare */
 
This page took 0.02864 seconds and 4 git commands to generate.