Support VERSION_REVTYPE git builds on cleanup_checkout.sh
[freeciv.git] / utility / fcthread.h
blob93bffdd725b4256ecdc9173f0986cec8ab37aa8f
1 /**********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 ***********************************************************************/
14 #ifndef FC__THREAD_H
15 #define FC__THREAD_H
17 #ifdef __cplusplus
18 extern "C" {
19 #endif /* __cplusplus */
21 /* gen_headers */
22 #include "freeciv_config.h"
24 /* utility */
25 #include "support.h" /* bool */
27 #ifdef FREECIV_HAVE_C11_THREADS
29 #include <threads.h>
31 #define fc_thread thrd_t
32 #define fc_mutex mtx_t
33 #define fc_thread_cond cnd_t
35 #elif defined(FREECIV_HAVE_PTHREAD)
37 #include <pthread.h>
39 #define fc_thread pthread_t
40 #define fc_mutex pthread_mutex_t
41 #define fc_thread_cond pthread_cond_t
43 #elif defined (FREECIV_HAVE_WINTHREADS)
45 #include <windows.h>
46 #define fc_thread HANDLE *
47 #define fc_mutex HANDLE *
49 #ifndef FREECIV_HAVE_THREAD_COND
50 #define fc_thread_cond char
51 #else /* FREECIV_HAVE_THREAD_COND */
52 #warning FREECIV_HAVE_THREAD_COND defined but we have no real Windows implementation
53 #endif /* FREECIV_HAVE_THREAD_COND */
55 #else /* No pthreads nor winthreads */
57 #error "No working thread implementation"
59 #endif /* FREECIV_HAVE_PTHREAD */
61 int fc_thread_start(fc_thread *thread, void (*function) (void *arg), void *arg);
62 void fc_thread_wait(fc_thread *thread);
64 void fc_init_mutex(fc_mutex *mutex);
65 void fc_destroy_mutex(fc_mutex *mutex);
66 void fc_allocate_mutex(fc_mutex *mutex);
67 void fc_release_mutex(fc_mutex *mutex);
69 void fc_thread_cond_init(fc_thread_cond *cond);
70 void fc_thread_cond_destroy(fc_thread_cond *cond);
71 void fc_thread_cond_wait(fc_thread_cond *cond, fc_mutex *mutex);
72 void fc_thread_cond_signal(fc_thread_cond *cond);
74 bool has_thread_cond_impl(void);
76 #ifdef __cplusplus
78 #endif /* __cplusplus */
80 #endif /* FC__THREAD_H */