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:
49 typedef struct lwpProc empth_t;
50 typedef struct lwpSem empth_sem_t;
51 #define EMPTH_FD_READ LWP_FD_READ
52 #define EMPTH_FD_WRITE LWP_FD_WRITE
53 #define EMPTH_PRINT LWP_PRINT
54 #define EMPTH_STACKCHECK LWP_STACKCHECK
59 #define _MIT_POSIX_THREADS 1
62 #define EMPTH_FD_READ 0x1
63 #define EMPTH_FD_WRITE 0x2
65 #define EMPTH_PRINT 0x1
66 #define EMPTH_STACKCHECK 0x2
68 #define EMPTH_KILLED 1
69 typedef struct empth_ctx_t {
70 char *name; /* thread name */
71 char *desc; /* description */
72 void *ud; /* user data */
73 int state; /* my state */
74 void (*ep)(void *); /* entry point */
75 pthread_t id; /* thread id */
79 pthread_mutex_t mtx_update; /* use it to update count */
82 pthread_mutex_t mtx_sem;
83 pthread_cond_t cnd_sem;
88 /* DEC has slightly different names for whatever reason... */
90 #define pthread_key_create pthread_keycreate
91 #define pthread_attr_init pthread_attr_create
92 #define pthread_attr_destroy pthread_attr_delete
97 #if defined(_EMPTH_WIN32)
98 /* The Windows NT Threads */
99 #define EMPTH_FD_READ 0x1
100 #define EMPTH_FD_WRITE 0x2
102 #define EMPTH_PRINT 0x1
103 #define EMPTH_STACKCHECK 0x2
105 typedef struct loc_Thread_t empth_t;
106 typedef struct loc_Sem_t void empth_sem_t;
110 int empth_init(char **ctx, int flags);
111 empth_t *empth_create(int, void (*)(void *), int, int, char *, char *, void *);
112 empth_t *empth_self(void);
113 void empth_exit(void);
114 void empth_yield(void);
115 void empth_terminate(empth_t *);
116 void empth_select(int fd, int flags);
117 void empth_wakeup(empth_t *);
118 void empth_sleep(long until);
119 empth_sem_t *empth_sem_create(char *name, int count);
120 void empth_sem_signal(empth_sem_t *);
121 void empth_sem_wait(empth_sem_t *);
122 void empth_alarm(int);
125 #include "prototypes.h" /* must come at end, after defines and typedefs */