Skip to content
Snippets Groups Projects
Commit 05f177c5 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Added some 'const' decoration and better documentation to the atomics to make...

Added some 'const' decoration and better documentation to the atomics to make them easier to follow.
parent fac83953
Branches
Tags
No related merge requests found
...@@ -39,13 +39,16 @@ ...@@ -39,13 +39,16 @@
* *
* This is a text-book implementation based on an atomic CAS. * This is a text-book implementation based on an atomic CAS.
* *
* We create a temporary union to cope with the int-only atomic CAS
* and the floating-point min that we want.
*
* @param address The address to update. * @param address The address to update.
* @param y The value to update the address with. * @param y The value to update the address with.
*/ */
__attribute__((always_inline)) INLINE static void atomic_min_f( __attribute__((always_inline)) INLINE static void atomic_min_f(
volatile float* address, float y) { volatile float *const address, const float y) {
int* int_ptr = (int*)address; int *const int_ptr = (int *)address;
typedef union { typedef union {
float as_float; float as_float;
...@@ -67,13 +70,16 @@ __attribute__((always_inline)) INLINE static void atomic_min_f( ...@@ -67,13 +70,16 @@ __attribute__((always_inline)) INLINE static void atomic_min_f(
* *
* This is a text-book implementation based on an atomic CAS. * This is a text-book implementation based on an atomic CAS.
* *
* We create a temporary union to cope with the int-only atomic CAS
* and the floating-point max that we want.
*
* @param address The address to update. * @param address The address to update.
* @param y The value to update the address with. * @param y The value to update the address with.
*/ */
__attribute__((always_inline)) INLINE static void atomic_max_f( __attribute__((always_inline)) INLINE static void atomic_max_f(
volatile float* address, float y) { volatile float *const address, const float y) {
int* int_ptr = (int*)address; int *const int_ptr = (int *)address;
typedef union { typedef union {
float as_float; float as_float;
...@@ -95,13 +101,16 @@ __attribute__((always_inline)) INLINE static void atomic_max_f( ...@@ -95,13 +101,16 @@ __attribute__((always_inline)) INLINE static void atomic_max_f(
* *
* This is a text-book implementation based on an atomic CAS. * This is a text-book implementation based on an atomic CAS.
* *
* We create a temporary union to cope with the int-only atomic CAS
* and the floating-point add that we want.
*
* @param address The address to update. * @param address The address to update.
* @param y The value to update the address with. * @param y The value to update the address with.
*/ */
__attribute__((always_inline)) INLINE static void atomic_add_f( __attribute__((always_inline)) INLINE static void atomic_add_f(
volatile float* address, float y) { volatile float *const address, const float y) {
int* int_ptr = (int*)address; int *const int_ptr = (int *)address;
typedef union { typedef union {
float as_float; float as_float;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment