diff options
author | jb <jb@FreeBSD.org> | 1998-06-09 23:21:05 +0000 |
---|---|---|
committer | jb <jb@FreeBSD.org> | 1998-06-09 23:21:05 +0000 |
commit | 765df5f4d29065eac50b4bfab3407a7da8a90323 (patch) | |
tree | e14930dc53674181c346bbe0f43647669e330569 /lib/libpthread/thread/thr_mutex.c | |
parent | 5ed1d7e9485fa8756d1be3fdf6cfa5125ac45657 (diff) | |
download | FreeBSD-src-765df5f4d29065eac50b4bfab3407a7da8a90323.zip FreeBSD-src-765df5f4d29065eac50b4bfab3407a7da8a90323.tar.gz |
Implement compile time debug support instead of tracking file name and
line number every time a file descriptor is locked.
This looks like a big change but it isn't. It should reduce the size
of libc_r and make it run slightly faster.
Diffstat (limited to 'lib/libpthread/thread/thr_mutex.c')
-rw-r--r-- | lib/libpthread/thread/thr_mutex.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/lib/libpthread/thread/thr_mutex.c b/lib/libpthread/thread/thr_mutex.c index fb737cf..95c2083 100644 --- a/lib/libpthread/thread/thr_mutex.c +++ b/lib/libpthread/thread/thr_mutex.c @@ -32,6 +32,7 @@ */ #include <stdlib.h> #include <errno.h> +#include <string.h> #ifdef _THREAD_SAFE #include <pthread.h> #include "pthread_private.h" @@ -94,7 +95,8 @@ pthread_mutex_init(pthread_mutex_t * mutex, pmutex->m_flags |= MUTEX_FLAGS_INITED; pmutex->m_owner = NULL; pmutex->m_type = type; - pmutex->access_lock = 0; + memset(&pmutex->lock, 0, + sizeof(pmutex->lock)); *mutex = pmutex; } else { free(pmutex); @@ -116,7 +118,7 @@ pthread_mutex_destroy(pthread_mutex_t * mutex) ret = EINVAL; else { /* Lock the mutex structure: */ - _spinlock(&(*mutex)->access_lock); + _SPINLOCK(&(*mutex)->lock); /* * Free the memory allocated for the mutex @@ -150,7 +152,7 @@ pthread_mutex_trylock(pthread_mutex_t * mutex) else if (*mutex != NULL || (ret = pthread_mutex_init(mutex,NULL)) == 0) { /* Lock the mutex structure: */ - _spinlock(&(*mutex)->access_lock); + _SPINLOCK(&(*mutex)->lock); /* Process according to mutex type: */ switch ((*mutex)->m_type) { @@ -195,7 +197,7 @@ pthread_mutex_trylock(pthread_mutex_t * mutex) } /* Unlock the mutex structure: */ - _atomic_unlock(&(*mutex)->access_lock); + _SPINUNLOCK(&(*mutex)->lock); } /* Return the completion status: */ @@ -217,7 +219,7 @@ pthread_mutex_lock(pthread_mutex_t * mutex) else if (*mutex != NULL || (ret = pthread_mutex_init(mutex,NULL)) == 0) { /* Lock the mutex structure: */ - _spinlock(&(*mutex)->access_lock); + _SPINLOCK(&(*mutex)->lock); /* Process according to mutex type: */ switch ((*mutex)->m_type) { @@ -240,13 +242,13 @@ pthread_mutex_lock(pthread_mutex_t * mutex) _thread_queue_enq(&(*mutex)->m_queue, _thread_run); /* Unlock the mutex structure: */ - _atomic_unlock(&(*mutex)->access_lock); + _SPINUNLOCK(&(*mutex)->lock); /* Block signals: */ _thread_kern_sched_state(PS_MUTEX_WAIT, __FILE__, __LINE__); /* Lock the mutex again: */ - _spinlock(&(*mutex)->access_lock); + _SPINLOCK(&(*mutex)->lock); } } break; @@ -273,13 +275,13 @@ pthread_mutex_lock(pthread_mutex_t * mutex) _thread_queue_enq(&(*mutex)->m_queue, _thread_run); /* Unlock the mutex structure: */ - _atomic_unlock(&(*mutex)->access_lock); + _SPINUNLOCK(&(*mutex)->lock); /* Block signals: */ _thread_kern_sched_state(PS_MUTEX_WAIT, __FILE__, __LINE__); /* Lock the mutex again: */ - _spinlock(&(*mutex)->access_lock); + _SPINLOCK(&(*mutex)->lock); } } @@ -295,7 +297,7 @@ pthread_mutex_lock(pthread_mutex_t * mutex) } /* Unlock the mutex structure: */ - _atomic_unlock(&(*mutex)->access_lock); + _SPINUNLOCK(&(*mutex)->lock); } /* Return the completion status: */ @@ -311,7 +313,7 @@ pthread_mutex_unlock(pthread_mutex_t * mutex) ret = EINVAL; } else { /* Lock the mutex structure: */ - _spinlock(&(*mutex)->access_lock); + _SPINLOCK(&(*mutex)->lock); /* Process according to mutex type: */ switch ((*mutex)->m_type) { @@ -362,7 +364,7 @@ pthread_mutex_unlock(pthread_mutex_t * mutex) } /* Unlock the mutex structure: */ - _atomic_unlock(&(*mutex)->access_lock); + _SPINUNLOCK(&(*mutex)->lock); } /* Return the completion status: */ |