Ignore generated files.
[wine/multimedia.git] / include / thread.h
blob83ca6fe8a2ac498c8ac3a6c0edd7e15e561f6beb
1 /*
2 * Thread definitions
4 * Copyright 1996 Alexandre Julliard
5 */
7 #ifndef __WINE_THREAD_H
8 #define __WINE_THREAD_H
10 #include "config.h"
11 #include "winbase.h"
12 #include "selectors.h" /* for SET_FS */
14 #ifdef linux
15 #define HAVE_CLONE_SYSCALL
16 #endif
18 /* This is what we will use on *BSD, once threads using rfork() get
19 * implemented:
21 * #if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__)
22 * #define HAVE_RFORK
23 * #endif
26 #if (defined(HAVE_CLONE_SYSCALL) || defined(HAVE_RFORK)) && !defined(NO_REENTRANT_LIBC)
27 #define USE_THREADS
28 #endif
30 struct _PDB;
32 /* Thread exception block */
33 typedef struct _TEB
35 void *except; /* 00 Head of exception handling chain */
36 void *stack_top; /* 04 Top of thread stack */
37 void *stack_low; /* 08 Stack low-water mark */
38 HTASK16 htask16; /* 0c Win16 task handle */
39 WORD stack_sel; /* 0e 16-bit stack selector */
40 DWORD selman_list; /* 10 Selector manager list */
41 DWORD user_ptr; /* 14 User pointer */
42 struct _TEB *self; /* 18 Pointer to this structure */
43 WORD flags; /* 1c Flags */
44 WORD mutex_count; /* 1e Win16 mutex count */
45 DWORD debug_context; /* 20 Debug context */
46 DWORD *ppriority; /* 24 Pointer to current priority */
47 HQUEUE16 queue; /* 28 Message queue */
48 WORD pad1; /* 2a */
49 LPVOID *tls_ptr; /* 2c Pointer to TLS array */
50 struct _PDB *process; /* 30 owning process (used by NT3.51 applets)*/
51 } TEB;
53 /* Thread exception flags */
54 #define TEBF_WIN32 0x0001
55 #define TEBF_TRAP 0x0002
57 /* Thread database */
58 typedef struct _THDB
60 LONG header[2]; /* 00 Kernel object header */
61 struct _PDB *process; /* 08 Process owning this thread */
62 HANDLE event; /* 0c Thread event */
63 TEB teb; /* 10 Thread exception block */
64 DWORD flags; /* 44 Flags */
65 DWORD exit_code; /* 48 Termination status */
66 WORD teb_sel; /* 4c Selector to TEB */
67 WORD emu_sel; /* 4e 80387 emulator selector */
68 int thread_errno; /* 50 Per-thread errno (was: unknown) */
69 void *wait_list; /* 54 Event waiting list */
70 int thread_h_errno; /* 50 Per-thread h_errno (was: unknown) */
71 void *ring0_thread; /* 5c Pointer to ring 0 thread */
72 void *ptdbx; /* 60 Pointer to TDBX structure */
73 void *stack_base; /* 64 Base of the stack */
74 void *exit_stack; /* 68 Stack pointer on thread exit */
75 void *emu_data; /* 6c Related to 80387 emulation */
76 DWORD last_error; /* 70 Last error code */
77 void *debugger_CB; /* 74 Debugger context block */
78 DWORD debug_thread; /* 78 Thread debugging this one (?) */
79 void *pcontext; /* 7c Thread register context */
80 DWORD cur_stack; /* 80 Current stack (was: unknown) */
81 DWORD unknown3[2]; /* 84 Unknown */
82 WORD current_ss; /* 8c Another 16-bit stack selector */
83 WORD pad2; /* 8e */
84 void *ss_table; /* 90 Pointer to info about 16-bit stack */
85 WORD thunk_ss; /* 94 Yet another 16-bit stack selector */
86 WORD pad3; /* 96 */
87 LPVOID tls_array[64]; /* 98 Thread local storage */
88 DWORD delta_priority; /* 198 Priority delta */
89 DWORD unknown4[7]; /* 19c Unknown */
90 void *create_data; /* 1b8 Pointer to creation structure */
91 DWORD suspend_count; /* 1bc SuspendThread() counter */
92 void *entry_point; /* 1c0 Thread entry point (was: unknown) */
93 void *entry_arg; /* 1c4 Entry point arg (was: unknown) */
94 DWORD unknown5[4]; /* 1c8 Unknown */
95 DWORD sys_count[4]; /* 1d8 Syslevel mutex entry counters */
96 CRITICAL_SECTION *sys_mutex[4];/* 1e8 Syslevel mutex pointers */
97 DWORD unknown6[2]; /* 1f8 Unknown */
98 /* The following are Wine-specific fields */
99 int socket; /* 200 Socket for server communication */
100 unsigned int seq; /* Server sequence number */
101 void *server_tid; /* Server id for this thread */
102 struct _THDB *next; /* Global thread list */
103 } THDB;
105 /* The pseudo handle value returned by GetCurrentThread */
106 #define CURRENT_THREAD_PSEUDOHANDLE 0xfffffffe
108 #ifdef __i386__
109 /* On the i386, the current thread is in the %fs register */
110 # define SET_CUR_THREAD(thdb) SET_FS((thdb)->teb_sel)
111 #else
112 extern THDB *pCurrentThread;
113 # define SET_CUR_THREAD(thdb) (pCurrentThread = (thdb))
114 #endif /* __i386__ */
117 /* scheduler/thread.c */
118 extern THDB *THREAD_CreateInitialThread( struct _PDB *pdb );
119 extern THDB *THREAD_Create( struct _PDB *pdb, DWORD stack_size,
120 BOOL alloc_stack16,
121 int *server_thandle, int *server_phandle,
122 LPTHREAD_START_ROUTINE start_addr, LPVOID param );
123 extern THDB *THREAD_Current(void);
124 extern BOOL THREAD_IsWin16( THDB *thdb );
125 extern THDB *THREAD_IdToTHDB( DWORD id );
126 extern void THREAD_Start( THDB *thdb );
127 extern DWORD THREAD_TlsAlloc( THDB *thread );
129 /* scheduler/sysdeps.c */
130 extern int SYSDEPS_SpawnThread( THDB *thread );
131 extern void SYSDEPS_ExitThread(void);
132 extern TEB * WINAPI NtCurrentTeb(void);
134 #endif /* __WINE_THREAD_H */