[sgen] Allocate job data dynamically.
[mono.git] / mono / utils / strtod.c
index 6f08b124fc7ce2a01750a7db97456f0d77f08769..708e485017c1fce347a87ce877fa3937a6f76399 100644 (file)
  * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
  *
  ***************************************************************/
+#include "config.h"
 #include "strtod.h"
 #include <glib.h>
 #define freedtoa __freedtoa
 #define dtoa __dtoa
 
+#define Omit_Private_Memory
+#define MULTIPLE_THREADS 1
+/* Lock 0 is not used because of USE_MALLOC, Lock 1 protects a lazy-initialized table */
+#define ACQUIRE_DTOA_LOCK(n)
+#define FREE_DTOA_LOCK(n)
+
 /* Please send bug reports to David M. Gay (dmg at acm dot org,
  * with " at " changed at "@" and " dot " changed to ".").     */
 
  * #define NO_ERRNO if strtod should not assign errno = ERANGE when
  *     the result overflows to +-Infinity or underflows to 0.
  */
-#if defined(i386) || defined(mips) && defined(MIPSEL) || defined (__arm__)
+#if defined(TARGET_X86) || defined(mips) && defined(MIPSEL) || defined (__arm__)
 
 #   define IEEE_8087
 
-#elif defined(__x86_64__) || defined(__alpha__)
+#elif defined(TARGET_AMD64) || defined(__alpha__)
 
 #   define IEEE_8087
 
@@ -216,6 +223,7 @@ extern void *MALLOC(size_t);
 #define MALLOC malloc
 #endif
 
+#define Omit_Private_Memory
 #ifndef Omit_Private_Memory
 #ifndef PRIVATE_MEM
 #define PRIVATE_MEM 2304
@@ -558,13 +566,17 @@ Bfree
        (Bigint *v)
 #endif
 {
+#ifdef Omit_Private_Memory
+       free (v);
+#else
        if (v) {
                ACQUIRE_DTOA_LOCK(0);
                v->next = freelist[v->k];
                freelist[v->k] = v;
                FREE_DTOA_LOCK(0);
-               }
        }
+#endif
+}
 
 #define Bcopy(x,y) memcpy((char *)&x->sign, (char *)&y->sign, \
 y->wds*sizeof(Long) + 2*sizeof(int))
@@ -1189,16 +1201,16 @@ b2d
        *e = 32 - k;
 #ifdef Pack_32
        if (k < Ebits) {
-               d0 = Exp_1 | y >> Ebits - k;
+               d0 = Exp_1 | (y >> (Ebits - k));
                w = xa > xa0 ? *--xa : 0;
-               d1 = y << (32-Ebits) + k | w >> Ebits - k;
+               d1 = y << ((32-Ebits) + k) | (w >> (Ebits - k));
                goto ret_d;
                }
        z = xa > xa0 ? *--xa : 0;
        if (k -= Ebits) {
-               d0 = Exp_1 | y << k | z >> 32 - k;
+               d0 = Exp_1 | y << k | (z >> (32 - k));
                y = xa > xa0 ? *--xa : 0;
-               d1 = z << k | y >> 32 - k;
+               d1 = z << k | (y >> (32 - k));
                }
        else {
                d0 = Exp_1 | y;
@@ -1275,7 +1287,7 @@ d2b
 #ifdef Pack_32
        if ((y = d1)) {
                if ((k = lo0bits(&y))) {
-                       x[0] = y | z << 32 - k;
+                       x[0] = y | (z << (32 - k));
                        z >>= k;
                        }
                else
@@ -1537,8 +1549,13 @@ hexnan
 #endif /*No_Hex_NaN*/
 #endif /* INFNAN_CHECK */
 
+       /*
+        * LOCKING: This is not thread-safe, since the locking macros are defined as no-ops,
+        * the caller should lock.
+        */
+
  double
-bsd_strtod
+mono_strtod
 #ifdef KR_headers
        (s00, se) CONST char *s00; char **se;
 #else
@@ -1554,7 +1571,7 @@ bsd_strtod
        double aadj, aadj1, adj, rv, rv0;
        Long L;
        ULong y, z;
-       Bigint *bb, *bb1, *bd, *bd0, *bs, *delta;
+       Bigint *bb = NULL, *bb1, *bd = NULL, *bd0, *bs = NULL, *delta = NULL;
 #ifdef SET_INEXACT
        int inexact, oldinexact;
 #endif
@@ -1918,7 +1935,7 @@ bsd_strtod
                                        if (j >= 53)
                                         word0(rv) = (P+2)*Exp_msk1;
                                        else
-                                        word0(rv) &= 0xffffffff << j-32;
+                                        word0(rv) &= 0xffffffff << (j-32);
                                        }
                                else
                                        word1(rv) &= 0xffffffff << j;
@@ -2594,9 +2611,9 @@ nrv_alloc(char *s, char **rve, int n)
  * when MULTIPLE_THREADS is not defined.
  */
 
-void freedtoa (char *s);
+static void freedtoa (char *s);
 
- void
+static void
 #ifdef KR_headers
 freedtoa(s) char *s;
 #else