sniper Tue Dec 9 18:59:34 2003 EDT
Modified files:
/ZendEngine2 zend_operators.c zend_operators.h
/php-src/ext/bcmath bcmath.c config.m4 php_bcmath.h
/php-src/ext/bcmath/libbcmath/src bcmath.h init.c
/php-src/main config.nw.h config.w32.h internal_functions_nw.c
internal_functions_win32.c
Log:
- Brought ext/bcmath to the new millennium
# consistency..
Index: ZendEngine2/zend_operators.c
diff -u ZendEngine2/zend_operators.c:1.170 ZendEngine2/zend_operators.c:1.171
--- ZendEngine2/zend_operators.c:1.170 Tue Dec 2 16:09:24 2003
+++ ZendEngine2/zend_operators.c Tue Dec 9 18:59:31 2003
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_operators.c,v 1.170 2003/12/02 21:09:24 andi Exp $ */
+/* $Id: zend_operators.c,v 1.171 2003/12/09 23:59:31 sniper Exp $ */
#include <ctype.h>
@@ -29,7 +29,7 @@
#include "zend_fast_cache.h"
#include "zend_API.h"
-#if 0&&WITH_BCMATH
+#if 0&&HAVE_BCMATH
#include "ext/bcmath/number.h"
#endif
@@ -117,7 +117,7 @@
case IS_DOUBLE:
case IS_LONG:
break;
-#if 0 && WITH_BCMATH
+#if 0 && HAVE_BCMATH
case FLAG_IS_BC:
op->type = IS_DOUBLE; /* may have lost
significant digits */
break;
@@ -1752,7 +1752,7 @@
if ((ret1=is_numeric_string(s1->value.str.val, s1->value.str.len, &lval1,
&dval1, 0)) &&
(ret2=is_numeric_string(s2->value.str.val, s2->value.str.len, &lval2,
&dval2, 0))) {
-#if 0&&WITH_BCMATH
+#if 0&&HAVE_BCMATH
if ((ret1==FLAG_IS_BC) || (ret2==FLAG_IS_BC)) {
bc_num first, second;
Index: ZendEngine2/zend_operators.h
diff -u ZendEngine2/zend_operators.h:1.82 ZendEngine2/zend_operators.h:1.83
--- ZendEngine2/zend_operators.h:1.82 Mon Nov 24 15:57:54 2003
+++ ZendEngine2/zend_operators.h Tue Dec 9 18:59:31 2003
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_operators.h,v 1.82 2003/11/24 20:57:54 helly Exp $ */
+/* $Id: zend_operators.h,v 1.83 2003/12/09 23:59:31 sniper Exp $ */
#ifndef ZEND_OPERATORS_H
#define ZEND_OPERATORS_H
@@ -30,7 +30,7 @@
#endif
-#if 0&&WITH_BCMATH
+#if 0&&HAVE_BCMATH
#include "ext/bcmath/libbcmath/src/bcmath.h"
#endif
@@ -106,7 +106,7 @@
if (dval) {
*dval = local_dval;
}
-#if 0&&WITH_BCMATH
+#if 0&&HAVE_BCMATH
if (length>16) {
register char *ptr=str, *end=str+length;
Index: php-src/ext/bcmath/bcmath.c
diff -u php-src/ext/bcmath/bcmath.c:1.56 php-src/ext/bcmath/bcmath.c:1.57
--- php-src/ext/bcmath/bcmath.c:1.56 Thu Jun 12 08:21:33 2003
+++ php-src/ext/bcmath/bcmath.c Tue Dec 9 18:59:32 2003
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: bcmath.c,v 1.56 2003/06/12 12:21:33 andrey Exp $ */
+/* $Id: bcmath.c,v 1.57 2003/12/09 23:59:32 sniper Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -24,8 +24,9 @@
#include "php.h"
-#if WITH_BCMATH
+#if HAVE_BCMATH
+#include "php_ini.h"
#include "ext/standard/info.h"
#include "php_bcmath.h"
#include "libbcmath/src/bcmath.h"
@@ -50,14 +51,10 @@
STANDARD_MODULE_HEADER,
"bcmath",
bcmath_functions,
-#if ZTS
- PHP_MODULE_STARTUP_N(bcmath),
-#else
+ PHP_MINIT(bcmath),
+ PHP_MSHUTDOWN(bcmath),
NULL,
-#endif
NULL,
- PHP_RINIT(bcmath),
- PHP_RSHUTDOWN(bcmath),
PHP_MINFO(bcmath),
NO_VERSION_YET,
STANDARD_MODULE_PROPERTIES
@@ -67,53 +64,55 @@
ZEND_GET_MODULE(bcmath)
#endif
-#ifndef THREAD_SAFE
-static long bc_precision;
-#endif
+/* {{{ PHP_INI */
+PHP_INI_BEGIN()
+ STD_PHP_INI_ENTRY("bcmath.scale", "0", PHP_INI_ALL, OnUpdateLong,
bc_precision, zend_bcmath_globals, bcmath_globals)
+PHP_INI_END()
+/* }}} */
-#if ZTS
-PHP_MODULE_STARTUP_D(bcmath)
+/* {{{ php_bcmath_init_globals
+ */
+static void php_bcmath_init_globals(zend_bcmath_globals *bcmath_globals)
{
- zend_bcmath_globals *bcmath_globals;
-
- ts_allocate_id(&bcmath_globals_id, sizeof(zend_bcmath_globals), NULL, NULL);
- bcmath_globals = ts_resource(bcmath_globals_id);
- return SUCCESS;
+ bcmath_globals->bc_precision = 0;
}
-#endif
+/* }}} */
-PHP_RSHUTDOWN_FUNCTION(bcmath)
+/* {{{ PHP_MINIT_FUNCTION
+ */
+PHP_MINIT_FUNCTION(bcmath)
{
- bc_free_num(&BCG(_zero_));
- bc_free_num(&BCG(_one_));
- bc_free_num(&BCG(_two_));
+ ZEND_INIT_MODULE_GLOBALS(bcmath, php_bcmath_init_globals, NULL);
+
+ REGISTER_INI_ENTRIES();
+
+ bc_init_numbers(TSRMLS_C);
return SUCCESS;
}
+/* }}} */
-
-PHP_RINIT_FUNCTION(bcmath)
+/* {{{ PHP_MSHUTDOWN_FUNCTION
+ */
+PHP_MSHUTDOWN_FUNCTION(bcmath)
{
- if (cfg_get_long("bcmath.scale", &bc_precision) == FAILURE) {
- bc_precision = 0;
- }
+ _bc_free_num_ex(&BCG(_zero_), 1);
+ _bc_free_num_ex(&BCG(_one_), 1);
+ _bc_free_num_ex(&BCG(_two_), 1);
- if (bc_precision < 0) {
- bc_precision = 0;
- }
-
- bc_init_numbers(TSRMLS_C);
-
return SUCCESS;
}
-
-
+/* }}} */
+
+/* {{{ PHP_MINFO_FUNCTION
+ */
PHP_MINFO_FUNCTION(bcmath)
{
php_info_print_table_start();
php_info_print_table_row(2, "BCMath support", "enabled");
php_info_print_table_end();
}
+/* }}} */
/* {{{ php_str2num
Convert to bc_num detecting scale */
@@ -136,7 +135,7 @@
{
zval **left, **right, **scale_param;
bc_num first, second, result;
- int scale = bc_precision;
+ int scale = BCG(bc_precision);
switch (ZEND_NUM_ARGS()) {
case 2:
@@ -182,7 +181,7 @@
{
zval **left, **right, **scale_param;
bc_num first, second, result;
- int scale = bc_precision;
+ int scale = BCG(bc_precision);
switch (ZEND_NUM_ARGS()) {
case 2:
@@ -228,7 +227,7 @@
{
zval **left, **right, **scale_param;
bc_num first, second, result;
- int scale = bc_precision;
+ int scale = BCG(bc_precision);
switch (ZEND_NUM_ARGS()) {
case 2:
@@ -274,7 +273,7 @@
{
zval **left, **right, **scale_param;
bc_num first, second, result;
- int scale = bc_precision;
+ int scale = BCG(bc_precision);
switch (ZEND_NUM_ARGS()) {
case 2:
@@ -368,7 +367,7 @@
char *left, *right, *modulous;
int left_len, right_len, modulous_len;
bc_num first, second, mod, result;
- int scale = bc_precision;
+ int scale = BCG(bc_precision);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss|l", &left,
&left_len, &right, &right_len, &modulous, &modulous_len, &scale) == FAILURE) {
WRONG_PARAM_COUNT;
@@ -402,7 +401,7 @@
{
zval **left, **right, **scale_param;
bc_num first, second, result;
- int scale = bc_precision;
+ int scale = BCG(bc_precision);
switch (ZEND_NUM_ARGS()) {
case 2:
@@ -448,7 +447,7 @@
{
zval **left, **scale_param;
bc_num result;
- int scale = bc_precision;
+ int scale = BCG(bc_precision);
switch (ZEND_NUM_ARGS()) {
case 1:
@@ -491,7 +490,7 @@
{
zval **left, **right, **scale_param;
bc_num first, second;
- int scale = bc_precision;
+ int scale = BCG(bc_precision);
switch (ZEND_NUM_ARGS()) {
case 2:
@@ -538,7 +537,7 @@
}
convert_to_long_ex(new_scale);
- bc_precision = (Z_LVAL_PP(new_scale) < 0) ? 0 : Z_LVAL_PP(new_scale);
+ BCG(bc_precision) = (Z_LVAL_PP(new_scale) < 0) ? 0 : Z_LVAL_PP(new_scale);
RETURN_TRUE;
}
Index: php-src/ext/bcmath/config.m4
diff -u php-src/ext/bcmath/config.m4:1.15 php-src/ext/bcmath/config.m4:1.16
--- php-src/ext/bcmath/config.m4:1.15 Wed Nov 20 16:16:39 2002
+++ php-src/ext/bcmath/config.m4 Tue Dec 9 18:59:32 2003
@@ -1,12 +1,11 @@
dnl
-dnl $Id: config.m4,v 1.15 2002/11/20 21:16:39 andi Exp $
+dnl $Id: config.m4,v 1.16 2003/12/09 23:59:32 sniper Exp $
dnl
PHP_ARG_ENABLE(bcmath, whether to enable bc style precision math functions,
[ --enable-bcmath Enable bc style precision math functions.])
if test "$PHP_BCMATH" != "no"; then
- AC_DEFINE(WITH_BCMATH, 1, [Whether you have bcmath])
PHP_NEW_EXTENSION(bcmath, bcmath.c \
libbcmath/src/add.c libbcmath/src/div.c libbcmath/src/init.c libbcmath/src/neg.c
libbcmath/src/outofmem.c libbcmath/src/raisemod.c libbcmath/src/rt.c
libbcmath/src/sub.c \
libbcmath/src/compare.c libbcmath/src/divmod.c libbcmath/src/int2num.c
libbcmath/src/num2long.c libbcmath/src/output.c libbcmath/src/recmul.c \
@@ -14,4 +13,5 @@
libbcmath/src/rmzero.c libbcmath/src/str2num.c,
$ext_shared,,[EMAIL PROTECTED]@/libbcmath/src)
PHP_ADD_BUILD_DIR($ext_builddir/libbcmath/src)
+ AC_DEFINE(HAVE_BCMATH, 1, [Whether you have bcmath])
fi
Index: php-src/ext/bcmath/php_bcmath.h
diff -u php-src/ext/bcmath/php_bcmath.h:1.16 php-src/ext/bcmath/php_bcmath.h:1.17
--- php-src/ext/bcmath/php_bcmath.h:1.16 Tue Jun 10 16:03:25 2003
+++ php-src/ext/bcmath/php_bcmath.h Tue Dec 9 18:59:32 2003
@@ -16,39 +16,20 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_bcmath.h,v 1.16 2003/06/10 20:03:25 imajes Exp $ */
+/* $Id: php_bcmath.h,v 1.17 2003/12/09 23:59:32 sniper Exp $ */
#ifndef PHP_BCMATH_H
#define PHP_BCMATH_H
-#if WITH_BCMATH
+#if HAVE_BCMATH
#include "libbcmath/src/bcmath.h"
-ZEND_BEGIN_MODULE_GLOBALS(bcmath)
- bc_num _zero_;
- bc_num _one_;
- bc_num _two_;
-ZEND_END_MODULE_GLOBALS(bcmath)
-
-#if ZTS
-# define BCG(v) TSRMG(bcmath_globals_id, zend_bcmath_globals *, v)
-extern int bcmath_globals_id;
-#else
-# define BCG(v) (bcmath_globals.v)
-extern zend_bcmath_globals bcmath_globals;
-#endif
-
-#define BC
-
extern zend_module_entry bcmath_module_entry;
#define phpext_bcmath_ptr &bcmath_module_entry
-#if ZTS
PHP_MINIT_FUNCTION(bcmath);
-#endif
-PHP_RINIT_FUNCTION(bcmath);
-PHP_RSHUTDOWN_FUNCTION(bcmath);
+PHP_MSHUTDOWN_FUNCTION(bcmath);
PHP_MINFO_FUNCTION(bcmath);
PHP_FUNCTION(bcadd);
@@ -62,6 +43,21 @@
PHP_FUNCTION(bcscale);
PHP_FUNCTION(bcpowmod);
+ZEND_BEGIN_MODULE_GLOBALS(bcmath)
+ bc_num _zero_;
+ bc_num _one_;
+ bc_num _two_;
+ long bc_precision;
+ZEND_END_MODULE_GLOBALS(bcmath)
+
+#if ZTS
+#define BCG(v) TSRMG(bcmath_globals_id, zend_bcmath_globals *, v)
+#else
+#define BCG(v) (bcmath_globals.v)
+#endif
+
+ZEND_EXTERN_MODULE_GLOBALS(bcmath)
+
#else
#define phpext_bcmath_ptr NULL
Index: php-src/ext/bcmath/libbcmath/src/bcmath.h
diff -u php-src/ext/bcmath/libbcmath/src/bcmath.h:1.8
php-src/ext/bcmath/libbcmath/src/bcmath.h:1.9
--- php-src/ext/bcmath/libbcmath/src/bcmath.h:1.8 Mon Dec 1 09:01:38 2003
+++ php-src/ext/bcmath/libbcmath/src/bcmath.h Tue Dec 9 18:59:33 2003
@@ -101,9 +101,9 @@
_PROTOTYPE(void bc_init_numbers, (TSRMLS_D));
-_PROTOTYPE(bc_num bc_new_num, (int length, int scale));
+_PROTOTYPE(bc_num _bc_new_num_ex, (int length, int scale, int persistent));
-_PROTOTYPE(void bc_free_num, (bc_num *num));
+_PROTOTYPE(void _bc_free_num_ex, (bc_num *num, int persistent));
_PROTOTYPE(bc_num bc_copy_num, (bc_num num));
@@ -155,4 +155,8 @@
_PROTOTYPE(void bc_rt_warn, (char *mesg ,...));
_PROTOTYPE(void bc_rt_error, (char *mesg ,...));
_PROTOTYPE(void bc_out_of_memory, (void));
+
+#define bc_new_num(length, scale) _bc_new_num_ex((length), (scale), 0)
+#define bc_free_num(num) _bc_free_num_ex((num), 0)
+
#endif
Index: php-src/ext/bcmath/libbcmath/src/init.c
diff -u php-src/ext/bcmath/libbcmath/src/init.c:1.5
php-src/ext/bcmath/libbcmath/src/init.c:1.6
--- php-src/ext/bcmath/libbcmath/src/init.c:1.5 Fri Nov 29 12:59:30 2002
+++ php-src/ext/bcmath/libbcmath/src/init.c Tue Dec 9 18:59:33 2003
@@ -45,19 +45,19 @@
/* new_num allocates a number and sets fields to known values. */
bc_num
-bc_new_num (length, scale)
- int length, scale;
+_bc_new_num_ex (length, scale, persistent)
+ int length, scale, persistent;
{
bc_num temp;
- /* PHP Change: malloc() -> emalloc(), removed free_list code */
- temp = (bc_num) emalloc (sizeof(bc_struct)+length+scale);
+ /* PHP Change: malloc() -> pemalloc(), removed free_list code */
+ temp = (bc_num) pemalloc (sizeof(bc_struct)+length+scale, persistent);
#if 0
if (_bc_Free_list != NULL) {
temp = _bc_Free_list;
_bc_Free_list = temp->n_next;
} else {
- temp = (bc_num) emalloc (sizeof(bc_struct));
+ temp = (bc_num) pemalloc (sizeof(bc_struct), persistent);
if (temp == NULL) bc_out_of_memory ();
}
#endif
@@ -65,8 +65,8 @@
temp->n_len = length;
temp->n_scale = scale;
temp->n_refs = 1;
- /* PHP Change: malloc() -> emalloc() */
- temp->n_ptr = (char *) emalloc (length+scale);
+ /* PHP Change: malloc() -> pemalloc() */
+ temp->n_ptr = (char *) pemalloc (length+scale, persistent);
if (temp->n_ptr == NULL) bc_out_of_memory();
temp->n_value = temp->n_ptr;
memset (temp->n_ptr, 0, length+scale);
@@ -78,16 +78,17 @@
frees the storage if reference count is zero. */
void
-bc_free_num (num)
+_bc_free_num_ex (num, persistent)
bc_num *num;
+ int persistent;
{
if (*num == NULL) return;
(*num)->n_refs--;
if ((*num)->n_refs == 0) {
if ((*num)->n_ptr)
- /* PHP Change: free() -> efree(), removed free_list code */
- efree ((*num)->n_ptr);
- efree(*num);
+ /* PHP Change: free() -> pefree(), removed free_list code */
+ pefree ((*num)->n_ptr, persistent);
+ pefree(*num, persistent);
#if 0
(*num)->n_next = _bc_Free_list;
_bc_Free_list = *num;
@@ -102,10 +103,10 @@
void
bc_init_numbers (TSRMLS_D)
{
- BCG(_zero_) = bc_new_num (1,0);
- BCG(_one_) = bc_new_num (1,0);
+ BCG(_zero_) = _bc_new_num_ex (1,0,1);
+ BCG(_one_) = _bc_new_num_ex (1,0,1);
BCG(_one_)->n_value[0] = 1;
- BCG(_two_) = bc_new_num (1,0);
+ BCG(_two_) = _bc_new_num_ex (1,0,1);
BCG(_two_)->n_value[0] = 2;
}
Index: php-src/main/config.nw.h
diff -u php-src/main/config.nw.h:1.4 php-src/main/config.nw.h:1.5
--- php-src/main/config.nw.h:1.4 Tue Jun 10 16:03:41 2003
+++ php-src/main/config.nw.h Tue Dec 9 18:59:33 2003
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: config.nw.h,v 1.4 2003/06/10 20:03:41 imajes Exp $ */
+/* $Id: config.nw.h,v 1.5 2003/12/09 23:59:33 sniper Exp $ */
/* config.nw.h. Configure file for NetWare platform */
@@ -33,7 +33,7 @@
#define HAVE_GETPROTOBYNUMBER 1
/* set to enable bcmath */
-#define WITH_BCMATH 1
+#define HAVE_BCMATH 1
/* set to enable mysql */
#define HAVE_MYSQL 1
Index: php-src/main/config.w32.h
diff -u php-src/main/config.w32.h:1.82 php-src/main/config.w32.h:1.83
--- php-src/main/config.w32.h:1.82 Wed Dec 3 20:40:59 2003
+++ php-src/main/config.w32.h Tue Dec 9 18:59:33 2003
@@ -2,7 +2,7 @@
Build Configuration for Win32.
This has only been tested with MS VisualC++ 6 (and later).
- $Id: config.w32.h,v 1.82 2003/12/04 01:40:59 wez Exp $
+ $Id: config.w32.h,v 1.83 2003/12/09 23:59:33 sniper Exp $
*/
/* Default PHP / PEAR directories */
@@ -20,7 +20,7 @@
#define PHP_SYSCONFDIR "c:\\php5"
/* Enable / Disable BCMATH extension (default: enabled) */
-#define WITH_BCMATH 1
+#define HAVE_BCMATH 1
/* Enable / Disable crypt() function (default: enabled) */
#define HAVE_CRYPT 1
Index: php-src/main/internal_functions_nw.c
diff -u php-src/main/internal_functions_nw.c:1.4
php-src/main/internal_functions_nw.c:1.5
--- php-src/main/internal_functions_nw.c:1.4 Tue Jun 10 16:03:41 2003
+++ php-src/main/internal_functions_nw.c Tue Dec 9 18:59:33 2003
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: internal_functions_nw.c,v 1.4 2003/06/10 20:03:41 imajes Exp $ */
+/* $Id: internal_functions_nw.c,v 1.5 2003/12/09 23:59:33 sniper Exp $ */
/* {{{ includes
*/
@@ -65,7 +65,7 @@
*/
zend_module_entry *php_builtin_extensions[] = {
phpext_standard_ptr,
-#if WITH_BCMATH
+#if HAVE_BCMATH
phpext_bcmath_ptr,
#endif
phpext_calendar_ptr,
Index: php-src/main/internal_functions_win32.c
diff -u php-src/main/internal_functions_win32.c:1.82
php-src/main/internal_functions_win32.c:1.83
--- php-src/main/internal_functions_win32.c:1.82 Sun Oct 19 17:48:45 2003
+++ php-src/main/internal_functions_win32.c Tue Dec 9 18:59:33 2003
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: internal_functions_win32.c,v 1.82 2003/10/19 21:48:45 shane Exp $ */
+/* $Id: internal_functions_win32.c,v 1.83 2003/12/09 23:59:33 sniper Exp $ */
/* {{{ includes
*/
@@ -49,7 +49,7 @@
#include "ext/standard/php_lcg.h"
#include "ext/standard/php_array.h"
#include "ext/standard/php_assert.h"
-#if WITH_BCMATH
+#if HAVE_BCMATH
#include "ext/bcmath/php_bcmath.h"
#endif
#if HAVE_CALENDAR
@@ -105,7 +105,7 @@
*/
zend_module_entry *php_builtin_extensions[] = {
phpext_standard_ptr
-#if WITH_BCMATH
+#if HAVE_BCMATH
,phpext_bcmath_ptr
#endif
#if HAVE_CALENDAR
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php