44 #if !defined(QT_NO_QWS_MULTIPROCESS) 46 #include <sys/types.h> 57 #include <private/qcore_unix_p.h> 64 #include <QtCore/QAtomicInt> 76 : shmId(-1), shmBase(0), shmSize(0)
94 shmId = shmget(IPC_PRIVATE, size, IPC_CREAT | 0600);
97 shmId = (getpid() << 16) + (localUniqueId.fetchAndAddRelaxed(1) %
ushort(-1));
112 perror(
"QWSSharedMemory::create():");
113 qWarning(
"Error allocating shared memory of size %d", size);
124 shmctl(
shmId, IPC_RMID, 0);
128 if (QT_FSTAT(hand, &st) != -1) {
131 shmBase = mmap(0,
shmSize, PROT_READ | PROT_WRITE, MAP_SHARED, hand, 0);
136 perror(
"QWSSharedMemory::create():");
165 if (QT_FSTAT(hand, &st) != -1) {
168 shmBase = mmap(0,
shmSize, PROT_READ | PROT_WRITE, MAP_SHARED, hand, 0);
174 perror(
"QWSSharedMemory::attach():");
196 if (QT_FSTAT(hand, &st) == 0) {
198 shm_nattch = st.st_nlink - 2;
202 if (shm_nattch == 0) {
221 shmctl(
shmId, IPC_STAT, &shm);
231 #endif // QT_NO_QWS_MULTIPROCESS
#define QT_END_NAMESPACE
This macro expands to.
#define EINTR_LOOP(var, cmd)
The QByteArray class provides an array of bytes.
static int qt_safe_close(int fd)
#define Q_BASIC_ATOMIC_INITIALIZER(a)
#define QT_BEGIN_NAMESPACE
This macro expands to.
Q_CORE_EXPORT void qWarning(const char *,...)
const char * constData() const
Returns a pointer to the data stored in the byte array.
#define st(var, type, card)
static QByteArray number(int, int base=10)
Returns a byte array containing the string equivalent of the number n to base base (10 by default)...