64-bit nonsense
This commit is contained in:
parent
ded42a6ea9
commit
8650250482
1 changed files with 19 additions and 3 deletions
|
|
@ -77,11 +77,16 @@ procalloc(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
threadstart(void *v)
|
threadstart(uint y, uint x)
|
||||||
{
|
{
|
||||||
_Thread *t;
|
_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);
|
//print("threadstart %p\n", v);
|
||||||
t->startfn(t->startarg);
|
t->startfn(t->startarg);
|
||||||
//print("threadexits %p\n", v);
|
//print("threadexits %p\n", v);
|
||||||
|
|
@ -94,6 +99,8 @@ threadalloc(void (*fn)(void*), void *arg, uint stack)
|
||||||
{
|
{
|
||||||
_Thread *t;
|
_Thread *t;
|
||||||
sigset_t zero;
|
sigset_t zero;
|
||||||
|
uint x, y;
|
||||||
|
ulong z;
|
||||||
|
|
||||||
/* allocate the task and stack together */
|
/* allocate the task and stack together */
|
||||||
t = malloc(sizeof *t+stack);
|
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
|
(char*)t->context.uc.uc_stack.ss_sp
|
||||||
+t->context.uc.uc_stack.ss_size;
|
+t->context.uc.uc_stack.ss_size;
|
||||||
#endif
|
#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;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue