Add a configure-time check for an IPC support

Adds a configure check for System V and POSIX IPC.
System V takes precedence over POSIX IPC, and if both
are not supported, QT_NO_SHAREDMEMORY and
QT_NO_SYSTEMSEMAPHORE are defined.

This patch is a forward-port from 4.8 branch
(6ef4abaa9cd7d465cbae5cbf8cb4664bef387d10).

Change-Id: I3ec20342f0f0266843479634109b67c6989dd296
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Tobias Koenig 2014-12-22 10:27:53 +01:00
parent 3d17b73377
commit c3e50db199
5 changed files with 136 additions and 0 deletions

View File

@ -0,0 +1,58 @@
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the config.tests of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/mman.h>
#include <semaphore.h>
#include <fcntl.h>
int main(int, char **)
{
sem_t *semaphore = sem_open("test", O_CREAT | O_EXCL, 0666, 0);
if (semaphore != SEM_FAILED)
sem_close(semaphore);
shm_open("test", O_RDWR | O_CREAT | O_EXCL, 0666);
shm_unlink("test");
return 0;
}

View File

@ -0,0 +1,4 @@
SOURCES = ipc.cpp
CONFIG -= qt dylib
mac:CONFIG -= app_bundle
linux:LIBS += -lpthread -lrt

View File

@ -0,0 +1,59 @@
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the config.tests of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
#include <sys/shm.h>
#include <fcntl.h>
int main(int, char **)
{
key_t unix_key = ftok("test", 'Q');
int semaphore = semget(unix_key, 1, 0666 | IPC_CREAT | IPC_EXCL);
if (semaphore != -1)
semctl(semaphore, 0, IPC_RMID, 0);
shmget(unix_key, 0, 0666 | IPC_CREAT | IPC_EXCL);
shmctl(0, 0, static_cast<struct shmid_ds *>(0));
return 0;
}

View File

@ -0,0 +1,3 @@
SOURCES = ipc.cpp
CONFIG -= qt dylib
mac:CONFIG -= app_bundle

12
configure vendored
View File

@ -4310,6 +4310,18 @@ fi
[ "$XPLATFORM_MINGW" = "yes" ] && QMakeVar add styles "windowsxp windowsvista"
[ "$XPLATFORM_ANDROID" = "yes" ] && QMakeVar add styles "android"
# check IPC support
if ! compileTest unix/ipc_sysv "ipc_sysv" ; then
# SYSV IPC is not supported - check POSIX IPC
if compileTest unix/ipc_posix "ipc_posix" ; then
QCONFIG_FLAGS="$QCONFIG_FLAGS QT_POSIX_IPC"
else
if [ "$XPLATFORM_ANDROID" = "no" ] ; then
QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_SYSTEMSEMAPHORE QT_NO_SHAREDMEMORY"
fi
fi
fi
# detect zlib
if [ "$CFG_ZLIB" = "no" ]; then
# Note: Qt no longer support builds without zlib