@@ -26,57 +26,57 @@ #import "macros.h" #if defined(OF_HAVE_PTHREADS) # include -typedef pthread_mutex_t of_mutex_t; +typedef pthread_mutex_t OFPlainMutex; #elif defined(OF_WINDOWS) # include -typedef CRITICAL_SECTION of_mutex_t; +typedef CRITICAL_SECTION OFPlainMutex; #elif defined(OF_AMIGAOS) # include -typedef struct SignalSemaphore of_mutex_t; +typedef struct SignalSemaphore OFPlainMutex; #endif #if defined(OF_HAVE_ATOMIC_OPS) # import "atomic.h" typedef volatile int of_spinlock_t; # define OF_SPINCOUNT 10 #elif defined(OF_HAVE_PTHREAD_SPINLOCKS) typedef pthread_spinlock_t of_spinlock_t; #else -typedef of_mutex_t of_spinlock_t; +typedef OFPlainMutex of_spinlock_t; #endif #ifdef OF_HAVE_SCHED_YIELD # include #endif #if defined(OF_HAVE_RECURSIVE_PTHREAD_MUTEXES) || defined(OF_WINDOWS) || \ defined(OF_AMIGAOS) -# define of_rmutex_t of_mutex_t +# define OFPlainRecursiveMutex OFPlainMutex #else # import "tlskey.h" typedef struct { - of_mutex_t mutex; + OFPlainMutex mutex; OFTLSKey count; -} of_rmutex_t; +} OFPlainRecursiveMutex; #endif #ifdef __cplusplus extern "C" { #endif -extern int of_mutex_new(of_mutex_t *mutex); -extern int of_mutex_lock(of_mutex_t *mutex); -extern int of_mutex_trylock(of_mutex_t *mutex); -extern int of_mutex_unlock(of_mutex_t *mutex); -extern int of_mutex_free(of_mutex_t *mutex); -extern int of_rmutex_new(of_rmutex_t *rmutex); -extern int of_rmutex_lock(of_rmutex_t *rmutex); -extern int of_rmutex_trylock(of_rmutex_t *rmutex); -extern int of_rmutex_unlock(of_rmutex_t *rmutex); -extern int of_rmutex_free(of_rmutex_t *rmutex); +extern int OFPlainMutexNew(OFPlainMutex *mutex); +extern int OFPlainMutexLock(OFPlainMutex *mutex); +extern int OFPlainMutexTryLock(OFPlainMutex *mutex); +extern int OFPlainMutexUnlock(OFPlainMutex *mutex); +extern int OFPlainMutexFree(OFPlainMutex *mutex); +extern int OFPlainRecursiveMutexNew(OFPlainRecursiveMutex *rmutex); +extern int OFPlainRecursiveMutexLock(OFPlainRecursiveMutex *rmutex); +extern int OFPlainRecursiveMutexTryLock(OFPlainRecursiveMutex *rmutex); +extern int OFPlainRecursiveMutexUnlock(OFPlainRecursiveMutex *rmutex); +extern int OFPlainRecursiveMutexFree(OFPlainRecursiveMutex *rmutex); #ifdef __cplusplus } #endif /* Spinlocks are inlined for performance. */ @@ -98,11 +98,11 @@ *spinlock = 0; return 0; #elif defined(OF_HAVE_PTHREAD_SPINLOCKS) return pthread_spin_init(spinlock, 0); #else - return of_mutex_new(spinlock); + return OFPlainMutexNew(spinlock); #endif } static OF_INLINE int of_spinlock_trylock(of_spinlock_t *spinlock) @@ -115,11 +115,11 @@ return EBUSY; #elif defined(OF_HAVE_PTHREAD_SPINLOCKS) return pthread_spin_trylock(spinlock); #else - return of_mutex_trylock(spinlock); + return OFPlainMutexTryLock(spinlock); #endif } static OF_INLINE int of_spinlock_lock(of_spinlock_t *spinlock) @@ -136,11 +136,11 @@ return 0; #elif defined(OF_HAVE_PTHREAD_SPINLOCKS) return pthread_spin_lock(spinlock); #else - return of_mutex_lock(spinlock); + return OFPlainMutexLock(spinlock); #endif } static OF_INLINE int of_spinlock_unlock(of_spinlock_t *spinlock) @@ -152,11 +152,11 @@ return (ret ? 0 : EINVAL); #elif defined(OF_HAVE_PTHREAD_SPINLOCKS) return pthread_spin_unlock(spinlock); #else - return of_mutex_unlock(spinlock); + return OFPlainMutexUnlock(spinlock); #endif } static OF_INLINE int of_spinlock_free(of_spinlock_t *spinlock) @@ -164,8 +164,8 @@ #if defined(OF_HAVE_ATOMIC_OPS) return 0; #elif defined(OF_HAVE_PTHREAD_SPINLOCKS) return pthread_spin_destroy(spinlock); #else - return of_mutex_free(spinlock); + return OFPlainMutexFree(spinlock); #endif }