Added DebugBreak.
[wine] / server / thread.h
1 /*
2  * Wine server threads
3  *
4  * Copyright (C) 1998 Alexandre Julliard
5  */
6
7 #ifndef __WINE_SERVER_THREAD_H
8 #define __WINE_SERVER_THREAD_H
9
10 #ifndef __WINE_SERVER__
11 #error This file can only be used in the Wine server
12 #endif
13
14 #include "object.h"
15
16 /* thread structure */
17
18 struct process;
19 struct thread_wait;
20 struct thread_apc;
21 struct mutex;
22 struct debug_ctx;
23 struct debug_event;
24
25 enum run_state { STARTING, RUNNING, TERMINATED };
26
27 struct thread
28 {
29     struct object       obj;       /* object header */
30     struct thread      *next;      /* system-wide thread list */
31     struct thread      *prev;
32     struct thread      *proc_next; /* per-process thread list */
33     struct thread      *proc_prev;
34     struct process     *process;
35     struct mutex       *mutex;       /* list of currently owned mutexes */
36     struct debug_ctx   *debug_ctx;   /* debugger context if this thread is a debugger */
37     struct process     *debug_first; /* head of debugged processes list */
38     struct debug_event *debug_event; /* pending debug event for this thread */
39     struct thread_wait *wait;      /* current wait condition if sleeping */
40     struct thread_apc  *apc;       /* list of async procedure calls */
41     int                 apc_count; /* number of outstanding APCs */
42     int                 error;     /* current error code */
43     enum run_state      state;     /* running state */
44     int                 exit_code; /* thread exit code */
45     struct client      *client;    /* client for socket communications */
46     int                 unix_pid;  /* Unix pid of client */
47     void               *teb;       /* TEB address (in client address space) */
48     int                 priority;  /* priority level */
49     int                 affinity;  /* affinity mask */
50     int                 suspend;   /* suspend count */
51     enum request        last_req;  /* last request received (for debugging) */
52 };
53
54 extern struct thread *current;
55
56 /* thread functions */
57
58 extern void create_initial_thread( int fd );
59 extern struct thread *get_thread_from_id( void *id );
60 extern struct thread *get_thread_from_handle( int handle, unsigned int access );
61 extern void suspend_all_threads( void );
62 extern void resume_all_threads( void );
63 extern int send_reply( struct thread *thread, int pass_fd,
64                        int n, ... /* arg_1, len_1, ..., arg_n, len_n */ );
65 extern int add_queue( struct object *obj, struct wait_queue_entry *entry );
66 extern void remove_queue( struct object *obj, struct wait_queue_entry *entry );
67 extern void kill_thread( struct thread *thread, int exit_code );
68 extern void thread_killed( struct thread *thread, int exit_code );
69 extern void thread_timeout(void);
70 extern void wake_up( struct object *obj, int max );
71
72 #define GET_ERROR()     (current->error)
73 #define SET_ERROR(err)  (current->error = (err))
74 #define CLEAR_ERROR()   (current->error = 0)
75
76 #endif  /* __WINE_SERVER_THREAD_H */