alpha.c 664 B

1234567891011121314151617181920212223242526272829303132
  1. #include <u.h>
  2. #include <libc.h>
  3. #include <thread.h>
  4. #include "threadimpl.h"
  5. /* first argument goes in a register and on the stack; avoid it */
  6. static void
  7. launcheralpha(int, void (*f)(void *arg), void *arg)
  8. {
  9. (*f)(arg);
  10. threadexits(nil);
  11. }
  12. void
  13. _threadinitstack(Thread *t, void (*f)(void*), void *arg)
  14. {
  15. ulong *tos;
  16. tos = (ulong*)&t->stk[t->stksize&~7];
  17. *--tos = 0; /* pad arguments to 8 bytes */
  18. *--tos = (ulong)arg;
  19. *--tos = (ulong)f;
  20. *--tos = 0; /* first arg */
  21. *--tos = 0; /* for alignment with... */
  22. *--tos = 0; /* ... place to store return PC */
  23. t->sched[JMPBUFPC] = (ulong)launcheralpha+JMPBUFDPC;
  24. t->sched[JMPBUFSP] = (ulong)tos;
  25. }