Skip to content

Commit 205807f

Browse files
committed
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.
1 parent 6dd2eaf commit 205807f

File tree

4 files changed

+14
-40
lines changed

4 files changed

+14
-40
lines changed

Zend/zend.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,22 +1230,9 @@ static ZEND_COLD void zend_error_va_list(int type, const char *format, va_list a
12301230
break;
12311231
default:
12321232
/* Handle the error in user space */
1233-
/* va_copy() is __va_copy() in old gcc versions.
1234-
* According to the autoconf manual, using
1235-
* memcpy(&dst, &src, sizeof(va_list))
1236-
* gives maximum portability. */
1237-
#ifndef va_copy
1238-
# ifdef __va_copy
1239-
# define va_copy(dest, src) __va_copy((dest), (src))
1240-
# else
1241-
# define va_copy(dest, src) memcpy(&(dest), &(src), sizeof(va_list))
1242-
# endif
1243-
#endif
12441233
va_copy(usr_copy, args);
12451234
ZVAL_STR(&params[1], zend_vstrpprintf(0, format, usr_copy));
1246-
#ifdef va_copy
12471235
va_end(usr_copy);
1248-
#endif
12491236

12501237
ZVAL_LONG(&params[0], type);
12511238

Zend/zend_portability.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,18 @@ static zend_always_inline double _zend_get_nan(void) /* {{{ */
498498
#define ZEND_VALID_SOCKET(sock) ((sock) >= 0)
499499
#endif
500500

501+
/* va_copy() is __va_copy() in old gcc versions.
502+
* According to the autoconf manual, using
503+
* memcpy(&dst, &src, sizeof(va_list))
504+
* gives maximum portability. */
505+
#ifndef va_copy
506+
# ifdef __va_copy
507+
# define va_copy(dest, src) __va_copy((dest), (src))
508+
# else
509+
# define va_copy(dest, src) memcpy(&(dest), &(src), sizeof(va_list))
510+
# endif
511+
#endif
512+
501513
#endif /* ZEND_PORTABILITY_H */
502514

503515
/*

ext/soap/soap.c

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -167,20 +167,13 @@ ZEND_DECLARE_MODULE_GLOBALS(soap)
167167

168168
static void (*old_error_handler)(int, const char *, const uint32_t, const char*, va_list);
169169

170-
#ifdef va_copy
171170
#define call_old_error_handler(error_num, error_filename, error_lineno, format, args) \
172171
{ \
173172
va_list copy; \
174173
va_copy(copy, args); \
175174
old_error_handler(error_num, error_filename, error_lineno, format, copy); \
176175
va_end(copy); \
177176
}
178-
#else
179-
#define call_old_error_handler(error_num, error_filename, error_lineno, format, args) \
180-
{ \
181-
old_error_handler(error_num, error_filename, error_lineno, format, args); \
182-
}
183-
#endif
184177

185178
#define PHP_SOAP_SERVER_CLASSNAME "SoapServer"
186179
#define PHP_SOAP_CLIENT_CLASSNAME "SoapClient"
@@ -2163,19 +2156,14 @@ static void soap_error_handler(int error_num, const char *error_filename, const
21632156
char* code = SOAP_GLOBAL(error_code);
21642157
char buffer[1024];
21652158
size_t buffer_len;
2166-
#ifdef va_copy
21672159
va_list argcopy;
2168-
#endif
21692160
zend_object **old_objects;
21702161
int old = PG(display_errors);
21712162

2172-
#ifdef va_copy
21732163
va_copy(argcopy, args);
21742164
buffer_len = vslprintf(buffer, sizeof(buffer)-1, format, argcopy);
21752165
va_end(argcopy);
2176-
#else
2177-
buffer_len = vslprintf(buffer, sizeof(buffer)-1, format, args);
2178-
#endif
2166+
21792167
buffer[sizeof(buffer)-1]=0;
21802168
if (buffer_len > sizeof(buffer) - 1 || buffer_len == (size_t)-1) {
21812169
buffer_len = sizeof(buffer) - 1;
@@ -2216,9 +2204,7 @@ static void soap_error_handler(int error_num, const char *error_filename, const
22162204
int old = PG(display_errors);
22172205
int fault = 0;
22182206
zval fault_obj;
2219-
#ifdef va_copy
22202207
va_list argcopy;
2221-
#endif
22222208

22232209
if (error_num == E_USER_ERROR ||
22242210
error_num == E_COMPILE_ERROR ||
@@ -2246,13 +2232,10 @@ static void soap_error_handler(int error_num, const char *error_filename, const
22462232
size_t buffer_len;
22472233
zval outbuflen;
22482234

2249-
#ifdef va_copy
22502235
va_copy(argcopy, args);
22512236
buffer_len = vslprintf(buffer, sizeof(buffer)-1, format, argcopy);
22522237
va_end(argcopy);
2253-
#else
2254-
buffer_len = vslprintf(buffer, sizeof(buffer)-1, format, args);
2255-
#endif
2238+
22562239
buffer[sizeof(buffer)-1]=0;
22572240
if (buffer_len > sizeof(buffer) - 1 || buffer_len == (size_t)-1) {
22582241
buffer_len = sizeof(buffer) - 1;

main/php.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -240,14 +240,6 @@ typedef unsigned int socklen_t;
240240
# endif
241241
#endif
242242

243-
#ifndef va_copy
244-
# ifdef __va_copy
245-
# define va_copy(ap1, ap2) __va_copy((ap1), (ap2))
246-
# else
247-
# define va_copy(ap1, ap2) memcpy((&ap1), (&ap2), sizeof(va_list))
248-
# endif
249-
#endif
250-
251243
#include "php_stdint.h"
252244

253245
#include "zend_hash.h"

0 commit comments

Comments
 (0)