OnUpdateLong(), etc. (64bit issues)

[email protected] (Jani Taskinen)
Newsgroups php.dev
Message-ID <[email protected]>
    Attached proposed patch to solve this, just the Zend/ part.
    (patch is for PHP_4_3 branch)
    
    --Jani
patch (text/plain, 2 KB)
Index: zend_ini.c
===================================================================
RCS file: /repository/Zend/zend_ini.c,v
retrieving revision 1.23.2.1
diff -u -r1.23.2.1 zend_ini.c
--- zend_ini.c	31 Dec 2002 16:23:03 -0000	1.23.2.1
+++ zend_ini.c	4 Mar 2003 21:40:26 -0000
@@ -428,6 +428,7 @@
 }
 
 
+/* This should be removed in PHP 5? */
 ZEND_API ZEND_INI_MH(OnUpdateInt)
 {
 	long *p;
@@ -445,6 +446,44 @@
 	return SUCCESS;
 }
 
+/*
+ * Note: on 64 bit platforms, sizeof(long) != sizeof(int) and
+ * long* and int* cannot be used interchangably without disaster!
+ * OnUpdateInteger or OnUpdateLong must match the resource type!
+ */
+ZEND_API ZEND_INI_MH(OnUpdateInteger)
+{
+	int *p;
+#ifndef ZTS
+	char *base = (char *) mh_arg2;
+#else
+	char *base;
+
+	base = (char *) ts_resource(*((int *) mh_arg2));
+#endif
+	
+	p = (int *) (base+(size_t) mh_arg1);
+
+	*p = zend_atoi(new_value, new_value_length);
+	return SUCCESS;
+}
+
+ZEND_API ZEND_INI_MH(OnUpdateLong)
+{
+	long *p;
+#ifndef ZTS
+	char *base = (char *) mh_arg2;
+#else
+	char *base;
+
+	base = (char *) ts_resource(*((int *) mh_arg2));
+#endif
+
+	p = (long *) (base+(size_t) mh_arg1);
+
+	*p = zend_atoi(new_value, new_value_length);
+	return SUCCESS;
+}
 
 ZEND_API ZEND_INI_MH(OnUpdateReal)
 {
Index: zend_ini.h
===================================================================
RCS file: /repository/Zend/zend_ini.h,v
retrieving revision 1.21.2.1
diff -u -r1.21.2.1 zend_ini.h
--- zend_ini.h	31 Dec 2002 16:23:03 -0000	1.21.2.1
+++ zend_ini.h	4 Mar 2003 21:40:27 -0000
@@ -170,7 +170,9 @@
 
 /* Standard message handlers */
 ZEND_API ZEND_INI_MH(OnUpdateBool);
-ZEND_API ZEND_INI_MH(OnUpdateInt);
+ZEND_API ZEND_INI_MH(OnUpdateInt);      /* Remove in PHP 5? */
+ZEND_API ZEND_INI_MH(OnUpdateInteger);
+ZEND_API ZEND_INI_MH(OnUpdateLong);
 ZEND_API ZEND_INI_MH(OnUpdateReal);
 ZEND_API ZEND_INI_MH(OnUpdateString);
 ZEND_API ZEND_INI_MH(OnUpdateStringUnempty);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.