CAS for SAP-REF-*

Bug #1894057 reported by Nicolas Hafner
16
This bug affects 2 people
Affects Status Importance Assigned to Milestone
SBCL
New
Wishlist
Unassigned

Bug Description

Currently there are no CAS expanders for SAP-REF-* functions, meaning one cannot CAS foreign memory.

This would be valuable for interacting with foreign code that requires atomic synchronisation.

This could then be used by the CFFI backend as well to allow doing things like

   (sb-ext:compare-and-swap (cffi:mem-ref ...) ...)

Tags: feature
Revision history for this message
Andrew Berkley (ajberkley) wrote :

It's almost there:

(let* ((addr (cffi:foreign-alloc :int32 :initial-element 1234))
                (starting-value (cffi:mem-ref addr :int32)))
           (print starting-value)
           (sb-int::%primitive sb-vm::signed-sap-cas-32 (cffi:mem-aptr addr :int32) 0
                               starting-value (random 32))
           (print (cffi:mem-ref addr :int32)))

Revision history for this message
Douglas Katzman (dougk) wrote :

that doesn't really count. It's ad-hoc vop, not for external use, only works on x86-64, and only supports 32-bit int. It needs to support 1,2,4,8 bytes and work all on architectures.

Stas Boukarev (stassats)
Changed in sbcl:
importance: Undecided → Wishlist
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.