aboutsummaryrefslogtreecommitdiff
path: root/src/libthread/thread.c
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2005-01-18 05:57:35 +0000
committerrsc <devnull@localhost>2005-01-18 05:57:35 +0000
commit86502504820d9626542a310fd48b50ff760ec279 (patch)
tree0a2c0e06500940d73b306b153ddba196eddd434f /src/libthread/thread.c
parentded42a6ea9fe737c4a6ce18f318086740401cc16 (diff)
downloadplan9port-86502504820d9626542a310fd48b50ff760ec279.tar.gz
plan9port-86502504820d9626542a310fd48b50ff760ec279.tar.bz2
plan9port-86502504820d9626542a310fd48b50ff760ec279.zip
64-bit nonsense
Diffstat (limited to 'src/libthread/thread.c')
-rw-r--r--src/libthread/thread.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/libthread/thread.c b/src/libthread/thread.c
index 6c31cb76..dfc0acdf 100644
--- a/src/libthread/thread.c
+++ b/src/libthread/thread.c
@@ -77,11 +77,16 @@ procalloc(void)
}
static void
-threadstart(void *v)
+threadstart(uint y, uint x)
{
_Thread *t;
+ ulong z;
+
+ z = x<<16; /* hide undefined 32-bit shift from 32-bit compilers */
+ z <<= 16;
+ z |= y;
+ t = (_Thread*)z;
- t = v;
//print("threadstart %p\n", v);
t->startfn(t->startarg);
//print("threadexits %p\n", v);
@@ -94,6 +99,8 @@ threadalloc(void (*fn)(void*), void *arg, uint stack)
{
_Thread *t;
sigset_t zero;
+ uint x, y;
+ ulong z;
/* allocate the task and stack together */
t = malloc(sizeof *t+stack);
@@ -125,7 +132,16 @@ threadalloc(void (*fn)(void*), void *arg, uint stack)
(char*)t->context.uc.uc_stack.ss_sp
+t->context.uc.uc_stack.ss_size;
#endif
- makecontext(&t->context.uc, (void(*)())threadstart, 1, t);
+ /*
+ * All this magic is because you have to pass makecontext a
+ * function that takes some number of word-sized variables,
+ * and on 64-bit machines pointers are bigger than words.
+ */
+ z = (ulong)t;
+ y = z;
+ z >>= 16; /* hide undefined 32-bit shift from 32-bit compilers */
+ x = z>>16;
+ makecontext(&t->context.uc, (void(*)())threadstart, 2, y, x);
return t;
}