diff options
author | chris <chris@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-02-27 00:49:25 +0000 |
---|---|---|
committer | chris <chris@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-02-27 00:49:25 +0000 |
commit | 733e2e952b6edba9082e8d34c8b058cfd16fb336 (patch) | |
tree | 72d8649c6934b9ff3f76cd25d2440d4c115efbd1 /ace | |
parent | 2b4df3b0d7e68751a6ba9d7f718590bc75fddc5e (diff) | |
download | ATCD-733e2e952b6edba9082e8d34c8b058cfd16fb336.tar.gz |
ChangeLogTag:Wed Feb 26 18:42:33 2003 Christopher Kohlhoff <chris@kohlhoff.com>
Diffstat (limited to 'ace')
-rw-r--r-- | ace/Atomic_Op.cpp | 32 | ||||
-rw-r--r-- | ace/Atomic_Op.h | 3 | ||||
-rw-r--r-- | ace/Atomic_Op.i | 12 | ||||
-rw-r--r-- | ace/Makefile.bor | 3 | ||||
-rw-r--r-- | ace/Synch.h | 2 |
5 files changed, 48 insertions, 4 deletions
diff --git a/ace/Atomic_Op.cpp b/ace/Atomic_Op.cpp index b35d1d7424c..11c075d473d 100644 --- a/ace/Atomic_Op.cpp +++ b/ace/Atomic_Op.cpp @@ -13,6 +13,7 @@ ACE_RCSID(ace, Atomic_Op, "$Id$") long (*ACE_Atomic_Op<ACE_Thread_Mutex, long>::increment_fn_) (volatile long *) = 0; long (*ACE_Atomic_Op<ACE_Thread_Mutex, long>::decrement_fn_) (volatile long *) = 0; +long (*ACE_Atomic_Op<ACE_Thread_Mutex, long>::exchange_fn_) (volatile long *, long) = 0; long (*ACE_Atomic_Op<ACE_Thread_Mutex, long>::exchange_add_fn_) (volatile long *, long) = 0; void @@ -22,12 +23,14 @@ ACE_Atomic_Op<ACE_Thread_Mutex, long>::init_functions (void) { increment_fn_ = single_cpu_increment; decrement_fn_ = single_cpu_decrement; + exchange_fn_ = single_cpu_exchange; exchange_add_fn_ = single_cpu_exchange_add; } else { increment_fn_ = multi_cpu_increment; decrement_fn_ = multi_cpu_decrement; + exchange_fn_ = multi_cpu_exchange; exchange_add_fn_ = multi_cpu_exchange_add; } } @@ -75,6 +78,20 @@ ACE_Atomic_Op<ACE_Thread_Mutex, long>::single_cpu_decrement (volatile long *valu } long +ACE_Atomic_Op<ACE_Thread_Mutex, long>::single_cpu_exchange (volatile long *value, + long rhs) +{ +#if defined (__GNUC__) && defined (ACE_HAS_PENTIUM) + unsigned long addr = ACE_reinterpret_cast (unsigned long, value); + asm( "xchg %0, (%1)" : "+r"(rhs) : "r"(addr) ); + return rhs; +#else /* __GNUC__ && ACE_HAS_PENTIUM */ + ACE_UNUSED_ARG (value); + ACE_NOTSUP_RETURN (-1); +#endif /* __GNUC__ && ACE_HAS_PENTIUM */ +} + +long ACE_Atomic_Op<ACE_Thread_Mutex, long>::single_cpu_exchange_add (volatile long *value, long rhs) { @@ -137,6 +154,21 @@ ACE_Atomic_Op<ACE_Thread_Mutex, long>::multi_cpu_decrement (volatile long *value } long +ACE_Atomic_Op<ACE_Thread_Mutex, long>::multi_cpu_exchange (volatile long *value, + long rhs) +{ +#if defined (__GNUC__) && defined (ACE_HAS_PENTIUM) + unsigned long addr = ACE_reinterpret_cast (unsigned long, value); + // The XCHG instruction automatically follows LOCK semantics + asm( "xchg %0, (%1)" : "+r"(rhs) : "r"(addr) ); + return rhs; +#else /* __GNUC__ && ACE_HAS_PENTIUM */ + ACE_UNUSED_ARG (value); + ACE_NOTSUP_RETURN (-1); +#endif /* __GNUC__ && ACE_HAS_PENTIUM */ +} + +long ACE_Atomic_Op<ACE_Thread_Mutex, long>::multi_cpu_exchange_add (volatile long *value, long rhs) { diff --git a/ace/Atomic_Op.h b/ace/Atomic_Op.h index 086fc7da3bd..c84697b6e12 100644 --- a/ace/Atomic_Op.h +++ b/ace/Atomic_Op.h @@ -137,16 +137,19 @@ private: // Single-cpu atomic op implementations. static long single_cpu_increment (volatile long *value); static long single_cpu_decrement (volatile long *value); + static long single_cpu_exchange (volatile long *value, long rhs); static long single_cpu_exchange_add (volatile long *value, long rhs); // Multi-cpu atomic op implementations. static long multi_cpu_increment (volatile long *value); static long multi_cpu_decrement (volatile long *value); + static long multi_cpu_exchange (volatile long *value, long rhs); static long multi_cpu_exchange_add (volatile long *value, long rhs); // Pointers to selected atomic op implementations. static long (*increment_fn_) (volatile long *); static long (*decrement_fn_) (volatile long *); + static long (*exchange_fn_) (volatile long *, long); static long (*exchange_add_fn_) (volatile long *, long); }; #endif /* ACE_HAS_BUILTIN_ATOMIC_OP */ diff --git a/ace/Atomic_Op.i b/ace/Atomic_Op.i index 39d09ba0d17..dfae7e33526 100644 --- a/ace/Atomic_Op.i +++ b/ace/Atomic_Op.i @@ -117,14 +117,22 @@ ACE_Atomic_Op<ACE_Thread_Mutex, long>::operator< (long rhs) const ACE_INLINE void ACE_Atomic_Op<ACE_Thread_Mutex, long>::operator= (long rhs) { - this->value_ = rhs; +#if defined (WIN32) + ::InterlockedExchange (ACE_const_cast (long *, &this->value_), rhs); +#else /* WIN32 */ + (*exchange_fn_) (&this->value_, rhs); +#endif /* WIN32 */ } ACE_INLINE void ACE_Atomic_Op<ACE_Thread_Mutex, long>::operator= ( const ACE_Atomic_Op<ACE_Thread_Mutex, long> &rhs) { - this->value_ = rhs.value_; +#if defined (WIN32) + ::InterlockedExchange (ACE_const_cast (long *, &this->value_), rhs.value_); +#else /* WIN32 */ + (*exchange_fn_) (&this->value_, rhs.value_); +#endif /* WIN32 */ } ACE_INLINE long diff --git a/ace/Makefile.bor b/ace/Makefile.bor index 8008811bca8..2e2bf8de58d 100644 --- a/ace/Makefile.bor +++ b/ace/Makefile.bor @@ -245,8 +245,7 @@ OBJFILES = \ RESOURCE = $(OBJDIR)\ace.res -CFLAGS = $(ACE_CFLAGS) -DACE_BUILD_DLL -DACE_OS_BUILD_DLL \ - -DACE_LD_DECORATOR_STR=ACE_LIB_TEXT(\"$(LIB_DECORATOR)\") +CFLAGS = $(ACE_CFLAGS) -DACE_BUILD_DLL -DACE_OS_BUILD_DLL CPPDIR = . INCDIR_NAME = ace diff --git a/ace/Synch.h b/ace/Synch.h index f1a680e7e63..a8798689064 100644 --- a/ace/Synch.h +++ b/ace/Synch.h @@ -1701,6 +1701,7 @@ public: // = Initialization and termination methods. ACE_Guard (ACE_Null_Mutex &) {} ACE_Guard (ACE_Null_Mutex &, int) {} + ACE_Guard (ACE_Null_Mutex &, int, int) {} #if defined (ACE_WIN32) ~ACE_Guard (void) {} #endif /* ACE_WIN32 */ @@ -1708,6 +1709,7 @@ public: int acquire (void) { return 0; } int tryacquire (void) { return 0; } int release (void) { return 0; } + void disown (void) {} int locked (void) { return 1; } int remove (void) { return 0; } void dump (void) const {} |