1 #include <BeOSBuildCompatibility.h> 2 3 #include <string.h> 4 5 #include <OS.h> 6 #include <SupportDefs.h> 7 8 9 int32 10 atomic_set(vint32 *value, int32 newValue) 11 { 12 int32 oldValue = *value; 13 *value = newValue; 14 return oldValue; 15 } 16 17 18 int32 19 atomic_test_and_set(vint32 *value, int32 newValue, int32 testAgainst) 20 { 21 int32 oldValue = *value; 22 if (oldValue == testAgainst) 23 *value = newValue; 24 return oldValue; 25 } 26 27 28 int32 29 atomic_add(vint32 *value, int32 addValue) 30 { 31 int32 oldValue = *value; 32 *value += addValue; 33 return oldValue; 34 } 35 36 37 int32 38 atomic_and(vint32 *value, int32 andValue) 39 { 40 int32 oldValue = *value; 41 *value &= andValue; 42 return oldValue; 43 } 44 45 46 int32 47 atomic_or(vint32 *value, int32 orValue) 48 { 49 int32 oldValue = *value; 50 *value |= orValue; 51 return oldValue; 52 } 53 54 55 int32 56 atomic_get(vint32 *value) 57 { 58 return *value; 59 } 60