2010-02-13 Jb Evain <jbevain@novell.com>
[mono-project.git] / mono / io-layer / threads.h
blob700e77b55832c23a776250a8874a25183b262464
1 /*
2 * threads.h: Thread handles
4 * Author:
5 * Dick Porter (dick@ximian.com)
7 * (C) 2002 Ximian, Inc.
8 */
10 #ifndef _WAPI_THREADS_H_
11 #define _WAPI_THREADS_H_
13 #include <glib.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>
21 G_BEGIN_DECLS
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 /*
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.
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 guint32 mono_pthread_key_for_tls (guint32 idx);
59 extern guint32 TlsAlloc(void);
60 extern gboolean TlsFree(guint32 idx);
61 extern gpointer TlsGetValue(guint32 idx);
62 extern gboolean TlsSetValue(guint32 idx, gpointer value);
63 extern void Sleep(guint32 ms);
64 extern guint32 SleepEx(guint32 ms, gboolean alertable);
65 extern guint32 QueueUserAPC (WapiApcProc apc_callback, gpointer thread_handle,
66 gpointer param);
68 /* Kludge alert! Making this visible outside io-layer is broken, but I
69 * can't find any w32 call that will let me do this.
71 extern void _wapi_thread_signal_self (guint32 exitstatus);
73 void wapi_interrupt_thread (gpointer handle);
74 void wapi_clear_interruption (void);
75 gboolean wapi_thread_set_wait_handle (gpointer handle);
76 void wapi_thread_clear_wait_handle (gpointer handle);
77 char* wapi_current_thread_desc (void);
79 G_END_DECLS
80 #endif /* _WAPI_THREADS_H_ */