Add unit test for AggregateException.GetBaseException that works on .net but is broke...
[mono.git] / mono / io-layer / threads.h
1 /*
2  * threads.h:  Thread handles
3  *
4  * Author:
5  *      Dick Porter (dick@ximian.com)
6  *
7  * (C) 2002 Ximian, Inc.
8  */
9
10 #ifndef _WAPI_THREADS_H_
11 #define _WAPI_THREADS_H_
12
13 #include <glib.h>
14
15 #include <mono/io-layer/handles.h>
16 #include <mono/io-layer/io.h>
17 #include <mono/io-layer/status.h>
18 #include <mono/io-layer/processes.h>
19 #include <mono/io-layer/access.h>
20
21 G_BEGIN_DECLS
22
23 #define TLS_MINIMUM_AVAILABLE 64
24 #define TLS_OUT_OF_INDEXES 0xFFFFFFFF
25
26 #define STILL_ACTIVE STATUS_PENDING
27
28
29 #define THREAD_TERMINATE                0x0001
30 #define THREAD_SUSPEND_RESUME           0x0002
31 #define THREAD_GET_CONTEXT              0x0008
32 #define THREAD_SET_CONTEXT              0x0010
33 #define THREAD_SET_INFORMATION          0x0020
34 #define THREAD_QUERY_INFORMATION        0x0040
35 #define THREAD_SET_THREAD_TOKEN         0x0080
36 #define THREAD_IMPERSONATE              0x0100
37 #define THREAD_DIRECT_IMPERSONATION     0x0200
38 #define THREAD_ALL_ACCESS               (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3ff)
39
40 typedef guint32 (*WapiThreadStart)(gpointer);
41 typedef guint32 (*WapiApcProc)(gpointer);
42
43 /* 
44  * The 'tid' argument has a different type than in win32, which breaks on win64.
45  * Runtime code shouldn't use this, use the mono_thread_create () function in
46  * metadata instead.
47  */
48 extern gpointer CreateThread(WapiSecurityAttributes *security,
49                              guint32 stacksize, WapiThreadStart start,
50                              gpointer param, guint32 create, gsize *tid); /* NB tid is 32bit in MS API */
51 extern gpointer OpenThread (guint32 access, gboolean inherit, gsize tid); /* NB tid is 32bit in MS API */
52 extern void ExitThread(guint32 exitcode) G_GNUC_NORETURN;
53 extern gboolean GetExitCodeThread(gpointer handle, guint32 *exitcode);
54 extern gsize GetCurrentThreadId(void); /* NB return is 32bit in MS API */
55 extern gpointer GetCurrentThread(void);
56 extern guint32 ResumeThread(gpointer handle);
57 extern guint32 SuspendThread(gpointer handle);
58 extern void Sleep(guint32 ms);
59 extern guint32 SleepEx(guint32 ms, gboolean alertable);
60 extern guint32 QueueUserAPC (WapiApcProc apc_callback, gpointer thread_handle, 
61                                         gpointer param);
62
63 /* Kludge alert! Making this visible outside io-layer is broken, but I
64  * can't find any w32 call that will let me do this.
65  */
66 extern void _wapi_thread_signal_self (guint32 exitstatus);
67
68 void wapi_interrupt_thread (gpointer handle);
69 void wapi_clear_interruption (void);
70 gboolean wapi_thread_set_wait_handle (gpointer handle);
71 void wapi_thread_clear_wait_handle (gpointer handle);
72 void wapi_self_interrupt (void);
73
74 gpointer wapi_prepare_interrupt_thread (gpointer thread_handle);
75 void wapi_finish_interrupt_thread (gpointer wait_handle);
76
77
78 char* wapi_current_thread_desc (void);
79
80 G_END_DECLS
81 #endif /* _WAPI_THREADS_H_ */