Qt 4.8
Functions | Variables
qatomic_generic_unix.cpp File Reference
#include "qplatformdefs.h"
#include <QtCore/qatomic.h>

Go to the source code of this file.

Functions

Q_CORE_EXPORT int QBasicAtomicInt_fetchAndAddOrdered (volatile int *_q_value, int valueToAdd)
 
Q_CORE_EXPORT int QBasicAtomicInt_fetchAndStoreOrdered (volatile int *_q_value, int newValue)
 
Q_CORE_EXPORT bool QBasicAtomicInt_testAndSetOrdered (volatile int *_q_value, int expectedValue, int newValue)
 
Q_CORE_EXPORT void * QBasicAtomicPointer_fetchAndAddOrdered (void *volatile *_q_value, qptrdiff valueToAdd)
 
Q_CORE_EXPORT void * QBasicAtomicPointer_fetchAndStoreOrdered (void *volatile *_q_value, void *newValue)
 
Q_CORE_EXPORT bool QBasicAtomicPointer_testAndSetOrdered (void *volatile *_q_value, void *expectedValue, void *newValue)
 

Variables

static pthread_mutex_t qAtomicMutex = PTHREAD_MUTEX_INITIALIZER
 

Function Documentation

◆ QBasicAtomicInt_fetchAndAddOrdered()

Q_CORE_EXPORT int QBasicAtomicInt_fetchAndAddOrdered ( volatile int *  _q_value,
int  valueToAdd 
)

Definition at line 76 of file qatomic_generic_unix.cpp.

77 {
78  int returnValue;
79  pthread_mutex_lock(&qAtomicMutex);
80  returnValue = *_q_value;
81  *_q_value += valueToAdd;
82  pthread_mutex_unlock(&qAtomicMutex);
83  return returnValue;
84 }
static pthread_mutex_t qAtomicMutex

◆ QBasicAtomicInt_fetchAndStoreOrdered()

Q_CORE_EXPORT int QBasicAtomicInt_fetchAndStoreOrdered ( volatile int *  _q_value,
int  newValue 
)

Definition at line 65 of file qatomic_generic_unix.cpp.

66 {
67  int returnValue;
68  pthread_mutex_lock(&qAtomicMutex);
69  returnValue = *_q_value;
70  *_q_value = newValue;
71  pthread_mutex_unlock(&qAtomicMutex);
72  return returnValue;
73 }
static pthread_mutex_t qAtomicMutex

◆ QBasicAtomicInt_testAndSetOrdered()

Q_CORE_EXPORT bool QBasicAtomicInt_testAndSetOrdered ( volatile int *  _q_value,
int  expectedValue,
int  newValue 
)

Definition at line 52 of file qatomic_generic_unix.cpp.

53 {
54  bool returnValue = false;
55  pthread_mutex_lock(&qAtomicMutex);
56  if (*_q_value == expectedValue) {
57  *_q_value = newValue;
58  returnValue = true;
59  }
60  pthread_mutex_unlock(&qAtomicMutex);
61  return returnValue;
62 }
static pthread_mutex_t qAtomicMutex

◆ QBasicAtomicPointer_fetchAndAddOrdered()

Q_CORE_EXPORT void* QBasicAtomicPointer_fetchAndAddOrdered ( void *volatile *  _q_value,
qptrdiff  valueToAdd 
)

Definition at line 113 of file qatomic_generic_unix.cpp.

114 {
115  void *returnValue;
116  pthread_mutex_lock(&qAtomicMutex);
117  returnValue = *_q_value;
118  *_q_value = reinterpret_cast<char *>(returnValue) + valueToAdd;
119  pthread_mutex_unlock(&qAtomicMutex);
120  return returnValue;
121 }
static pthread_mutex_t qAtomicMutex

◆ QBasicAtomicPointer_fetchAndStoreOrdered()

Q_CORE_EXPORT void* QBasicAtomicPointer_fetchAndStoreOrdered ( void *volatile *  _q_value,
void *  newValue 
)

Definition at line 102 of file qatomic_generic_unix.cpp.

103 {
104  void *returnValue;
105  pthread_mutex_lock(&qAtomicMutex);
106  returnValue = *_q_value;
107  *_q_value = newValue;
108  pthread_mutex_unlock(&qAtomicMutex);
109  return returnValue;
110 }
static pthread_mutex_t qAtomicMutex

◆ QBasicAtomicPointer_testAndSetOrdered()

Q_CORE_EXPORT bool QBasicAtomicPointer_testAndSetOrdered ( void *volatile *  _q_value,
void *  expectedValue,
void *  newValue 
)

Definition at line 87 of file qatomic_generic_unix.cpp.

90 {
91  bool returnValue = false;
92  pthread_mutex_lock(&qAtomicMutex);
93  if (*_q_value == expectedValue) {
94  *_q_value = newValue;
95  returnValue = true;
96  }
97  pthread_mutex_unlock(&qAtomicMutex);
98  return returnValue;
99 }
static pthread_mutex_t qAtomicMutex

Variable Documentation

◆ qAtomicMutex

pthread_mutex_t qAtomicMutex = PTHREAD_MUTEX_INITIALIZER
static