source: trunk/include/win/thread.h@ 281

Last change on this file since 281 was 281, checked in by sandervl, 26 years ago

Major changes in PE2LX/KERNEL32 for TLS support. DLL VERSION INCREASED TO 3 AS THIS CHANGE MAKES IT INCOMPATIBLE WITH APPS CONVERTED WITH PREVIOUS VERSION OF PE2LX (OR WIN32K)

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