Status

NSPR
NSPR
--
enhancement
12 years ago
2 months ago

People

(Reporter: Ben Turner (not reading bugmail, use the needinfo flag!), Assigned: Wan-Teh Chang)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(URL)

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).

Comment 1

12 years ago
wtc, assuming that you're ok with this change, what's the process for getting the appropriate platform-specific code (assembly)?
(Assignee)

Comment 2

12 years ago
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);

Comment 4

12 years ago
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);
(Assignee)

Comment 5

12 years ago
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.
QA Contact: wtchang → nspr
You need to log in before you can comment on or make changes to this bug.