This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
AIX patch (including Configure support for {sched,pthread}_yield,
[perl5.git] / fakethr.h
CommitLineData
d6949db4
MB
1typedef int perl_mutex;
2typedef int perl_key;
3
52e1cb5e 4typedef struct perl_thread *perl_os_thread;
ea0efc06
MB
5/* With fake threads, thr is global(ish) so we don't need dTHR */
6#define dTHR extern int errno
7
d6949db4 8struct perl_wait_queue {
52e1cb5e 9 struct perl_thread * thread;
d6949db4
MB
10 struct perl_wait_queue * next;
11};
12typedef struct perl_wait_queue *perl_cond;
13
f826a10b
MB
14/* Ask thread.h to include our per-thread extras */
15#define HAVE_THREAD_INTERN
d6949db4 16struct thread_intern {
51dd5992 17 perl_os_thread next_run, prev_run; /* Linked list of runnable threads */
d6949db4
MB
18 perl_cond wait_queue; /* Wait queue that we are waiting on */
19 IV private; /* Holds data across time slices */
20 I32 savemark; /* Holds MARK for thread join values */
21};
f826a10b
MB
22
23#define init_thread_intern(t) \
24 STMT_START { \
46930d8f 25 t->self = (t); \
f826a10b
MB
26 (t)->i.next_run = (t)->i.prev_run = (t); \
27 (t)->i.wait_queue = 0; \
28 (t)->i.private = 0; \
29 } STMT_END
30
ea0efc06
MB
31/*
32 * Note that SCHEDULE() is only callable from pp code (which
33 * must be expecting to be restarted). We'll have to do
34 * something a bit different for XS code.
35 */
36
37#define SCHEDULE() return schedule(), op
38
39#define MUTEX_LOCK(m)
40#define MUTEX_UNLOCK(m)
41#define MUTEX_INIT(m)
42#define MUTEX_DESTROY(m)
43#define COND_INIT(c) perl_cond_init(c)
44#define COND_SIGNAL(c) perl_cond_signal(c)
45#define COND_BROADCAST(c) perl_cond_broadcast(c)
46#define COND_WAIT(c, m) \
47 STMT_START { \
48 perl_cond_wait(c); \
49 SCHEDULE(); \
50 } STMT_END
51#define COND_DESTROY(c)
52
53#define THREAD_CREATE(t, f) f((t))
54#define THREAD_POST_CREATE(t) NOOP
55
56#define YIELD NOOP