
"Chris Thomasson" <cristom@comcast.net> wrote in message news:ej3iak$use$1@sea.gmane.org...
Okay. I will go ahead and post the CAS operations for my "'mostly' lock-free refcount library alternative for Boost...":
http://appcore.home.comcast.net/vzoom/refcount/
;^)
Here is the code for the CAS functions that are compatible with my current refcount library: .align 16 # int refcount_ia32_cas( # refcount_ia32_t* volatile*, # refcount_ia32_t*, # refcount_ia32_t*) .globl _refcount_ia32_cas _refcount_ia32_cas: MOVL 4(%ESP), %ECX TESTL %ECX, %ECX JE refcount_ia32_cas_failed MOVL 8(%ESP), %EAX MOVL 12(%ESP), %EDX LOCK CMPXCHGL %EDX, (%ECX) JNE refcount_ia32_cas_failed MOVL $1, %EAX RETL refcount_ia32_cas_failed: XORl %EAX, %EAX RETL .align 16 # int refcount_ia32_add_cas_weak( # refcount_ia32_t* volatile*, # refcount_ia32_t*, # refcount_ia32_t*, # int) .globl _refcount_ia32_add_cas_weak _refcount_ia32_add_cas_weak: MOVL 4(%ESP), %ECX TESTL %ECX, %ECX JE refcount_ia32_cas_failed MOVL 12(%ESP), %EDX TESTL %EDX, %EDX JE refcount_ia32_add_cas_weak_execute MOVL 16(%ESP), %EAX CMPL $0, %EAX JLE refcount_ia32_add_cas_weak_execute LOCK XADDL %EAX, (%EDX) refcount_ia32_add_cas_weak_execute: MOVL 8(%ESP), %EAX LOCK CMPXCHG %EDX, (%ECX) JNE refcount_ia32_add_cas_weak_dec MOVL $1, %EAX RETL refcount_ia32_add_cas_weak_dec: TESTL %EDX, %EDX JE refcount_ia32_add_cas_weak_failed CMPL $0, 16(%ESP) JLE refcount_ia32_add_cas_weak_failed LOCK DECL (%EDX) refcount_ia32_add_cas_weak_failed: XORL %EAX, %EAX RETL If you want to use CAS with my refcount library now, just stick the posted source code in the refcount-ia32-mingw.asm file and assemble... Then create the declarations in the refcount-ia32.h file, and add the proper member functions to the refcount-sys.hpp and refcount.hpp files... Simple... ;^) I am going to add the CAS to my library very soon, I will definitely keep you posted...