Browse Source

Mon Sep 24 17:14:05 CEST 2007 Paolo Molaro <[email protected]>

	* strtod.h, strtod.c: made the code threadsafe, fixed gcc warnings,
	renamed exported call and made it properly internal.


svn path=/trunk/mono/; revision=86260
Paolo Molaro 18 years ago
parent
commit
80f2541aa0
4 changed files with 25 additions and 12 deletions
  1. 1 1
      mono/metadata/icall.c
  2. 6 0
      mono/utils/ChangeLog
  3. 15 9
      mono/utils/strtod.c
  4. 3 2
      mono/utils/strtod.h

+ 1 - 1
mono/metadata/icall.c

@@ -96,7 +96,7 @@ mono_double_ParseImpl (char *ptr, double *result)
 		*result = strtod (ptr, &endptr);
 #else
 	if (*ptr)
-		*result = bsd_strtod (ptr, &endptr);
+		*result = mono_strtod (ptr, &endptr);
 #endif
 
 	if (!*ptr || (endptr && *endptr))

+ 6 - 0
mono/utils/ChangeLog

@@ -1,3 +1,9 @@
+
+Mon Sep 24 17:14:05 CEST 2007 Paolo Molaro <[email protected]>
+
+	* strtod.h, strtod.c: made the code threadsafe, fixed gcc warnings,
+	renamed exported call and made it properly internal.
+
 2007-09-14  Jonathan Chambers <[email protected]>
 
 	* mono-io-portability.c: Add HAVE_UNISTD_H check around include.

+ 15 - 9
mono/utils/strtod.c

@@ -21,6 +21,11 @@
 #define freedtoa __freedtoa
 #define dtoa __dtoa
 
+static GStaticMutex str_mutex [2] = {G_STATIC_MUTEX_INIT, G_STATIC_MUTEX_INIT};
+#define MULTIPLE_THREADS 1
+#define ACQUIRE_DTOA_LOCK(n)	g_static_mutex_lock (&str_mutex [(n)])
+#define FREE_DTOA_LOCK(n)	g_static_mutex_unlock (&str_mutex [(n)])
+
 /* Please send bug reports to David M. Gay (dmg at acm dot org,
  * with " at " changed at "@" and " dot " changed to ".").	*/
 
@@ -216,6 +221,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
@@ -1189,16 +1195,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 +1281,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
@@ -1538,7 +1544,7 @@ hexnan
 #endif /* INFNAN_CHECK */
 
  double
-bsd_strtod
+mono_strtod
 #ifdef KR_headers
 	(s00, se) CONST char *s00; char **se;
 #else
@@ -1918,7 +1924,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 +2600,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

+ 3 - 2
mono/utils/strtod.h

@@ -1,7 +1,8 @@
 #ifndef MONO_STRTOD_H
 #define MONO_STRTOD_H 1
 
-double bsd_strtod (const char *s00, char **se);
-char *__bsd_dtoa  (double d, int mode, int ndigits, int *decpt, int *sign, char **rve, char **resultp);
+#include "mono-compiler.h"
+
+double mono_strtod (const char *s00, char **se) MONO_INTERNAL;
 
 #endif