52ad08b7b6383c0fa2b95700fc7e804b2ab4d314
[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, u1 **stackTop);
27 u1* initialize_thread_stack (void *func, u1 *stack);
28 void asm_switchstackandcall (void *stack, void *func);
29
30 #define THREADSTACKSIZE         (32 * 1024)
31
32 #define THREADSWITCH(to, from)     perform_alpha_threadswitch(&(from)->restorePoint,\
33                                                               &(to)->restorePoint, &(from)->usedStackTop)
34
35 #define THREADINIT(to, func)       (to)->restorePoint = \
36                                      initialize_thread_stack((u1*)(func), \
37                                                              (to)->stackEnd)
38
39 #define THREADINFO(ee)                                          \
40                 do {                                            \
41                         (ee)->restorePoint = 0;                 \
42                         (ee)->flags = THREAD_FLAGS_NOSTACKALLOC;\
43                 } while(0)
44
45 /*
46                         void* ptr;                              \
47                         asm("addq $30,$31,%0" : "=r" (ptr));    \
48                         (ee)->stackEnd = ptr;                   \
49                         (ee)->stackBase = (ee)->stackEnd - threadStackSize;\
50 */
51
52 /*
53 #define THREADFRAMES(tid, cnt)                                  \
54                 do {                                            \
55                         void** ptr;                             \
56                         cnt = 0;                                \
57                         if (tid == currentThread) {             \
58                                 asm("movl %%ebp,%0" : "=r" (ptr));\
59                         }                                       \
60                         else {                                  \
61                                 ptr = ((void***)tid->PrivateInfo->restorePoint)[2];\
62                         }                                       \
63                         while (*ptr != 0) {                     \
64                                 cnt++;                          \
65                                 ptr = (void**)*ptr;             \
66                         }                                       \
67                 } while (0)
68 */
69
70 #endif