diff --git a/include/ucore/atomic.h b/include/ucore/atomic.h index 1d7184d..5311352 100644 --- a/include/ucore/atomic.h +++ b/include/ucore/atomic.h @@ -1,8 +1,12 @@ #ifndef UC_ATOMIC_H_ #define UC_ATOMIC_H_ -#ifdef __GNUC__ +/** Atomic functions (macros). The ptr argument must be a pointer to + * an integer type. + * For gcc, see http://gcc.gnu.org/onlinedocs/gcc-4.8.1/gcc/_005f_005fsync-Builtins.html + */ +#ifdef __GNUC__ /** * Atomically add val to *ptr @@ -11,7 +15,7 @@ #define UC_ATOMIC_ADD(ptr, val) __sync_fetch_and_add((ptr), (val)) /** - * Atomically subtract val to *ptr + * Atomically subtract val from *ptr * @return *ptr before the subtraction */ #define UC_ATOMIC_SUB(ptr, val) __sync_fetch_and_add((ptr), -(val)) @@ -30,8 +34,7 @@ /** - * UC_ATOMIC_CAS(p, 12, - * Compare-And-Swap. If *ptr is oldval, write newwal to *ptr. + * Atomic Compare-And-Swap. If *ptr is oldval, write newwal to *ptr. * @return *ptr that was before the operation. */ #define UC_ATOMIC_CAS(ptr, oldval, newval) __sync_val_compare_and_swap((ptr), (oldval), (newval))