summaryrefslogtreecommitdiff
path: root/include/my_atomic.h
diff options
context:
space:
mode:
authorunknown <serg@janus.mylan>2006-10-23 15:13:51 +0200
committerunknown <serg@janus.mylan>2006-10-23 15:13:51 +0200
commitce707d9f7fb589a1a928ccc58b34b03a9a3a48d0 (patch)
tree4c92bbfbd700a8880d1d2f2cec5581428e9d612b /include/my_atomic.h
parentbef65f33c2f075140850c98a1779e636e66a5412 (diff)
downloadmariadb-git-ce707d9f7fb589a1a928ccc58b34b03a9a3a48d0.tar.gz
include/my_atomic.h: comment
include/my_atomic.h: comment
Diffstat (limited to 'include/my_atomic.h')
-rw-r--r--include/my_atomic.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/include/my_atomic.h b/include/my_atomic.h
index aad69295998..8efad2802c0 100644
--- a/include/my_atomic.h
+++ b/include/my_atomic.h
@@ -14,6 +14,40 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+/*
+ This header defines five atomic operations:
+
+ my_atomic_add#(&var, what)
+ add 'what' to *var, and return the old value of *var
+
+ my_atomic_fas#(&var, what)
+ 'Fetch And Store'
+ store 'what' in *var, and return the old value of *var
+
+ my_atomic_cas#(&var, &old, new)
+ 'Compare And Swap'
+ if *var is equal to *old, then store 'new' in *var, and return TRUE
+ otherwise store *var in *old, and return FALSE
+
+ my_atomic_load#(&var)
+ return *var
+
+ my_atomic_store#(&var, what)
+ store 'what' in *var
+
+ '#' is substituted by a size suffix - 8, 16, 32, or ptr
+ (e.g. my_atomic_add8, my_atomic_fas32, my_atomic_casptr).
+
+ NOTE This operations are not always atomic, so they always must be
+ enclosed in my_atomic_rwlock_rdlock(lock)/my_atomic_rwlock_rdunlock(lock)
+ or my_atomic_rwlock_wrlock(lock)/my_atomic_rwlock_wrunlock(lock).
+ Hint: if a code block makes intensive use of atomic ops, it make sense
+ to take/release rwlock once for the whole block, not for every statement.
+
+ On architectures where these operations are really atomic, rwlocks will
+ be optimized away.
+*/
+
#ifndef my_atomic_rwlock_init
#define intptr void *