From bug 204114 it appears that NSPR doesn't have any ability to atomically swap a pointer value. This would be great for implementing RCU-type synchronization (see the URL).
wtc, assuming that you're ok with this change, what's the process for getting the appropriate platform-specific code (assembly)?
I suspect the proposed function is the pointer analog of PR_AtomicSet, but I'm not sure. Please write down the proposed function prototype so I can comment.
(In reply to comment #2) > I suspect the proposed function is the pointer > analog of PR_AtomicSet, but I'm not sure. > Please write down the proposed function prototype > so I can comment. > Yes, you're absolutely correct. The function would take as arguments the address of the pointer to set and the value for that pointer. It would then return the previous value of the pointer. It's syntax would be just like PR_AtomicSet: void* oldValue = PR_AtomicSetPtr(&pointerToSet, newValue);
NSPR_API(void*) PR_AtomicSetPointer(void **val, void *newval); And, if reading a pointer-sized value is not an atomic operation on all systems: NSPR_API(void*) PR_AtomicReadPointer(void** location);
On 32-bit platforms PR_AtomicSetPointer can be implemented using PR_AtomicSet with typecasts. On 64-bit platforms you should be able to adapt the assembly code of PR_AtomicSet for 64-bit.
You need to log in before you can comment on or make changes to this bug.