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)
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 ***********************************************************************/
19 #endif /* __cplusplus */
22 #include "freeciv_config.h"
25 #include "support.h" /* bool */
27 #ifdef FREECIV_HAVE_TINYCTHR
28 #include "tinycthread.h"
29 #define FREECIV_C11_THR
31 #ifdef FREECIV_HAVE_C11_THREADS
33 #define FREECIV_C11_THR
34 #endif /* FREECIV_HAVE_C11_THREADS */
35 #endif /* FREECIV_hAVE_TINYCTHR */
37 #ifdef FREECIV_C11_THR
39 #define fc_thread thrd_t
40 #define fc_mutex mtx_t
41 #define fc_thread_cond cnd_t
43 #elif defined(FREECIV_HAVE_PTHREAD)
47 #define fc_thread pthread_t
48 #define fc_mutex pthread_mutex_t
49 #define fc_thread_cond pthread_cond_t
51 #elif defined (FREECIV_HAVE_WINTHREADS)
54 #define fc_thread HANDLE *
55 #define fc_mutex HANDLE *
57 #ifndef FREECIV_HAVE_THREAD_COND
58 #define fc_thread_cond char
59 #else /* FREECIV_HAVE_THREAD_COND */
60 #warning FREECIV_HAVE_THREAD_COND defined but we have no real Windows implementation
61 #endif /* FREECIV_HAVE_THREAD_COND */
63 #else /* No pthreads nor winthreads */
65 #error "No working thread implementation"
67 #endif /* FREECIV_HAVE_PTHREAD */
69 int fc_thread_start(fc_thread
*thread
, void (*function
) (void *arg
), void *arg
);
70 void fc_thread_wait(fc_thread
*thread
);
72 void fc_init_mutex(fc_mutex
*mutex
);
73 void fc_destroy_mutex(fc_mutex
*mutex
);
74 void fc_allocate_mutex(fc_mutex
*mutex
);
75 void fc_release_mutex(fc_mutex
*mutex
);
77 void fc_thread_cond_init(fc_thread_cond
*cond
);
78 void fc_thread_cond_destroy(fc_thread_cond
*cond
);
79 void fc_thread_cond_wait(fc_thread_cond
*cond
, fc_mutex
*mutex
);
80 void fc_thread_cond_signal(fc_thread_cond
*cond
);
82 bool has_thread_cond_impl(void);
86 #endif /* __cplusplus */
88 #endif /* FC__THREAD_H */