# HG changeset patch # User Josef 'Jeff' Sipek # Date 1586535917 14400 # Node ID 6e72f4b462c83e69e950654d45f46168a6271f14 # Parent 59316ed46006f6bc315070083f763a4453169fd7 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 diff -r 59316ed46006 -r 6e72f4b462c8 include/jeffpc/atomic.h --- 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 + * Copyright (c) 2014-2020 Josef 'Jeff' Sipek * * 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) \