Freeciv-3.2: /fast/freeciv/nightly/S3_2/utility/fcthread.h Source File

Freeciv-3.2

Loading...
Searching...
No Matches
fcthread.h
Go to the documentation of this file.
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.
7
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***********************************************************************/
13
14#ifndef FC__THREAD_H
15#define FC__THREAD_H
16
17#ifdef __cplusplus
18extern "C" {
19#endif /* __cplusplus */
20
21/* gen_headers */
22#include "freeciv_config.h"
23
24/* utility */
25#include "support.h" /* bool */
26
27#ifdef FREECIV_HAVE_TINYCTHR
28#include "fc_tinycthread.h"
29#define FREECIV_C11_THR
30#else
31#ifdef FREECIV_HAVE_C11_THREADS
32#include <threads.h>
33#define FREECIV_C11_THR
34#endif /* FREECIV_HAVE_C11_THREADS */
35#endif /* FREECIV_HAVE_TINYCTHR */
36
37#ifdef FREECIV_C11_THR
38
39#define fc_thread thrd_t
40#define fc_mutex mtx_t
41#define fc_thread_cond cnd_t
42
43#elif defined(FREECIV_HAVE_PTHREAD)
44
45#include <pthread.h>
46
47#define fc_thread pthread_t
48#define fc_mutex pthread_mutex_t
49#define fc_thread_cond pthread_cond_t
50
51#elif defined (FREECIV_HAVE_WINTHREADS)
52
53#include <windows.h>
54#define fc_thread HANDLE *
55#define fc_mutex HANDLE *
56
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 */
62
63#else /* No pthreads nor winthreads */
64
65#error "No working thread implementation"
66
67#endif /* FREECIV_HAVE_PTHREAD */
68
69 int fc_thread_start(fc_thread *thread, void (*function) (void *arg), void *arg);
70 void fc_thread_wait(fc_thread *thread);
71
72 void fc_mutex_init(fc_mutex *mutex);
73 void fc_mutex_destroy(fc_mutex *mutex);
74 void fc_mutex_allocate(fc_mutex *mutex);
75 void fc_mutex_release(fc_mutex *mutex);
76
77void fc_thread_cond_init(fc_thread_cond *cond);
78void fc_thread_cond_destroy(fc_thread_cond *cond);
79void fc_thread_cond_wait(fc_thread_cond *cond, fc_mutex *mutex);
80void fc_thread_cond_signal(fc_thread_cond *cond);
81
82bool has_thread_cond_impl(void);
83
84#ifdef __cplusplus
85}
86#endif /* __cplusplus */
87
88#endif /* FC__THREAD_H */
incite_cost
char * incite_cost
Definition comments.c:74
fc_mutex_allocate
void fc_mutex_allocate(fc_mutex *mutex)
fc_thread_cond_destroy
void fc_thread_cond_destroy(fc_thread_cond *cond)
Definition fcthread.c:385
fc_thread_start
int fc_thread_start(fc_thread *thread, void(*function)(void *arg), void *arg)
fc_mutex_init
void fc_mutex_init(fc_mutex *mutex)
fc_thread_cond_signal
void fc_thread_cond_signal(fc_thread_cond *cond)
Definition fcthread.c:397
fc_thread_cond_wait
void fc_thread_cond_wait(fc_thread_cond *cond, fc_mutex *mutex)
Definition fcthread.c:391
fc_mutex_release
void fc_mutex_release(fc_mutex *mutex)
fc_thread_wait
void fc_thread_wait(fc_thread *thread)
has_thread_cond_impl
bool has_thread_cond_impl(void)
Definition fcthread.c:405
fc_thread_cond_init
void fc_thread_cond_init(fc_thread_cond *cond)
Definition fcthread.c:379
fc_mutex_destroy
void fc_mutex_destroy(fc_mutex *mutex)
support.h