Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/kernel/qsharedmemory_unix.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count |
---|---|---|
1 | /**************************************************************************** | - |
2 | ** | - |
3 | ** Copyright (C) 2015 The Qt Company Ltd. | - |
4 | ** Contact: http://www.qt.io/licensing/ | - |
5 | ** | - |
6 | ** This file is part of the QtCore module of the Qt Toolkit. | - |
7 | ** | - |
8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - |
9 | ** Commercial License Usage | - |
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
11 | ** accordance with the commercial license agreement provided with the | - |
12 | ** Software or, alternatively, in accordance with the terms contained in | - |
13 | ** a written agreement between you and The Qt Company. For licensing terms | - |
14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - |
15 | ** information use the contact form at http://www.qt.io/contact-us. | - |
16 | ** | - |
17 | ** GNU Lesser General Public License Usage | - |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
19 | ** General Public License version 2.1 or version 3 as published by the Free | - |
20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - |
21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - |
22 | ** following information to ensure the GNU Lesser General Public License | - |
23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - |
24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
25 | ** | - |
26 | ** As a special exception, The Qt Company gives you certain additional | - |
27 | ** rights. These rights are described in The Qt Company LGPL Exception | - |
28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
29 | ** | - |
30 | ** $QT_END_LICENSE$ | - |
31 | ** | - |
32 | ****************************************************************************/ | - |
33 | - | |
34 | #include "qplatformdefs.h" | - |
35 | - | |
36 | #include "qsharedmemory.h" | - |
37 | #include "qsharedmemory_p.h" | - |
38 | #include "qsystemsemaphore.h" | - |
39 | #include <qdebug.h> | - |
40 | - | |
41 | #include <errno.h> | - |
42 | - | |
43 | #ifndef QT_NO_SHAREDMEMORY | - |
44 | #include <sys/types.h> | - |
45 | #ifndef QT_POSIX_IPC | - |
46 | #include <sys/ipc.h> | - |
47 | #include <sys/shm.h> | - |
48 | #else | - |
49 | #include <sys/mman.h> | - |
50 | #endif | - |
51 | #include <sys/stat.h> | - |
52 | #include <fcntl.h> | - |
53 | #include <unistd.h> | - |
54 | #endif //QT_NO_SHAREDMEMORY | - |
55 | - | |
56 | #include "private/qcore_unix_p.h" | - |
57 | - | |
58 | #ifndef QT_NO_SHAREDMEMORY | - |
59 | QT_BEGIN_NAMESPACE | - |
60 | - | |
61 | QSharedMemoryPrivate::QSharedMemoryPrivate() | - |
62 | : QObjectPrivate(), memory(0), size(0), error(QSharedMemory::NoError), | - |
63 | #ifndef QT_NO_SYSTEMSEMAPHORE | - |
64 | systemSemaphore(QString()), lockedByMe(false), | - |
65 | #endif | - |
66 | #ifndef QT_POSIX_IPC | - |
67 | unix_key(0) | - |
68 | #else | - |
69 | hand(-1) | - |
70 | #endif | - |
71 | { | - |
72 | } executed 3612 times by 3 tests: end of block Executed by:
| 3612 |
73 | - | |
74 | void QSharedMemoryPrivate::setErrorString(QLatin1String function) | - |
75 | { | - |
76 | // EINVAL is handled in functions so they can give better error strings | - |
77 | switch (errno) { | - |
78 | case EACCES: never executed: case 13: | 0 |
79 | errorString = QSharedMemory::tr("%1: permission denied").arg(function); | - |
80 | error = QSharedMemory::PermissionDenied; | - |
81 | break; never executed: break; | 0 |
82 | case EEXIST: executed 2 times by 1 test: case 17: Executed by:
| 2 |
83 | errorString = QSharedMemory::tr("%1: already exists").arg(function); | - |
84 | error = QSharedMemory::AlreadyExists; | - |
85 | break; executed 2 times by 1 test: break; Executed by:
| 2 |
86 | case ENOENT: never executed: case 2: | 0 |
87 | errorString = QSharedMemory::tr("%1: doesn't exist").arg(function); | - |
88 | error = QSharedMemory::NotFound; | - |
89 | break; never executed: break; | 0 |
90 | case EMFILE: never executed: case 24: | 0 |
91 | case ENOMEM: never executed: case 12: | 0 |
92 | case ENOSPC: never executed: case 28: | 0 |
93 | errorString = QSharedMemory::tr("%1: out of resources").arg(function); | - |
94 | error = QSharedMemory::OutOfResources; | - |
95 | break; never executed: break; | 0 |
96 | default: never executed: default: | 0 |
97 | errorString = QSharedMemory::tr("%1: unknown error %2").arg(function).arg(errno); | - |
98 | error = QSharedMemory::UnknownError; | - |
99 | #if defined QSHAREDMEMORY_DEBUG | - |
100 | qDebug() << errorString << "key" << key << "errno" << errno << EINVAL; | - |
101 | #endif | - |
102 | } never executed: end of block | 0 |
103 | } | - |
104 | - | |
105 | QT_END_NAMESPACE | - |
106 | - | |
107 | #endif // QT_NO_SHAREDMEMORY | - |
Source code | Switch to Preprocessed file |