32 #include "../api_core.h"
38 #include "../System/cl_platform.h"
47 #if defined(WIN32) || defined(DOXYGEN) || __GNUC__ > 4 || (__GNUC__ == 4 & __GNUC_MINOR__ >= 1)
79 return InterlockedCompareExchange(val, 0, 0);
82 void set(LONG new_value)
84 InterlockedExchange(val, new_value);
89 return InterlockedIncrement(val);
94 return InterlockedDecrement(val);
99 return InterlockedCompareExchange(val, new_value, expected_value) == expected_value;
131 return __sync_val_compare_and_swap(val, 0, 0);
136 __sync_lock_test_and_set(val, new_value);
141 return __sync_add_and_fetch(val, 1);
146 return __sync_sub_and_fetch(val, 1);
151 return __sync_bool_compare_and_swap(val, expected_value, new_value);
~InterlockedVariable()
Definition: interlocked_variable.h:118
void set(int new_value)
Definition: interlocked_variable.h:134
static void * aligned_alloc(size_t size, size_t alignment=16)
Allocates aligned memory.
int decrement()
Definition: interlocked_variable.h:144
InterlockedVariable(const InterlockedVariable &src)
Definition: interlocked_variable.h:112
static void aligned_free(void *ptr)
Frees aligned memory.
InterlockedVariable & operator=(const InterlockedVariable &src)
Definition: interlocked_variable.h:123
General system helper functions.
Definition: system.h:46
InterlockedVariable()
Definition: interlocked_variable.h:106
bool compare_and_swap(int expected_value, int new_value)
Definition: interlocked_variable.h:149
int byte32
Definition: cl_platform.h:63
Interlocked variable class.
Definition: interlocked_variable.h:50
int get() const
Definition: interlocked_variable.h:129
int increment()
Definition: interlocked_variable.h:139