Added new CLIENT_DebuggerRequest routine, implemented support for
[wine/testsucceed.git] / include / server / thread.h
blobbc77a37dc4e90c24b0c45ab6ad9f1bb3289bc80b
1 /*
2 * Wine server threads
4 * Copyright (C) 1998 Alexandre Julliard
5 */
7 #ifndef __WINE_SERVER_THREAD_H
8 #define __WINE_SERVER_THREAD_H
10 #ifndef __WINE_SERVER__
11 #error This file can only be used in the Wine server
12 #endif
14 #include "server/object.h"
16 /* thread structure */
18 struct process;
19 struct thread_wait;
20 struct thread_apc;
21 struct mutex;
23 enum run_state { STARTING, RUNNING, TERMINATED };
25 struct thread
27 struct object obj; /* object header */
28 struct thread *next; /* system-wide thread list */
29 struct thread *prev;
30 struct thread *proc_next; /* per-process thread list */
31 struct thread *proc_prev;
32 struct process *process;
33 struct mutex *mutex; /* list of currently owned mutexes */
34 struct thread_wait *wait; /* current wait condition if sleeping */
35 struct thread_apc *apc; /* list of async procedure calls */
36 int apc_count; /* number of outstanding APCs */
37 int error; /* current error code */
38 enum run_state state; /* running state */
39 int exit_code; /* thread exit code */
40 int client_fd; /* client fd for socket communications */
41 int unix_pid; /* Unix pid of client */
42 int priority; /* priority level */
43 int affinity; /* affinity mask */
44 int suspend; /* suspend count */
45 enum request last_req; /* last request received (for debugging) */
48 extern struct thread *current;
50 /* thread functions */
52 extern void create_initial_thread( int fd );
53 extern struct thread *create_thread( int fd, void *pid, int suspend, int inherit, int *handle );
54 extern struct thread *get_thread_from_id( void *id );
55 extern struct thread *get_thread_from_handle( int handle, unsigned int access );
56 extern void get_thread_info( struct thread *thread,
57 struct get_thread_info_reply *reply );
58 extern void set_thread_info( struct thread *thread,
59 struct set_thread_info_request *req );
60 extern int suspend_thread( struct thread *thread );
61 extern int resume_thread( struct thread *thread );
62 extern void suspend_all_threads( void );
63 extern void resume_all_threads( void );
64 extern int send_reply( struct thread *thread, int pass_fd,
65 int n, ... /* arg_1, len_1, ..., arg_n, len_n */ );
66 extern int add_queue( struct object *obj, struct wait_queue_entry *entry );
67 extern void remove_queue( struct object *obj, struct wait_queue_entry *entry );
68 extern int thread_queue_apc( struct thread *thread, void *func, void *param );
69 extern void kill_thread( struct thread *thread, int exit_code );
70 extern void thread_killed( struct thread *thread, int exit_code );
71 extern void thread_timeout(void);
72 extern void sleep_on( struct thread *thread, int count, int *handles,
73 int flags, int timeout );
74 extern void wake_up( struct object *obj, int max );
76 #define GET_ERROR() (current->error)
77 #define SET_ERROR(err) (current->error = (err))
78 #define CLEAR_ERROR() (current->error = 0)
80 #endif /* __WINE_SERVER_THREAD_H */