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