X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=fakethr.h;h=5bbe8ac9061052b1f57f2a44c4d03b39e3f479b1;hb=3fadfdf11dfb17421538d2f4280b4d99a5c6cb5a;hp=dac2cc9030a688f31e63b929436a72c8b4699306;hpb=f826a10b5944692b2da706f4a0ac5056f28e8c6d;p=p5sagit%2Fp5-mst-13.2.git diff --git a/fakethr.h b/fakethr.h index dac2cc9..5bbe8ac 100644 --- a/fakethr.h +++ b/fakethr.h @@ -1,8 +1,21 @@ +/* fakethr.h + * + * Copyright (c) 1997-2002, Larry Wall + * + * You may distribute under the terms of either the GNU General Public + * License or the Artistic License, as specified in the README file. + * + */ + typedef int perl_mutex; typedef int perl_key; +typedef struct perl_thread *perl_os_thread; +/* With fake threads, thr is global(ish) so we don't need dTHR */ +#define dTHR extern int errno + struct perl_wait_queue { - struct thread * thread; + struct perl_thread * thread; struct perl_wait_queue * next; }; typedef struct perl_wait_queue *perl_cond; @@ -10,7 +23,7 @@ typedef struct perl_wait_queue *perl_cond; /* Ask thread.h to include our per-thread extras */ #define HAVE_THREAD_INTERN struct thread_intern { - perl_thread next_run, prev_run; /* Linked list of runnable threads */ + perl_os_thread next_run, prev_run; /* Linked list of runnable threads */ perl_cond wait_queue; /* Wait queue that we are waiting on */ IV private; /* Holds data across time slices */ I32 savemark; /* Holds MARK for thread join values */ @@ -18,9 +31,35 @@ struct thread_intern { #define init_thread_intern(t) \ STMT_START { \ - t->Tself = (t); \ + t->self = (t); \ (t)->i.next_run = (t)->i.prev_run = (t); \ (t)->i.wait_queue = 0; \ (t)->i.private = 0; \ } STMT_END +/* + * Note that SCHEDULE() is only callable from pp code (which + * must be expecting to be restarted). We'll have to do + * something a bit different for XS code. + */ + +#define SCHEDULE() return schedule(), PL_op + +#define MUTEX_LOCK(m) +#define MUTEX_UNLOCK(m) +#define MUTEX_INIT(m) +#define MUTEX_DESTROY(m) +#define COND_INIT(c) perl_cond_init(c) +#define COND_SIGNAL(c) perl_cond_signal(c) +#define COND_BROADCAST(c) perl_cond_broadcast(c) +#define COND_WAIT(c, m) \ + STMT_START { \ + perl_cond_wait(c); \ + SCHEDULE(); \ + } STMT_END +#define COND_DESTROY(c) + +#define THREAD_CREATE(t, f) f((t)) +#define THREAD_POST_CREATE(t) NOOP + +#define YIELD NOOP