summaryrefslogtreecommitdiff
path: root/lib/glthread/cond.h
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2019-06-20 04:13:43 +0200
committerBruno Haible <bruno@clisp.org>2019-06-20 04:15:05 +0200
commit7b7305f41af7c79ab3739704febba7cf171b404a (patch)
treed2884c182e4becf6c2068d1429234717b52d0833 /lib/glthread/cond.h
parentf46ac2b2b4635118957a5718a125016f4ec15a8a (diff)
downloadgnulib-7b7305f41af7c79ab3739704febba7cf171b404a.tar.gz
windows-cond: New module.
* lib/windows-cond.h: New file, based on lib/glthread/cond.h. * lib/windows-cond.c: New file, based on lib/glthread/cond.c. * lib/glthread/cond.h: Include windows-cond.h. (struct gl_waitqueue_link, gl_linked_waitqueue_t): Remove types. (gl_cond_t): Define using glwthread_cond_t. (gl_cond_initializer): Define using GLWTHREAD_COND_INIT. (glthread_cond_init): Define using glwthread_cond_init. (glthread_cond_wait): Define using glwthread_cond_wait. (glthread_cond_timedwait): Define using glwthread_cond_timedwait. (glthread_cond_signal): Define using glwthread_cond_signal. (glthread_cond_broadcast): Define using glwthread_cond_broadcast. (glthread_cond_destroy): Define using glwthread_cond_destroy. (glthread_cond_init_func, glthread_cond_wait_func, glthread_cond_timedwait_func, glthread_cond_signal_func, glthread_cond_broadcast_func, glthread_cond_destroy_func): Remove declarations. * lib/glthread/cond.c (gl_waitqueue_t, gl_waitqueue_element): Remove types. (gl_waitqueue_init, gl_waitqueue_add, gl_waitqueue_remove, gl_waitqueue_notify_first, gl_waitqueue_notify_all, glthread_cond_init_func, glthread_cond_wait_func, glthread_cond_timedwait_func, glthread_cond_signal_func, glthread_cond_broadcast_func, glthread_cond_destroy_func): Remove functions. * modules/windows-cond: New file. * modules/cond (Depends-on): Add windows-cond. Remove gettimeofday.
Diffstat (limited to 'lib/glthread/cond.h')
-rw-r--r--lib/glthread/cond.h45
1 files changed, 15 insertions, 30 deletions
diff --git a/lib/glthread/cond.h b/lib/glthread/cond.h
index f252c329cc..8880b078e8 100644
--- a/lib/glthread/cond.h
+++ b/lib/glthread/cond.h
@@ -293,53 +293,38 @@ extern int glthread_cond_timedwait_multithreaded (gl_cond_t *cond, gl_lock_t *lo
# define WIN32_LEAN_AND_MEAN /* avoid including junk */
# include <windows.h>
+# include "windows-cond.h"
+
# ifdef __cplusplus
extern "C" {
# endif
/* -------------------------- gl_cond_t datatype -------------------------- */
-struct gl_waitqueue_link
-{
- struct gl_waitqueue_link *wql_next;
- struct gl_waitqueue_link *wql_prev;
-};
-typedef struct
- {
- struct gl_waitqueue_link wq_list; /* circular list of waiting threads */
- }
- gl_linked_waitqueue_t;
-typedef struct
- {
- glwthread_spinlock_t guard; /* protects the initialization */
- CRITICAL_SECTION lock; /* protects the remaining fields */
- gl_linked_waitqueue_t waiters; /* waiting threads */
- }
- gl_cond_t;
+typedef glwthread_cond_t gl_cond_t;
# define gl_cond_define(STORAGECLASS, NAME) \
STORAGECLASS gl_cond_t NAME;
# define gl_cond_define_initialized(STORAGECLASS, NAME) \
STORAGECLASS gl_cond_t NAME = gl_cond_initializer;
# define gl_cond_initializer \
- { { 0, -1 } }
+ GLWTHREAD_COND_INIT
# define glthread_cond_init(COND) \
- glthread_cond_init_func (COND)
+ glwthread_cond_init (COND)
# define glthread_cond_wait(COND, LOCK) \
- glthread_cond_wait_func (COND, LOCK)
+ glwthread_cond_wait (COND, LOCK, \
+ (int (*) (void *)) glwthread_mutex_lock, \
+ (int (*) (void *)) glwthread_mutex_unlock)
# define glthread_cond_timedwait(COND, LOCK, ABSTIME) \
- glthread_cond_timedwait_func (COND, LOCK, ABSTIME)
+ glwthread_cond_timedwait (COND, LOCK, \
+ (int (*) (void *)) glwthread_mutex_lock, \
+ (int (*) (void *)) glwthread_mutex_unlock, \
+ ABSTIME)
# define glthread_cond_signal(COND) \
- glthread_cond_signal_func (COND)
+ glwthread_cond_signal (COND)
# define glthread_cond_broadcast(COND) \
- glthread_cond_broadcast_func (COND)
+ glwthread_cond_broadcast (COND)
# define glthread_cond_destroy(COND) \
- glthread_cond_destroy_func (COND)
-extern int glthread_cond_init_func (gl_cond_t *cond);
-extern int glthread_cond_wait_func (gl_cond_t *cond, gl_lock_t *lock);
-extern int glthread_cond_timedwait_func (gl_cond_t *cond, gl_lock_t *lock, struct timespec *abstime);
-extern int glthread_cond_signal_func (gl_cond_t *cond);
-extern int glthread_cond_broadcast_func (gl_cond_t *cond);
-extern int glthread_cond_destroy_func (gl_cond_t *cond);
+ glwthread_cond_destroy (COND)
# ifdef __cplusplus
}