summaryrefslogtreecommitdiff
path: root/lib/glthread/lock.c
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2019-06-20 04:10:39 +0200
committerBruno Haible <bruno@clisp.org>2019-06-20 04:11:36 +0200
commit4570a616244efbc2fa4bd8788f27ef0e4b48bdbe (patch)
treecbf0915c933748bafc49b5ebebd5f26193b8657f /lib/glthread/lock.c
parent2535ce3ac9fdd46ec44b0fa5f1e4f6dcaaaebd99 (diff)
downloadgnulib-4570a616244efbc2fa4bd8788f27ef0e4b48bdbe.tar.gz
windows-recmutex: New module.
* lib/windows-recmutex.h: New file, extracted from lib/glthread/lock.h. * lib/windows-recmutex.c: New file, extracted from lib/glthread/lock.c. * lib/glthread/lock.h: Include windows-recmutex.h. (gl_recursive_lock_t): Define using glwthread_recmutex_t. (gl_recursive_lock_initializer): Define using GLWTHREAD_RECMUTEX_INIT. (glthread_recursive_lock_init): Define using glwthread_recmutex_init. (glthread_recursive_lock_lock): Define using glwthread_recmutex_lock. (glthread_recursive_lock_unlock): Define using glwthread_recmutex_unlock. (glthread_recursive_lock_destroy): Define using glwthread_recmutex_destroy. (glthread_recursive_lock_init_func, glthread_recursive_lock_lock_func, glthread_recursive_lock_unlock_func, glthread_recursive_lock_destroy_func): Remove declarations. * lib/glthread/lock.c (glthread_recursive_lock_init_func, glthread_recursive_lock_lock_func, glthread_recursive_lock_unlock_func, glthread_recursive_lock_destroy_func): Remove functions. * modules/windows-recmutex: New file. * modules/lock (Depends-on): Add windows-recmutex.
Diffstat (limited to 'lib/glthread/lock.c')
-rw-r--r--lib/glthread/lock.c70
1 files changed, 0 insertions, 70 deletions
diff --git a/lib/glthread/lock.c b/lib/glthread/lock.c
index e17f524ca1..a686a306d6 100644
--- a/lib/glthread/lock.c
+++ b/lib/glthread/lock.c
@@ -1073,76 +1073,6 @@ glthread_rwlock_destroy_func (gl_rwlock_t *lock)
return 0;
}
-/* --------------------- gl_recursive_lock_t datatype --------------------- */
-
-void
-glthread_recursive_lock_init_func (gl_recursive_lock_t *lock)
-{
- lock->owner = 0;
- lock->depth = 0;
- InitializeCriticalSection (&lock->lock);
- lock->guard.done = 1;
-}
-
-int
-glthread_recursive_lock_lock_func (gl_recursive_lock_t *lock)
-{
- if (!lock->guard.done)
- {
- if (InterlockedIncrement (&lock->guard.started) == 0)
- /* This thread is the first one to need this lock. Initialize it. */
- glthread_recursive_lock_init (lock);
- else
- {
- /* Don't let lock->guard.started grow and wrap around. */
- InterlockedDecrement (&lock->guard.started);
- /* Yield the CPU while waiting for another thread to finish
- initializing this lock. */
- while (!lock->guard.done)
- Sleep (0);
- }
- }
- {
- DWORD self = GetCurrentThreadId ();
- if (lock->owner != self)
- {
- EnterCriticalSection (&lock->lock);
- lock->owner = self;
- }
- if (++(lock->depth) == 0) /* wraparound? */
- {
- lock->depth--;
- return EAGAIN;
- }
- }
- return 0;
-}
-
-int
-glthread_recursive_lock_unlock_func (gl_recursive_lock_t *lock)
-{
- if (lock->owner != GetCurrentThreadId ())
- return EPERM;
- if (lock->depth == 0)
- return EINVAL;
- if (--(lock->depth) == 0)
- {
- lock->owner = 0;
- LeaveCriticalSection (&lock->lock);
- }
- return 0;
-}
-
-int
-glthread_recursive_lock_destroy_func (gl_recursive_lock_t *lock)
-{
- if (lock->owner != 0)
- return EBUSY;
- DeleteCriticalSection (&lock->lock);
- lock->guard.done = 0;
- return 0;
-}
-
#endif
/* ========================================================================= */