summaryrefslogtreecommitdiff
path: root/ext/bcmath/libbcmath/src
diff options
context:
space:
mode:
authorAndi Gutmans <andi@php.net>2002-11-20 19:48:12 +0000
committerAndi Gutmans <andi@php.net>2002-11-20 19:48:12 +0000
commite6b7ab9db86710ca0c90d320bd43dcd4c2c06ed4 (patch)
tree93d192743b05e18f3402a8e131b0b4009b180f9d /ext/bcmath/libbcmath/src
parent33d0e4e1fbacd3acce5fab6bd3cc4c120223c46f (diff)
downloadphp-git-e6b7ab9db86710ca0c90d320bd43dcd4c2c06ed4.tar.gz
- Intermediate commit which works on making bcmath thread-safe.
Diffstat (limited to 'ext/bcmath/libbcmath/src')
-rw-r--r--ext/bcmath/libbcmath/src/bcmath.h8
-rw-r--r--ext/bcmath/libbcmath/src/init.c18
-rw-r--r--ext/bcmath/libbcmath/src/output.c4
-rw-r--r--ext/bcmath/libbcmath/src/raise.c4
-rw-r--r--ext/bcmath/libbcmath/src/raisemod.c6
-rw-r--r--ext/bcmath/libbcmath/src/recmul.c10
-rw-r--r--ext/bcmath/libbcmath/src/sqrt.c12
-rw-r--r--ext/bcmath/libbcmath/src/str2num.c2
-rw-r--r--ext/bcmath/libbcmath/src/zero.c2
9 files changed, 33 insertions, 33 deletions
diff --git a/ext/bcmath/libbcmath/src/bcmath.h b/ext/bcmath/libbcmath/src/bcmath.h
index a6c7627b6b..9fe981466c 100644
--- a/ext/bcmath/libbcmath/src/bcmath.h
+++ b/ext/bcmath/libbcmath/src/bcmath.h
@@ -80,11 +80,11 @@ typedef struct bc_struct
#define LONG_MAX 0x7ffffff
#endif
-
+#define BCG(s) s##a
/* Global numbers. */
-extern bc_num _zero_;
-extern bc_num _one_;
-extern bc_num _two_;
+extern bc_num BCG(_zero_);
+extern bc_num BCG(_one_);
+extern bc_num BCG(_two_);
/* Function Prototypes */
diff --git a/ext/bcmath/libbcmath/src/init.c b/ext/bcmath/libbcmath/src/init.c
index 4ff00b1102..a1546214ec 100644
--- a/ext/bcmath/libbcmath/src/init.c
+++ b/ext/bcmath/libbcmath/src/init.c
@@ -39,9 +39,9 @@
#include "private.h"
/* Storage used for special numbers. */
-bc_num _zero_;
-bc_num _one_;
-bc_num _two_;
+bc_num BCG(_zero_);
+bc_num BCG(_one_);
+bc_num BCG(_two_);
bc_num _bc_Free_list = NULL;
@@ -105,11 +105,11 @@ bc_free_num (num)
void
bc_init_numbers ()
{
- _zero_ = bc_new_num (1,0);
- _one_ = bc_new_num (1,0);
- _one_->n_value[0] = 1;
- _two_ = bc_new_num (1,0);
- _two_->n_value[0] = 2;
+ BCG(_zero_) = bc_new_num (1,0);
+ BCG(_one_) = bc_new_num (1,0);
+ BCG(_one_)->n_value[0] = 1;
+ BCG(_two_) = bc_new_num (1,0);
+ BCG(_two_)->n_value[0] = 2;
}
@@ -130,6 +130,6 @@ void
bc_init_num (num)
bc_num *num;
{
- *num = bc_copy_num (_zero_);
+ *num = bc_copy_num (BCG(_zero_));
}
diff --git a/ext/bcmath/libbcmath/src/output.c b/ext/bcmath/libbcmath/src/output.c
index e41479d2d3..81bcc9afa0 100644
--- a/ext/bcmath/libbcmath/src/output.c
+++ b/ext/bcmath/libbcmath/src/output.c
@@ -138,7 +138,7 @@ bc_out_num (num, o_base, out_char, leading_zero)
/* The number is some other base. */
digits = NULL;
bc_init_num (&int_part);
- bc_divide (num, _one_, &int_part, 0);
+ bc_divide (num, BCG(_one_), &int_part, 0);
bc_init_num (&frac_part);
bc_init_num (&cur_dig);
bc_init_num (&base);
@@ -185,7 +185,7 @@ bc_out_num (num, o_base, out_char, leading_zero)
{
(*out_char) ('.');
pre_space = 0;
- t_num = bc_copy_num (_one_);
+ t_num = bc_copy_num (BCG(_one_));
while (t_num->n_len <= num->n_scale) {
bc_multiply (frac_part, base, &frac_part, num->n_scale);
fdigit = bc_num2long (frac_part);
diff --git a/ext/bcmath/libbcmath/src/raise.c b/ext/bcmath/libbcmath/src/raise.c
index 5f2f03c208..b259e22882 100644
--- a/ext/bcmath/libbcmath/src/raise.c
+++ b/ext/bcmath/libbcmath/src/raise.c
@@ -66,7 +66,7 @@ bc_raise (num1, num2, result, scale)
if (exponent == 0)
{
bc_free_num (result);
- *result = bc_copy_num (_one_);
+ *result = bc_copy_num (BCG(_one_));
return;
}
@@ -111,7 +111,7 @@ bc_raise (num1, num2, result, scale)
/* Assign the value. */
if (neg)
{
- bc_divide (_one_, temp, result, rscale);
+ bc_divide (BCG(_one_), temp, result, rscale);
bc_free_num (&temp);
}
else
diff --git a/ext/bcmath/libbcmath/src/raisemod.c b/ext/bcmath/libbcmath/src/raisemod.c
index cc9dd35a57..1b90a9e4ef 100644
--- a/ext/bcmath/libbcmath/src/raisemod.c
+++ b/ext/bcmath/libbcmath/src/raisemod.c
@@ -57,7 +57,7 @@ bc_raisemod (base, expo, mod, result, scale)
/* Set initial values. */
power = bc_copy_num (base);
exponent = bc_copy_num (expo);
- temp = bc_copy_num (_one_);
+ temp = bc_copy_num (BCG(_one_));
bc_init_num(&parity);
/* Check the base for scale digits. */
@@ -68,7 +68,7 @@ bc_raisemod (base, expo, mod, result, scale)
if (exponent->n_scale != 0)
{
bc_rt_warn ("non-zero scale in exponent");
- bc_divide (exponent, _one_, &exponent, 0); /*truncate */
+ bc_divide (exponent, BCG(_one_), &exponent, 0); /*truncate */
}
/* Check the modulus for scale digits. */
@@ -79,7 +79,7 @@ bc_raisemod (base, expo, mod, result, scale)
rscale = MAX(scale, base->n_scale);
while ( !bc_is_zero(exponent) )
{
- (void) bc_divmod (exponent, _two_, &exponent, &parity, 0);
+ (void) bc_divmod (exponent, BCG(_two_), &exponent, &parity, 0);
if ( !bc_is_zero(parity) )
{
bc_multiply (temp, power, &temp, rscale);
diff --git a/ext/bcmath/libbcmath/src/recmul.c b/ext/bcmath/libbcmath/src/recmul.c
index 73f67af574..ec3ff779e5 100644
--- a/ext/bcmath/libbcmath/src/recmul.c
+++ b/ext/bcmath/libbcmath/src/recmul.c
@@ -197,14 +197,14 @@ _bc_rec_mul (bc_num u, int ulen, bc_num v, int vlen, bc_num *prod,
/* Split u and v. */
if (ulen < n) {
- u1 = bc_copy_num (_zero_);
+ u1 = bc_copy_num (BCG(_zero_));
u0 = new_sub_num (ulen,0, u->n_value);
} else {
u1 = new_sub_num (ulen-n, 0, u->n_value);
u0 = new_sub_num (n, 0, u->n_value+ulen-n);
}
if (vlen < n) {
- v1 = bc_copy_num (_zero_);
+ v1 = bc_copy_num (BCG(_zero_));
v0 = new_sub_num (vlen,0, v->n_value);
} else {
v1 = new_sub_num (vlen-n, 0, v->n_value);
@@ -231,17 +231,17 @@ _bc_rec_mul (bc_num u, int ulen, bc_num v, int vlen, bc_num *prod,
/* Do recursive multiplies and shifted adds. */
if (m1zero)
- m1 = bc_copy_num (_zero_);
+ m1 = bc_copy_num (BCG(_zero_));
else
_bc_rec_mul (u1, u1->n_len, v1, v1->n_len, &m1, 0);
if (bc_is_zero(d1) || bc_is_zero(d2))
- m2 = bc_copy_num (_zero_);
+ m2 = bc_copy_num (BCG(_zero_));
else
_bc_rec_mul (d1, d1len, d2, d2len, &m2, 0);
if (bc_is_zero(u0) || bc_is_zero(v0))
- m3 = bc_copy_num (_zero_);
+ m3 = bc_copy_num (BCG(_zero_));
else
_bc_rec_mul (u0, u0->n_len, v0, v0->n_len, &m3, 0);
diff --git a/ext/bcmath/libbcmath/src/sqrt.c b/ext/bcmath/libbcmath/src/sqrt.c
index 34b95b8898..d4f430906d 100644
--- a/ext/bcmath/libbcmath/src/sqrt.c
+++ b/ext/bcmath/libbcmath/src/sqrt.c
@@ -51,7 +51,7 @@ bc_sqrt (num, scale)
bc_num guess, guess1, point5, diff;
/* Initial checks. */
- cmp_res = bc_compare (*num, _zero_);
+ cmp_res = bc_compare (*num, BCG(_zero_));
if (cmp_res < 0)
return 0; /* error */
else
@@ -59,15 +59,15 @@ bc_sqrt (num, scale)
if (cmp_res == 0)
{
bc_free_num (num);
- *num = bc_copy_num (_zero_);
+ *num = bc_copy_num (BCG(_zero_));
return 1;
}
}
- cmp_res = bc_compare (*num, _one_);
+ cmp_res = bc_compare (*num, BCG(_one_));
if (cmp_res == 0)
{
bc_free_num (num);
- *num = bc_copy_num (_one_);
+ *num = bc_copy_num (BCG(_one_));
return 1;
}
@@ -84,7 +84,7 @@ bc_sqrt (num, scale)
if (cmp_res < 0)
{
/* The number is between 0 and 1. Guess should start at 1. */
- guess = bc_copy_num (_one_);
+ guess = bc_copy_num (BCG(_one_));
cscale = (*num)->n_scale;
}
else
@@ -121,7 +121,7 @@ bc_sqrt (num, scale)
/* Assign the number and clean up. */
bc_free_num (num);
- bc_divide (guess,_one_,num,rscale);
+ bc_divide (guess,BCG(_one_),num,rscale);
bc_free_num (&guess);
bc_free_num (&guess1);
bc_free_num (&point5);
diff --git a/ext/bcmath/libbcmath/src/str2num.c b/ext/bcmath/libbcmath/src/str2num.c
index 210a7d89ea..25583d187c 100644
--- a/ext/bcmath/libbcmath/src/str2num.c
+++ b/ext/bcmath/libbcmath/src/str2num.c
@@ -65,7 +65,7 @@ bc_str2num (num, str, scale)
while (isdigit((int)*ptr)) ptr++, strscale++; /* digits */
if ((*ptr != '\0') || (digits+strscale == 0))
{
- *num = bc_copy_num (_zero_);
+ *num = bc_copy_num (BCG(_zero_));
return;
}
diff --git a/ext/bcmath/libbcmath/src/zero.c b/ext/bcmath/libbcmath/src/zero.c
index dce77ba4aa..e21bb29252 100644
--- a/ext/bcmath/libbcmath/src/zero.c
+++ b/ext/bcmath/libbcmath/src/zero.c
@@ -48,7 +48,7 @@ bc_is_zero (num)
char *nptr;
/* Quick check. */
- if (num == _zero_) return TRUE;
+ if (num == BCG(_zero_)) return TRUE;
/* Initialize */
count = num->n_len + num->n_scale;