Skip to content

Commit e074e02

Browse files
NattyNarwhalnikic
authored andcommitted
sockets: Fix variable/macro name collision on AIX
The name "rem_size" is used by a macro in a system header on AIX, specifically `sys/xmem.h`. Without changing the name, you get the name mangled like so: ``` In file included from /usr/include/sys/uio.h:92:0, from /QOpenSys/pkgs/lib/gcc/powerpc-ibm-aix6.1.0.0/6.3.0/include-fixed-7.1/sys/socket.h:83, from /usr/include/sys/syslog.h:151, from /usr/include/syslog.h:29, from /home/calvin/rpmbuild/BUILD/php-8.0.0RC5/main/php_syslog.h:27, from /home/calvin/rpmbuild/BUILD/php-8.0.0RC5/main/php.h:318, from /home/calvin/rpmbuild/BUILD/php-8.0.0RC5/ext/sockets/sendrecvmsg.c:17: /home/calvin/rpmbuild/BUILD/php-8.0.0RC5/ext/sockets/sendrecvmsg.c: In function 'zif_socket_cmsg_space': /home/calvin/rpmbuild/BUILD/php-8.0.0RC5/ext/sockets/sendrecvmsg.c:298:10: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token size_t rem_size = ZEND_LONG_MAX - entry->size; ^ /home/calvin/rpmbuild/BUILD/php-8.0.0RC5/ext/sockets/sendrecvmsg.c:298:10: error: expected expression before '.' token /home/calvin/rpmbuild/BUILD/php-8.0.0RC5/ext/sockets/sendrecvmsg.c:299:18: error: 'u2' undeclared (first use in this function) size_t n_max = rem_size / entry->var_el_size; ^ /home/calvin/rpmbuild/BUILD/php-8.0.0RC5/ext/sockets/sendrecvmsg.c:299:18: note: each undeclared identifier is reported only once for each function it appears in ``` ...because of the declaration in `sys/xmem.h`: ``` ``` This just renames the variable so that it won't trip on this definition. Tested to fix the build on IBM i PASE. Closes GH-6453.
1 parent 4633e70 commit e074e02

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

ext/sockets/sendrecvmsg.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,9 @@ PHP_FUNCTION(socket_cmsg_space)
295295
}
296296

297297
if (entry->var_el_size > 0) {
298-
size_t rem_size = ZEND_LONG_MAX - entry->size;
299-
size_t n_max = rem_size / entry->var_el_size;
298+
/* Leading underscore to avoid symbol collision on AIX. */
299+
size_t _rem_size = ZEND_LONG_MAX - entry->size;
300+
size_t n_max = _rem_size / entry->var_el_size;
300301
size_t size = entry->size + n * entry->var_el_size;
301302
size_t total_size = CMSG_SPACE(size);
302303
if (n > n_max /* zend_long overflow */

0 commit comments

Comments
 (0)