Boost logo

Boost :

From: Chris Thomasson (cristom_at_[hidden])
Date: 2006-11-29 14:58:17


"Chris Thomasson" <cristom_at_[hidden]> wrote in message
news:ej3iak$use$1_at_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...


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk