diff options
author | sfraser%netscape.com <devnull@localhost> | 2001-12-07 23:59:35 +0000 |
---|---|---|
committer | sfraser%netscape.com <devnull@localhost> | 2001-12-07 23:59:35 +0000 |
commit | cc6c5123ff3f29a7387686d8f7e62a088c86d0bd (patch) | |
tree | 077469a2c7f039d8b1ddebcbe11e6f35e1b68aca | |
parent | f4736f8bf0739d4ed6a74543999d544e71c9d3d9 (diff) | |
download | nspr-hg-cc6c5123ff3f29a7387686d8f7e62a088c86d0bd.tar.gz |
Fix bug 106999 -- implement Mac atomic operations using Open Transport routines for speed. r=wtc.
-rw-r--r-- | pr/include/md/_macos.h | 19 | ||||
-rw-r--r-- | pr/src/md/mac/macthr.c | 20 |
2 files changed, 39 insertions, 0 deletions
diff --git a/pr/include/md/_macos.h b/pr/include/md/_macos.h index caf73cb9..f1f0f8aa 100644 --- a/pr/include/md/_macos.h +++ b/pr/include/md/_macos.h @@ -44,6 +44,7 @@ #define PR_DLL_SUFFIX "" #define _PR_LOCAL_THREADS_ONLY #define _PR_NO_PREEMPT 1 +#define _PR_HAVE_ATOMIC_OPS 1 #include "prinit.h" #include "prio.h" @@ -61,7 +62,9 @@ #include <stddef.h> #include <setjmp.h> + #include <Errors.h> +#include <OpenTransport.h> #define _PR_HAVE_PEEK_BUFFER #define _PR_PEEK_BUFFER_MAX (16 * 1024) @@ -678,4 +681,20 @@ extern void LeaveCritialRegion(); #endif +/* + * Atomic operations + */ +#ifdef _PR_HAVE_ATOMIC_OPS + +extern PRInt32 _MD_AtomicSet(PRInt32 *val, PRInt32 newval); + +#define _MD_INIT_ATOMIC() +#define _MD_ATOMIC_INCREMENT(val) OTAtomicAdd32(1, (SInt32 *)val) +#define _MD_ATOMIC_ADD(ptr, val) OTAtomicAdd32(val, (SInt32 *)ptr) +#define _MD_ATOMIC_DECREMENT(val) OTAtomicAdd32(-1, (SInt32 *)val) +#define _MD_ATOMIC_SET(val, newval) _MD_AtomicSet(val, newval) + +#endif /* _PR_HAVE_ATOMIC_OPS */ + + #endif /* prmacos_h___ */ diff --git a/pr/src/md/mac/macthr.c b/pr/src/md/mac/macthr.c index b01eda61..0df8a590 100644 --- a/pr/src/md/mac/macthr.c +++ b/pr/src/md/mac/macthr.c @@ -433,6 +433,26 @@ PRStatus _MD_KillProcess(PRProcess *process) PR_SetError(PR_NOT_IMPLEMENTED_ERROR, unimpErr); return PR_FAILURE; } + +//############################################################################## +//############################################################################## +#pragma mark - +#pragma mark ATOMIC OPERATIONS + +#ifdef _PR_HAVE_ATOMIC_OPS +PRInt32 +_MD_AtomicSet(PRInt32 *val, PRInt32 newval) +{ + PRInt32 rv; + do { + rv = *val; + } while (!OTCompareAndSwap32(rv, newval, (UInt32*)val)); + + return rv; +} + +#endif // _PR_HAVE_ATOMIC_OPS + //############################################################################## //############################################################################## #pragma mark - |