Initial revision
[cacao.git] / alpha / threads.h
1 /*
2  * i386/threads.h
3  * i386 threading information.
4  *
5  * Copyright (c) 1996 T. J. Wilkinson & Associates, London, UK.
6  *
7  * See the file "license.terms" for information on usage and redistribution
8  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
9  *
10  * Copyright (c) 1997 A. Krall, R. Grafl, M. Gschwind, M. Probst
11  * 
12  * See file COPYRIGHT for information on usage and disclaimer of warranties
13  *
14  * Written by Tim Wilkinson <tim@tjwassoc.demon.co.uk>, 1996.
15  */
16
17 #ifndef __alpha_threads_h
18 #define __alpha_threads_h
19
20 /**/
21 /* Thread handling */
22 /**/
23
24 #include "../threads/thread.h"
25
26 void perform_alpha_threadswitch (u1 **from, u1 **to);
27 u1* initialize_thread_stack (void *func, u1 *stack);
28 u1* used_stack_top (void);
29
30 #define THREADSTACKSIZE         (64 * 1024)
31
32 #define THREADSWITCH(to, from)     perform_alpha_threadswitch(&(from)->restorePoint,\
33                                                               &(to)->restorePoint)
34
35 #define THREADINIT(to, func)       (to)->restorePoint = \
36                                      initialize_thread_stack((u1*)(func), \
37                                                              (to)->stackEnd)
38
39 #define USEDSTACKTOP(top)          (top) = used_stack_top()
40
41 #define THREADINFO(ee)                                          \
42                 do {                                            \
43                         (ee)->restorePoint = 0;                 \
44                         (ee)->flags = THREAD_FLAGS_NOSTACKALLOC;\
45                 } while(0)
46
47 /*
48                         void* ptr;                              \
49                         asm("addq $30,$31,%0" : "=r" (ptr));    \
50                         (ee)->stackEnd = ptr;                   \
51                         (ee)->stackBase = (ee)->stackEnd - threadStackSize;\
52 */
53
54 /*
55 #define THREADFRAMES(tid, cnt)                                  \
56                 do {                                            \
57                         void** ptr;                             \
58                         cnt = 0;                                \
59                         if (tid == currentThread) {             \
60                                 asm("movl %%ebp,%0" : "=r" (ptr));\
61                         }                                       \
62                         else {                                  \
63                                 ptr = ((void***)tid->PrivateInfo->restorePoint)[2];\
64                         }                                       \
65                         while (*ptr != 0) {                     \
66                                 cnt++;                          \
67                                 ptr = (void**)*ptr;             \
68                         }                                       \
69                 } while (0)
70 */
71
72 #endif