2 * threads.h: Thread handles
5 * Dick Porter (dick@ximian.com)
7 * (C) 2002 Ximian, Inc.
10 #ifndef _WAPI_THREADS_H_
11 #define _WAPI_THREADS_H_
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>
23 #define TLS_MINIMUM_AVAILABLE 64
24 #define TLS_OUT_OF_INDEXES 0xFFFFFFFF
26 #define STILL_ACTIVE STATUS_PENDING
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)
40 typedef guint32 (*WapiThreadStart)(gpointer);
41 typedef guint32 (*WapiApcProc)(gpointer);
43 extern gpointer OpenThread (guint32 access, gboolean inherit, gsize tid); /* NB tid is 32bit in MS API */
44 extern void ExitThread(guint32 exitcode) G_GNUC_NORETURN;
45 extern gboolean GetExitCodeThread(gpointer handle, guint32 *exitcode);
46 extern gsize GetCurrentThreadId(void); /* NB return is 32bit in MS API */
47 extern gpointer GetCurrentThread(void);
48 extern void Sleep(guint32 ms);
49 extern guint32 SleepEx(guint32 ms, gboolean alertable);
51 /* Kludge alert! Making this visible outside io-layer is broken, but I
52 * can't find any w32 call that will let me do this.
54 extern void _wapi_thread_signal_self (guint32 exitstatus);
56 void wapi_thread_interrupt_self (void);
57 void wapi_interrupt_thread (gpointer handle);
58 void wapi_clear_interruption (void);
59 gboolean wapi_thread_set_wait_handle (gpointer handle);
60 void wapi_thread_clear_wait_handle (gpointer handle);
61 void wapi_self_interrupt (void);
63 gpointer wapi_prepare_interrupt_thread (gpointer thread_handle);
64 void wapi_finish_interrupt_thread (gpointer wait_handle);
67 char* wapi_current_thread_desc (void);
69 gpointer wapi_create_thread_handle (void);
70 void wapi_thread_handle_set_exited (gpointer handle, guint32 exitstatus);
71 void wapi_ref_thread_handle (gpointer handle);
74 #endif /* _WAPI_THREADS_H_ */