Release 970101
[wine] / include / thread.h
1 /*
2  * Thread definitions
3  *
4  * Copyright 1996 Alexandre Julliard
5  */
6
7 #ifndef __WINE_THREAD_H
8 #define __WINE_THREAD_H
9
10 #include "process.h"
11
12 /* Thread exception block */
13 typedef struct _TEB
14 {
15     void        *except;         /* 00 Head of exception handling chain */
16     void        *stack_top;      /* 04 Top of thread stack */
17     void        *stack_low;      /* 08 Stack low-water mark */
18     HTASK16      htask16;        /* 0c Win16 task handle */
19     WORD         stack_sel;      /* 0e 16-bit stack selector */
20     DWORD        selman_list;    /* 10 Selector manager list */
21     DWORD        user_ptr;       /* 14 User pointer */
22     struct _TEB *self;           /* 18 Pointer to this structure */
23     WORD         flags;          /* 1c Flags */
24     WORD         mutex_count;    /* 1e Win16 mutex count */
25     DWORD        debug_context;  /* 20 Debug context */
26     DWORD       *ppriority;      /* 24 Pointer to current priority */
27     HQUEUE16     queue;          /* 28 Message queue */
28     WORD         pad1;           /* 2a */
29     LPVOID      *tls_ptr;        /* 2c Pointer to TLS array */
30 } TEB;
31
32 /* Thread database */
33 typedef struct _THDB
34 {
35     K32OBJ       header;         /*  00 Kernel object header */
36     PDB32       *process;        /*  08 Process owning this thread */
37     K32OBJ      *event;          /*  0c Thread event */
38     TEB          teb;            /*  10 Thread information block */
39     PDB32       *process2;       /*  40 Same as offset 08 (?) */
40     DWORD        flags;          /*  44 Flags */
41     DWORD        exit_code;      /*  48 Termination status */
42     WORD         teb_sel;        /*  4c Selector to TEB */
43     WORD         emu_sel;        /*  4e 80387 emulator selector */
44     DWORD        unknown1;       /*  50 Unknown */
45     void        *wait_list;      /*  54 Event waiting list */
46     DWORD        unknown2;       /*  58 Unknown */
47     void        *ring0_thread;   /*  5c Pointer to ring 0 thread */
48     void        *ptdbx;          /*  60 Pointer to TDBX structure */
49     void        *stack_base;     /*  64 Base of the stack */
50     void        *exit_stack;     /*  68 Stack pointer on thread exit */
51     void        *emu_data;       /*  6c Related to 80387 emulation */
52     DWORD        last_error;     /*  70 Last error code */
53     void        *debugger_CB;    /*  74 Debugger context block */
54     DWORD        debug_thread;   /*  78 Thread debugging this one (?) */
55     void        *context;        /*  7c Thread register context */
56     DWORD        unknown3[3];    /*  80 Unknown */
57     WORD         current_ss;     /*  8c Another 16-bit stack selector */
58     WORD         pad2;           /*  8e */
59     void        *ss_table;       /*  90 Pointer to info about 16-bit stack */
60     WORD         thunk_ss;       /*  94 Yet another 16-bit stack selector */
61     WORD         pad3;           /*  96 */
62     LPVOID       tls_array[64];  /*  98 Thread local storage */
63     DWORD        delta_priority; /* 198 Priority delta */
64     DWORD        unknown4[7];    /* 19c Unknown */
65     void        *create_data;    /* 1b8 Pointer to creation structure */
66     DWORD        suspend_count;  /* 1bc SuspendThread() counter */
67     DWORD        unknown5[9];    /* 1c0 Unknown */
68     K32OBJ      *crit_section;   /* 1e4 Some critical section */
69     K32OBJ      *win16_mutex;    /* 1e8 Pointer to Win16 mutex */
70     K32OBJ      *win32_mutex;    /* 1ec Pointer to KERNEL32 mutex */
71     K32OBJ      *crit_section2;  /* 1f0 Another critical section */
72     DWORD        unknown6[2];    /* 1f4 Unknown */
73 } THDB;
74
75
76 extern THDB *THREAD_Create( PDB32 *pdb, DWORD stack_size );
77 extern void THREAD_Destroy( K32OBJ *ptr );
78
79 extern THDB *pCurrentThread;
80
81 #endif  /* __WINE_THREAD_H */