Wed Aug 22 18:35:12 CEST 2007 Paolo Molaro <lupus@ximian.com>
[mono.git] / mono / metadata / sgen-gc.h
1 #ifndef __MONO_SGENGC_H__
2 #define __MONO_SGENGC_H__
3
4 /* pthread impl */
5 #include <pthread.h>
6
7 #define ARCH_THREAD_TYPE pthread_t
8 #define ARCH_GET_THREAD pthread_self
9 #define ARCH_THREAD_EQUALS(a,b) pthread_equal (a, b)
10
11 /*
12  * Recursion is not allowed for the thread lock.
13  */
14 #define LOCK_DECLARE(name) pthread_mutex_t name = PTHREAD_MUTEX_INITIALIZER
15 #define LOCK_INIT(name)
16 #define LOCK_GC pthread_mutex_lock (&gc_mutex)
17 #define UNLOCK_GC pthread_mutex_unlock (&gc_mutex)
18
19 /* non-pthread will need to provide their own version of start/stop */
20 #define USE_SIGNAL_BASED_START_STOP_WORLD 1
21 /* we intercept pthread_create calls to know which threads exist */
22 #define USE_PTHREAD_INTERCEPT 1
23
24 #ifdef __i386__
25 #define ARCH_NUM_REGS 8
26 #define ARCH_STORE_REGS(ptr)    \
27         __asm__ __volatile__(   \
28                 "mov %%ecx, 0x00(%0)\n" \
29                 "mov %%edx, 0x04(%0)\n" \
30                 "mov %%ebx, 0x08(%0)\n" \
31                 "mov %%edi, 0x0c(%0)\n" \
32                 "mov %%esi, 0x10(%0)\n" \
33                 "mov %%ebp, 0x14(%0)\n" \
34                 : "=&a" (ptr)   \
35                 : "0" (cur_thread_regs) \
36                 : "memory"      \
37         )
38
39 #elif defined(__x86_64__)
40 #define ARCH_NUM_REGS 16
41 #define ARCH_STORE_REGS(ptr)    \
42         __asm__ __volatile__(   \
43                 "movq %%rcx, 0x00(%0)\n"        \
44                 "movq %%rdx, 0x08(%0)\n"        \
45                 "movq %%rbx, 0x10(%0)\n"        \
46                 "movq %%rdi, 0x18(%0)\n"        \
47                 "movq %%rsi, 0x20(%0)\n"        \
48                 "movq %%rbp, 0x28(%0)\n"        \
49                 "movq %%r8, 0x30(%0)\n" \
50                 "movq %%r9, 0x38(%0)\n" \
51                 "movq %%r10, 0x40(%0)\n"        \
52                 "movq %%r11, 0x48(%0)\n"        \
53                 "movq %%r12, 0x50(%0)\n"        \
54                 "movq %%r13, 0x58(%0)\n"        \
55                 "movq %%r14, 0x60(%0)\n"        \
56                 "movq %%r15, 0x68(%0)\n"        \
57                 : "=&a" (ptr)   \
58                 : "0" (cur_thread_regs) \
59                 : "memory"      \
60         )
61
62 #endif
63
64 #endif /* __MONO_SGENGC_H__ */
65