exp2l: Work around a NetBSD 10.0/i386 bug.
[gnulib.git] / lib / windows-cond.h
blobcfc160f5b9165332c0a19ca39c8902e53fcf6bcc
1 /* Condition variables (native Windows implementation).
2 Copyright (C) 2008-2024 Free Software Foundation, Inc.
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 /* Written by Yoann Vandoorselaere <yoann@prelude-ids.org>, 2008.
18 Based on Bruno Haible <bruno@clisp.org> lock.h */
20 #ifndef _WINDOWS_COND_H
21 #define _WINDOWS_COND_H
23 #define WIN32_LEAN_AND_MEAN /* avoid including junk */
24 #include <windows.h>
26 #include <time.h>
28 #include "windows-initguard.h"
30 #ifndef _glwthread_linked_waitqueue_link_defined
31 #define _glwthread_linked_waitqueue_link_defined
32 struct glwthread_waitqueue_link
34 struct glwthread_waitqueue_link *wql_next;
35 struct glwthread_waitqueue_link *wql_prev;
37 #endif /* _glwthread_linked_waitqueue_link_defined */
39 typedef struct
41 struct glwthread_waitqueue_link wq_list; /* circular list of waiting threads */
43 glwthread_linked_waitqueue_t;
45 typedef struct
47 glwthread_initguard_t guard; /* protects the initialization */
48 CRITICAL_SECTION lock; /* protects the remaining fields */
49 glwthread_linked_waitqueue_t waiters; /* waiting threads */
51 glwthread_cond_t;
53 #define GLWTHREAD_COND_INIT { GLWTHREAD_INITGUARD_INIT }
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
59 extern int glwthread_cond_init (glwthread_cond_t *cond);
60 /* Here, to cope with the various types of mutexes, the mutex is a 'void *', and
61 the caller needs to pass the corresponding *_lock and *_unlock functions. */
62 extern int glwthread_cond_wait (glwthread_cond_t *cond,
63 void *mutex,
64 int (*mutex_lock) (void *),
65 int (*mutex_unlock) (void *));
66 extern int glwthread_cond_timedwait (glwthread_cond_t *cond,
67 void *mutex,
68 int (*mutex_lock) (void *),
69 int (*mutex_unlock) (void *),
70 const struct timespec *abstime);
71 extern int glwthread_cond_signal (glwthread_cond_t *cond);
72 extern int glwthread_cond_broadcast (glwthread_cond_t *cond);
73 extern int glwthread_cond_destroy (glwthread_cond_t *cond);
75 #ifdef __cplusplus
77 #endif
79 #endif /* _WINDOWS_COND_H */