Open
Bug 342898
Opened 18 years ago
Updated 2 years ago
Need an atomic pointer swap
Categories
(NSPR :: NSPR, enhancement)
NSPR
NSPR
Tracking
(Not tracked)
NEW
People
(Reporter: bent.mozilla, Unassigned)
References
()
Details
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•18 years ago
|
||
wtc, assuming that you're ok with this change, what's the process for getting the appropriate platform-specific code (assembly)?
Comment 2•18 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.
Reporter | ||
Comment 3•18 years ago
|
||
(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•18 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);
Comment 5•18 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.
Updated•18 years ago
|
QA Contact: wtchang → nspr
Updated•2 years ago
|
Severity: normal → S3
Comment 6•2 years ago
|
||
The bug assignee is inactive on Bugzilla, so the assignee is being reset.
Assignee: wtc → nobody
You need to log in
before you can comment on or make changes to this bug.
Description
•