@@ -38,52 +38,19 @@ typedef char my_atomic_rwlock_t;
3838#define MY_ATOMIC_MODE "dummy (non-atomic)"
3939#else /* not MY_ATOMIC_MODE_DUMMY */
4040
41- typedef struct {mysql_mutex_t rw ;} my_atomic_rwlock_t ;
42-
43- #ifndef SAFE_MUTEX
41+ typedef struct {pthread_mutex_t rw ;} my_atomic_rwlock_t ;
4442
4543/*
4644 we're using read-write lock macros but map them to mutex locks, and they're
4745 faster. Still, having semantically rich API we can change the
4846 underlying implementation, if necessary.
4947*/
50- #define my_atomic_rwlock_destroy (name ) pthread_mutex_destroy(& (name)->rw.m_mutex)
51- #define my_atomic_rwlock_init (name ) pthread_mutex_init(& (name)->rw.m_mutex, 0)
52- #define my_atomic_rwlock_rdlock (name ) pthread_mutex_lock(& (name)->rw.m_mutex)
53- #define my_atomic_rwlock_wrlock (name ) pthread_mutex_lock(& (name)->rw.m_mutex)
54- #define my_atomic_rwlock_rdunlock (name ) pthread_mutex_unlock(& (name)->rw.m_mutex)
55- #define my_atomic_rwlock_wrunlock (name ) pthread_mutex_unlock(& (name)->rw.m_mutex)
56-
57- #else /* SAFE_MUTEX */
58-
59- /*
60- SAFE_MUTEX pollutes the compiling name space with macros
61- that alter pthread_mutex_t, pthread_mutex_init, etc.
62- Atomic operations should never use the safe mutex wrappers.
63- Unfortunately, there is no way to have both:
64- - safe mutex macros expanding pthread_mutex_lock to safe_mutex_lock
65- - my_atomic macros expanding to unmodified pthread_mutex_lock
66- inlined in the same compilation unit.
67- So, in case of SAFE_MUTEX, a function call is required.
68- Given that SAFE_MUTEX is a debugging facility,
69- this extra function call is not a performance concern for
70- production builds.
71- */
72- C_MODE_START
73- extern void plain_pthread_mutex_init (safe_mutex_t * );
74- extern void plain_pthread_mutex_destroy (safe_mutex_t * );
75- extern void plain_pthread_mutex_lock (safe_mutex_t * );
76- extern void plain_pthread_mutex_unlock (safe_mutex_t * );
77- C_MODE_END
78-
79- #define my_atomic_rwlock_destroy (name ) plain_pthread_mutex_destroy(&(name)->rw.m_mutex)
80- #define my_atomic_rwlock_init (name ) plain_pthread_mutex_init(&(name)->rw.m_mutex)
81- #define my_atomic_rwlock_rdlock (name ) plain_pthread_mutex_lock(&(name)->rw.m_mutex)
82- #define my_atomic_rwlock_wrlock (name ) plain_pthread_mutex_lock(&(name)->rw.m_mutex)
83- #define my_atomic_rwlock_rdunlock (name ) plain_pthread_mutex_unlock(&(name)->rw.m_mutex)
84- #define my_atomic_rwlock_wrunlock (name ) plain_pthread_mutex_unlock(&(name)->rw.m_mutex)
85-
86- #endif /* SAFE_MUTEX */
48+ #define my_atomic_rwlock_destroy (name ) pthread_mutex_destroy(& (name)->rw)
49+ #define my_atomic_rwlock_init (name ) pthread_mutex_init(& (name)->rw, 0)
50+ #define my_atomic_rwlock_rdlock (name ) pthread_mutex_lock(& (name)->rw)
51+ #define my_atomic_rwlock_wrlock (name ) pthread_mutex_lock(& (name)->rw)
52+ #define my_atomic_rwlock_rdunlock (name ) pthread_mutex_unlock(& (name)->rw)
53+ #define my_atomic_rwlock_wrunlock (name ) pthread_mutex_unlock(& (name)->rw)
8754
8855#define MY_ATOMIC_MODE "mutex"
8956#ifndef MY_ATOMIC_MODE_RWLOCKS
0 commit comments