RE: [PATCH] compress 2.018
[p5sagit/p5-mst-13.2.git] / fakethr.h
CommitLineData
d6376244 1/* fakethr.h
2 *
4bb101f2 3 * Copyright (C) 1999, by Larry Wall and others
d6376244 4 *
5 * You may distribute under the terms of either the GNU General Public
6 * License or the Artistic License, as specified in the README file.
7 *
8 */
9
d6949db4 10typedef int perl_mutex;
11typedef int perl_key;
12
52e1cb5e 13typedef struct perl_thread *perl_os_thread;
ea0efc06 14/* With fake threads, thr is global(ish) so we don't need dTHR */
15#define dTHR extern int errno
16
d6949db4 17struct perl_wait_queue {
52e1cb5e 18 struct perl_thread * thread;
d6949db4 19 struct perl_wait_queue * next;
20};
21typedef struct perl_wait_queue *perl_cond;
22
f826a10b 23/* Ask thread.h to include our per-thread extras */
24#define HAVE_THREAD_INTERN
d6949db4 25struct thread_intern {
51dd5992 26 perl_os_thread next_run, prev_run; /* Linked list of runnable threads */
d6949db4 27 perl_cond wait_queue; /* Wait queue that we are waiting on */
28 IV private; /* Holds data across time slices */
29 I32 savemark; /* Holds MARK for thread join values */
30};
f826a10b 31
32#define init_thread_intern(t) \
33 STMT_START { \
46930d8f 34 t->self = (t); \
f826a10b 35 (t)->i.next_run = (t)->i.prev_run = (t); \
36 (t)->i.wait_queue = 0; \
37 (t)->i.private = 0; \
38 } STMT_END
39
ea0efc06 40/*
41 * Note that SCHEDULE() is only callable from pp code (which
42 * must be expecting to be restarted). We'll have to do
43 * something a bit different for XS code.
44 */
45
6b88bc9c 46#define SCHEDULE() return schedule(), PL_op
ea0efc06 47
48#define MUTEX_LOCK(m)
49#define MUTEX_UNLOCK(m)
50#define MUTEX_INIT(m)
51#define MUTEX_DESTROY(m)
52#define COND_INIT(c) perl_cond_init(c)
53#define COND_SIGNAL(c) perl_cond_signal(c)
54#define COND_BROADCAST(c) perl_cond_broadcast(c)
55#define COND_WAIT(c, m) \
56 STMT_START { \
57 perl_cond_wait(c); \
58 SCHEDULE(); \
59 } STMT_END
60#define COND_DESTROY(c)
61
62#define THREAD_CREATE(t, f) f((t))
63#define THREAD_POST_CREATE(t) NOOP
64
65#define YIELD NOOP
e9a8c099 66
67/*
68 * Local variables:
69 * c-indentation-style: bsd
70 * c-basic-offset: 4
71 * indent-tabs-mode: t
72 * End:
73 *
74 * ex: set ts=8 sts=4 sw=4 noet:
75 */