[M3devel] cas/casp?

Jay K jay.krell at cornell.edu
Fri Dec 18 19:23:59 CET 2009


Nevermind.

 

http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Atomic-Builtins.html





 


From: jay.krell at cornell.edu
To: hosking at cs.purdue.edu; m3devel at elegosoft.com
Date: Fri, 18 Dec 2009 18:04:27 +0000
Subject: [M3devel] cas/casp?



Tony is this right?
 
 
conceptually:
 
 
result := CAS(VAR destination, compare, exchange)
 
 
old := destination
if old := compare then
  destination = exchange
return old
 
 
bool result := CASP(VAR destination, compare, exchange)
P for predicate aka returning bool
 
 
old := destination
if old = compare then
  destination := exchange
  return true
return false
 
 
I'm pretty sure it is.
 
 
I'll have this for 16 bit and 32 bit values shortly, for now requiring
a recent Microsoft compiler and it generates function calls.
But inlining should be easy enough.
And then 8bit and 64bit.
 
 
Also this will probably not work on 386 or 486 but require Pentium or somesuch.
I don't know when various instructions were introduced but I know
386 is much poorer here than modern processors.
 
 
I assume only support int8, uint8, int16, uint16, int32, uint32, int64, uint64, size_t, ptrdiff_t
and not e.g. floating point.
 
 
 - Jay
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20091218/796be31a/attachment-0002.html>


More information about the M3devel mailing list