summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Greene <jason@php.net>2002-05-12 07:22:47 +0000
committerJason Greene <jason@php.net>2002-05-12 07:22:47 +0000
commit969d7e5a82698a8dae480ce2bbb42c3de267de1b (patch)
tree69ebecfe6b91457a5632d570a7e815cdd58f48ea
parentebe26ec36c71b4bc72fe9da74aa48114d49dac1d (diff)
downloadphp-git-969d7e5a82698a8dae480ce2bbb42c3de267de1b.tar.gz
Fix build on IRIX for both mips and gcc
-rw-r--r--ext/sockets/config.m41
-rw-r--r--ext/sockets/sockets.c22
2 files changed, 17 insertions, 6 deletions
diff --git a/ext/sockets/config.m4 b/ext/sockets/config.m4
index debd7dbf75..3229fce907 100644
--- a/ext/sockets/config.m4
+++ b/ext/sockets/config.m4
@@ -9,6 +9,7 @@ if test "$PHP_SOCKETS" != "no"; then
AC_CHECK_FUNCS(hstrerror)
AC_CHECK_HEADERS(netdb.h netinet/tcp.h sys/un.h errno.h)
+ AC_CHECK_MEMBER(struct msghdr.msg_flags, , AC_DEFINE(MISSING_MSGHDR_MSGFLAGS, 1, [ ]))
AC_DEFINE(HAVE_SOCKETS, 1, [ ])
PHP_NEW_EXTENSION(sockets, sockets.c, $ext_shared)
diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c
index 87d5e4380c..015cc099c4 100644
--- a/ext/sockets/sockets.c
+++ b/ext/sockets/sockets.c
@@ -1513,9 +1513,11 @@ PHP_FUNCTION(socket_recvmsg)
hdr.msg_control = ctl_buf ? ctl_buf : NULL;
hdr.msg_controllen = ctl_buf ? Z_LVAL_P(arg4) : 0;
+#ifndef MISSING_MSGHDR_MSGFLAGS
hdr.msg_flags = 0;
-
- if (recvmsg(php_sock->bsd_socket, &hdr, Z_LVAL_P(arg5)) != 0) {
+#endif
+
+ if (recvmsg(php_sock->bsd_socket, &hdr, Z_LVAL_P(arg5)) < 0) {
PHP_SOCKET_ERROR(php_sock, "unable to receive message", errno);
RETURN_FALSE;
} else {
@@ -1528,7 +1530,9 @@ PHP_FUNCTION(socket_recvmsg)
zval_dtor(arg7);
ZVAL_LONG(arg4, hdr.msg_controllen);
+#ifndef MISSING_MSGHDR_MSGFLAGS
ZVAL_LONG(arg5, hdr.msg_flags);
+#endif
ZVAL_LONG(arg7, ntohs(sin->sin_port));
if (array_init(arg3) == FAILURE) {
@@ -1536,9 +1540,11 @@ PHP_FUNCTION(socket_recvmsg)
RETURN_FALSE;
}
- add_assoc_long(arg3, "cmsg_level", mhdr->cmsg_level);
- add_assoc_long(arg3, "cmsg_type", mhdr->cmsg_type);
- add_assoc_string(arg3, "cmsg_data", CMSG_DATA(mhdr), 1);
+ if (mhdr != NULL) {
+ add_assoc_long(arg3, "cmsg_level", mhdr->cmsg_level);
+ add_assoc_long(arg3, "cmsg_type", mhdr->cmsg_type);
+ add_assoc_string(arg3, "cmsg_data", CMSG_DATA(mhdr), 1);
+ }
{
char *tmp = inet_ntoa(sin->sin_addr);
@@ -1566,8 +1572,10 @@ PHP_FUNCTION(socket_recvmsg)
hdr.msg_control = NULL;
hdr.msg_controllen = 0;
}
-
+#ifndef MISSING_MSGHDR_MSGFLAGS
hdr.msg_flags = 0;
+#endif
+
if (recvmsg(php_sock->bsd_socket, &hdr, Z_LVAL_P(arg5)) != 0) {
PHP_SOCKET_ERROR(php_sock, "unable to receive message", errno);
@@ -1583,7 +1591,9 @@ PHP_FUNCTION(socket_recvmsg)
zval_dtor(arg6);
ZVAL_LONG(arg4, hdr.msg_controllen);
+#ifndef MISSING_MSGHDR_MSGFLAGS
ZVAL_LONG(arg5, hdr.msg_flags);
+#endif
if (array_init(arg3) == FAILURE) {
php_error(E_WARNING, "%s() cannot initialize return value", get_active_function_name(TSRMLS_C));