source: trunk/tools/qvfb/qlock.cpp@ 763

Last change on this file since 763 was 651, checked in by Dmitry A. Kuminov, 16 years ago

trunk: Merged in qt 4.6.2 sources.

File size: 8.7 KB
RevLine 
[2]1/****************************************************************************
2**
[651]3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
[561]4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
[2]6**
7** This file is part of the QtGui module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
[561]24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
[2]27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
[561]36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
[2]38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#include "qlock_p.h"
43
44
[561]45#ifdef QT_NO_QWS_MULTIPROCESS
46
47QT_BEGIN_NAMESPACE
48
49/* no multiprocess - use a dummy */
50
51QLock::QLock(const QString & /*filename*/, char /*id*/, bool /*create*/)
52 : type(Read), data(0)
53{
54}
55
56QLock::~QLock()
57{
58}
59
60bool QLock::isValid() const
61{
62 return true;
63}
64
65void QLock::lock(Type t)
66{
67 data = (QLockData *)-1;
68 type = t;
69}
70
71void QLock::unlock()
72{
73 data = 0;
74}
75
76bool QLock::locked() const
77{
78 return data;
79}
80
81QT_END_NAMESPACE
82
83#else // QT_NO_QWS_MULTIPROCESS
84
[2]85#include "qwssignalhandler_p.h"
[561]86
[2]87#include <unistd.h>
88#include <sys/types.h>
89#if defined(Q_OS_DARWIN)
90# define Q_NO_SEMAPHORE
91# include <sys/stat.h>
92# include <sys/file.h>
93#else // Q_OS_DARWIN
94# include <sys/sem.h>
95# if (defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED) && !defined(QT_LINUXBASE)) \
96 || defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD) || defined(Q_OS_NETBSD) \
97 || defined(Q_OS_BSDI)
98 /* union semun is defined by including <sys/sem.h> */
99# else
100/* according to X/OPEN we have to define it ourselves */
101union semun {
102 int val; /* value for SETVAL */
103 struct semid_ds *buf; /* buffer for IPC_STAT, IPC_SET */
104 unsigned short *array; /* array for GETALL, SETALL */
105};
106# endif
107#endif // Q_OS_DARWIN
108#include <sys/ipc.h>
109#include <string.h>
110#include <errno.h>
111#include <qdebug.h>
112#include <signal.h>
113
[561]