Qt 4.8
Functions
qatomic_sparc.cpp File Reference
#include <QtCore/qatomic.h>
#include <limits.h>
#include <sched.h>

Go to the source code of this file.

Functions

Q_CORE_EXPORT int q_atomic_lock_int (volatile int *addr)
 
Q_CORE_EXPORT int q_atomic_lock_ptr (volatile void *addr)
 
int q_atomic_trylock_int (volatile int *addr)
 
int q_atomic_trylock_ptr (volatile void *addr)
 

Function Documentation

◆ q_atomic_lock_int()

Q_CORE_EXPORT int q_atomic_lock_int ( volatile int *  addr)

Definition at line 52 of file qatomic_sparc.cpp.

53 {
54  int returnValue = q_atomic_trylock_int(addr);
55 
56  if (returnValue == INT_MIN) {
57  do {
58  // spin until we think we can succeed
59  do {
60  sched_yield();
61  returnValue = *addr;
62  } while (returnValue == INT_MIN);
63 
64  // try again
65  returnValue = q_atomic_trylock_int(addr);
66  } while (returnValue == INT_MIN);
67  }
68 
69  return returnValue;
70 }
int q_atomic_trylock_int(volatile int *addr)

◆ q_atomic_lock_ptr()

Q_CORE_EXPORT int q_atomic_lock_ptr ( volatile void *  addr)

Definition at line 72 of file qatomic_sparc.cpp.

73 {
74  int returnValue = q_atomic_trylock_ptr(addr);
75 
76  if (returnValue == -1) {
77  do {
78  // spin until we think we can succeed
79  do {
80  sched_yield();
81  returnValue = *reinterpret_cast<volatile int *>(addr);
82  } while (returnValue == -1);
83 
84  // try again
85  returnValue = q_atomic_trylock_ptr(addr);
86  } while (returnValue == -1);
87  }
88 
89  return returnValue;
90 }
int q_atomic_trylock_ptr(volatile void *addr)

◆ q_atomic_trylock_int()

int q_atomic_trylock_int ( volatile int *  addr)

Referenced by q_atomic_lock_int().

◆ q_atomic_trylock_ptr()

int q_atomic_trylock_ptr ( volatile void *  addr)

Referenced by q_atomic_lock_ptr().