Mercurial > libjeffpc
changeset 805:6e72f4b462c8
atomic: fix atomic_cas* comment documenting the behavior
It was backwards from reality (and tests). Returning the "before" value is
more useful because it allows us to retry the CAS without having to reload
the variable to get the old value.
Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author | Josef 'Jeff' Sipek <jeffpc@josefsipek.net> |
---|---|
date | Fri, 10 Apr 2020 12:25:17 -0400 |
parents | 59316ed46006 |
children | 12a3139a2baf |
files | include/jeffpc/atomic.h |
diffstat | 1 files changed, 2 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/include/jeffpc/atomic.h Fri Apr 10 11:57:07 2020 -0400 +++ b/include/jeffpc/atomic.h Fri Apr 10 12:25:17 2020 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net> + * Copyright (c) 2014-2020 Josef 'Jeff' Sipek <jeffpc@josefsipek.net> * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -49,7 +49,7 @@ #define atomic_inc(var) atomic_add((var), 1) #define atomic_dec(var) atomic_sub((var), 1) -/* The following return the 'after' value. If == new, then a swap occured. */ +/* The following return the 'before' value. If == old, then a swap occured. */ #define atomic_cas(var, old, new) \ __sync_val_compare_and_swap(&(var)->v, (old), (new)) #define atomic_cas_ptr(var, old, new) \