summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2017-06-25 17:00:26 +0200
committerNikita Popov <nikita.ppv@gmail.com>2017-06-25 17:00:26 +0200
commit205807f60ed3e76b318bbd398e51b764c7e2317d (patch)
tree6d4949d05378e616692244720be02650c48f7e99
parent6dd2eaf45c676eb6c133b5f926334e12ef73f664 (diff)
downloadphp-git-205807f60ed3e76b318bbd398e51b764c7e2317d.tar.gz
Move va_copy compatibility code into zend_portability.h
Previously this was defined in zend.c and php.h and also handled in another way in soap.c.
-rw-r--r--Zend/zend.c13
-rw-r--r--Zend/zend_portability.h12
-rw-r--r--ext/soap/soap.c21
-rw-r--r--main/php.h8
4 files changed, 14 insertions, 40 deletions
diff --git a/Zend/zend.c b/Zend/zend.c
index adcef0bec5..a6677099a5 100644
--- a/Zend/zend.c
+++ b/Zend/zend.c
@@ -1230,22 +1230,9 @@ static ZEND_COLD void zend_error_va_list(int type, const char *format, va_list a
break;
default:
/* Handle the error in user space */
-/* va_copy() is __va_copy() in old gcc versions.
- * According to the autoconf manual, using
- * memcpy(&dst, &src, sizeof(va_list))
- * gives maximum portability. */
-#ifndef va_copy
-# ifdef __va_copy
-# define va_copy(dest, src) __va_copy((dest), (src))
-# else
-# define va_copy(dest, src) memcpy(&(dest), &(src), sizeof(va_list))
-# endif
-#endif
va_copy(usr_copy, args);
ZVAL_STR(&params[1], zend_vstrpprintf(0, format, usr_copy));
-#ifdef va_copy
va_end(usr_copy);
-#endif
ZVAL_LONG(&params[0], type);
diff --git a/Zend/zend_portability.h b/Zend/zend_portability.h
index b2b956a82c..eefbd7b821 100644
--- a/Zend/zend_portability.h
+++ b/Zend/zend_portability.h
@@ -498,6 +498,18 @@ static zend_always_inline double _zend_get_nan(void) /* {{{ */
#define ZEND_VALID_SOCKET(sock) ((sock) >= 0)
#endif
+/* va_copy() is __va_copy() in old gcc versions.
+ * According to the autoconf manual, using
+ * memcpy(&dst, &src, sizeof(va_list))
+ * gives maximum portability. */
+#ifndef va_copy
+# ifdef __va_copy
+# define va_copy(dest, src) __va_copy((dest), (src))
+# else
+# define va_copy(dest, src) memcpy(&(dest), &(src), sizeof(va_list))
+# endif
+#endif
+
#endif /* ZEND_PORTABILITY_H */
/*
diff --git a/ext/soap/soap.c b/ext/soap/soap.c
index 68b61304b8..32cc648a28 100644
--- a/ext/soap/soap.c
+++ b/ext/soap/soap.c
@@ -167,7 +167,6 @@ ZEND_DECLARE_MODULE_GLOBALS(soap)
static void (*old_error_handler)(int, const char *, const uint32_t, const char*, va_list);
-#ifdef va_copy
#define call_old_error_handler(error_num, error_filename, error_lineno, format, args) \
{ \
va_list copy; \
@@ -175,12 +174,6 @@ static void (*old_error_handler)(int, const char *, const uint32_t, const char*,
old_error_handler(error_num, error_filename, error_lineno, format, copy); \
va_end(copy); \
}
-#else
-#define call_old_error_handler(error_num, error_filename, error_lineno, format, args) \
-{ \
- old_error_handler(error_num, error_filename, error_lineno, format, args); \
-}
-#endif
#define PHP_SOAP_SERVER_CLASSNAME "SoapServer"
#define PHP_SOAP_CLIENT_CLASSNAME "SoapClient"
@@ -2163,19 +2156,14 @@ static void soap_error_handler(int error_num, const char *error_filename, const
char* code = SOAP_GLOBAL(error_code);
char buffer[1024];
size_t buffer_len;
-#ifdef va_copy
va_list argcopy;
-#endif
zend_object **old_objects;
int old = PG(display_errors);
-#ifdef va_copy
va_copy(argcopy, args);
buffer_len = vslprintf(buffer, sizeof(buffer)-1, format, argcopy);
va_end(argcopy);
-#else
- buffer_len = vslprintf(buffer, sizeof(buffer)-1, format, args);
-#endif
+
buffer[sizeof(buffer)-1]=0;
if (buffer_len > sizeof(buffer) - 1 || buffer_len == (size_t)-1) {
buffer_len = sizeof(buffer) - 1;
@@ -2216,9 +2204,7 @@ static void soap_error_handler(int error_num, const char *error_filename, const
int old = PG(display_errors);
int fault = 0;
zval fault_obj;
-#ifdef va_copy
va_list argcopy;
-#endif
if (error_num == E_USER_ERROR ||
error_num == E_COMPILE_ERROR ||
@@ -2246,13 +2232,10 @@ static void soap_error_handler(int error_num, const char *error_filename, const
size_t buffer_len;
zval outbuflen;
-#ifdef va_copy
va_copy(argcopy, args);
buffer_len = vslprintf(buffer, sizeof(buffer)-1, format, argcopy);
va_end(argcopy);
-#else
- buffer_len = vslprintf(buffer, sizeof(buffer)-1, format, args);
-#endif
+
buffer[sizeof(buffer)-1]=0;
if (buffer_len > sizeof(buffer) - 1 || buffer_len == (size_t)-1) {
buffer_len = sizeof(buffer) - 1;
diff --git a/main/php.h b/main/php.h
index 116485a811..53926d2321 100644
--- a/main/php.h
+++ b/main/php.h
@@ -240,14 +240,6 @@ typedef unsigned int socklen_t;
# endif
#endif
-#ifndef va_copy
-# ifdef __va_copy
-# define va_copy(ap1, ap2) __va_copy((ap1), (ap2))
-# else
-# define va_copy(ap1, ap2) memcpy((&ap1), (&ap2), sizeof(va_list))
-# endif
-#endif
-
#include "php_stdint.h"
#include "zend_hash.h"