Added a simple (and completely non-reliable) C implementation for atomic_set(),
and atomic_test_and_set() for userland testing purposes. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1987 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -114,7 +114,26 @@ template<class Node> struct list {
|
|||||||
// atomic_set(value, newValue)
|
// atomic_set(value, newValue)
|
||||||
// sets "value" to "newValue"
|
// sets "value" to "newValue"
|
||||||
|
|
||||||
#if __INTEL__
|
#if _NO_INLINE_ASM
|
||||||
|
// Note that these atomic versions *don't* work as expected!
|
||||||
|
// They are only used for single processor user space tests
|
||||||
|
// (and don't even work correctly there)
|
||||||
|
inline int32
|
||||||
|
atomic_test_and_set(volatile int32 *value, int32 newValue, int32 testAgainst)
|
||||||
|
{
|
||||||
|
int32 oldValue = *value;
|
||||||
|
if (oldValue == testAgainst)
|
||||||
|
*value = newValue;
|
||||||
|
|
||||||
|
return oldValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void
|
||||||
|
atomic_set(volatile int32 *value, int32 newValue)
|
||||||
|
{
|
||||||
|
*value = newValue;
|
||||||
|
}
|
||||||
|
#elif __INTEL__
|
||||||
inline int32
|
inline int32
|
||||||
atomic_test_and_set(volatile int32 *value, int32 newValue, int32 testAgainst)
|
atomic_test_and_set(volatile int32 *value, int32 newValue, int32 testAgainst)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user