From 0c9a17ce0893f95a8a830d83f4fc5f21c6a08bc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 18 Nov 2002 01:16:27 +0000 Subject: [PATCH] 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 --- src/add-ons/kernel/file_systems/bfs/Utility.h | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/add-ons/kernel/file_systems/bfs/Utility.h b/src/add-ons/kernel/file_systems/bfs/Utility.h index e42c3ef210..44af6429d9 100644 --- a/src/add-ons/kernel/file_systems/bfs/Utility.h +++ b/src/add-ons/kernel/file_systems/bfs/Utility.h @@ -114,7 +114,26 @@ template struct list { // atomic_set(value, 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 atomic_test_and_set(volatile int32 *value, int32 newValue, int32 testAgainst) {