2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
23 * related information and legal notices. It is expected that any future
24 * projects/authors will amend these files as needed.
28 * empthread.h: Definitions for Empire threading
30 * Known contributors to this file:
39 #include "prototype.h"
50 typedef struct lwpProc empth_t;
51 typedef struct lwpSem empth_sem_t;
52 #define EMPTH_FD_READ LWP_FD_READ
53 #define EMPTH_FD_WRITE LWP_FD_WRITE
54 #define EMPTH_PRINT LWP_PRINT
55 #define EMPTH_STACKCHECK LWP_STACKCHECK
60 #define _MIT_POSIX_THREADS 1
63 #define EMPTH_FD_READ 0x1
64 #define EMPTH_FD_WRITE 0x2
66 #define EMPTH_PRINT 0x1
67 #define EMPTH_STACKCHECK 0x2
69 typedef void (*vf_ptr)();
70 #define EMPTH_KILLED 1
71 typedef struct empth_ctx_t {
72 char *name; /* thread name */
73 char *desc; /* description */
74 void *ud; /* user data */
75 int state; /* my state */
76 vf_ptr ep; /* entry point */
77 pthread_t id; /* thread id */
81 pthread_mutex_t mtx_update; /* use it to update count */
84 pthread_mutex_t mtx_sem;
85 pthread_cond_t cnd_sem;
90 /* DEC has slightly different names for whatever reason... */
92 #define pthread_key_create pthread_keycreate
93 #define pthread_attr_init pthread_attr_create
94 #define pthread_attr_destroy pthread_attr_delete
99 #if defined(_EMPTH_WIN32)
100 /* The Windows NT Threads */
101 #define EMPTH_FD_READ 0x1
102 #define EMPTH_FD_WRITE 0x2
104 #define EMPTH_PRINT 0x1
105 #define EMPTH_STACKCHECK 0x2
107 typedef void empth_t;
109 typedef void empth_sem_t;
113 int empth_init _PROTO((char **ctx, int flags));
114 empth_t *empth_create _PROTO((int, void (*)(), int,
115 int, char *, char *, void *));
116 empth_t *empth_self();
117 void empth_exit _PROTO((void));
118 void empth_yield _PROTO((void));
119 void empth_terminate _PROTO((empth_t *));
120 void empth_select _PROTO((int fd, int flags));
121 void empth_wakeup _PROTO((empth_t *));
122 void empth_sleep _PROTO((long until));
123 empth_sem_t *empth_sem_create _PROTO((char *name, int count));
124 void empth_sem_signal _PROTO((empth_sem_t *));
125 void empth_sem_wait _PROTO((empth_sem_t *));
126 emp_sig_t empth_alarm _PROTO((int));
129 #include "prototypes.h" /* must come at end, after defines and typedefs */