ios: fix compilation with osx 10.6

Change-Id: Id0b28c0aab46237b60756f12be05e3d05df9c9e7
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com>
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
Fawzi Mohamed
2013-10-04 01:28:47 +02:00
committed by Eike Ziller
parent 31b8fbbcbf
commit c39ec1e309
2 changed files with 35 additions and 8 deletions

View File

@@ -39,6 +39,7 @@
#include <QDebug>
#include <QCoreApplication>
#include <QList>
#include <QScopedArrayPointer>
#include <sys/types.h>
#include <sys/socket.h>
@@ -404,6 +405,17 @@ void IosToolHandlerPrivate::subprocessFinished(int exitCode, QProcess::ExitStatu
}
}
#ifndef CMSG_SPACE
size_t CMSG_SPACE(size_t len) {
msghdr msg;
cmsghdr cmsg;
msg.msg_control = &cmsg;
msg.msg_controllen = ~socklen_t(0); /* To maximize the chance that CMSG_NXTHDR won't return NULL */
cmsg.cmsg_len = CMSG_LEN(len);
return reinterpret_cast<unsigned char *>(CMSG_NXTHDR(&msg, &cmsg)) - reinterpret_cast<unsigned char *>(&cmsg);
}
#endif
int recv_fd(int socket)
{
int sent_fd;
@@ -421,10 +433,11 @@ int recv_fd(int socket)
socket_message.msg_iovlen = 1;
/* provide space for the ancillary data */
char ancillary_element_buffer[CMSG_SPACE(sizeof(int))];
memset(ancillary_element_buffer, 0, CMSG_SPACE(sizeof(int)));
socket_message.msg_control = ancillary_element_buffer;
socket_message.msg_controllen = CMSG_SPACE(sizeof(int));
size_t dimAncillaryEl = CMSG_SPACE(sizeof(int));
QScopedArrayPointer<char> ancillary_element_buffer(new char[dimAncillaryEl]);
memset(ancillary_element_buffer.data(), 0, dimAncillaryEl);
socket_message.msg_control = ancillary_element_buffer.data();
socket_message.msg_controllen = dimAncillaryEl;
int flags = 0;
#ifdef MSG_CMSG_CLOEXEC