Added specific routines for OUTPUT_DEBUG_STRING and EXCEPTION debug events.
[wine.git] / server / thread.h
blob198b77d2e849483ff98aa50fff74d48a24de5a6e
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 "object.h"
16 /* thread structure */
18 struct process;
19 struct thread_wait;
20 struct thread_apc;
21 struct mutex;
22 struct debug_ctx;
24 enum run_state
26 RUNNING, /* running normally */
27 TERMINATED /* terminated */
31 struct thread
33 struct object obj; /* object header */
34 struct thread *next; /* system-wide thread list */
35 struct thread *prev;
36 struct thread *proc_next; /* per-process thread list */
37 struct thread *proc_prev;
38 struct process *process;
39 struct mutex *mutex; /* list of currently owned mutexes */
40 struct debug_ctx *debug_ctx; /* debugger context if this thread is a debugger */
41 struct thread_wait *wait; /* current wait condition if sleeping */
42 struct thread_apc *apc; /* list of async procedure calls */
43 int apc_count; /* number of outstanding APCs */
44 int error; /* current error code */
45 int pass_fd; /* fd to pass to the client */
46 enum run_state state; /* running state */
47 int attached; /* is thread attached with ptrace? */
48 int exit_code; /* thread exit code */
49 int unix_pid; /* Unix pid of client */
50 CONTEXT *context; /* current context if in an exception handler */
51 void *teb; /* TEB address (in client address space) */
52 void *entry; /* thread entry point (in client address space) */
53 int priority; /* priority level */
54 int affinity; /* affinity mask */
55 int suspend; /* suspend count */
56 void *buffer; /* buffer for communication with the client */
57 enum request last_req; /* last request received (for debugging) */
60 /* callback function for building the thread reply when sleep_on is finished */
61 typedef void (*sleep_reply)( struct thread *thread, struct object *obj, int signaled );
63 extern struct thread *current;
65 /* thread functions */
67 extern struct thread *create_thread( int fd, struct process *process, int suspend );
68 extern struct thread *get_thread_from_id( void *id );
69 extern struct thread *get_thread_from_handle( int handle, unsigned int access );
70 extern struct thread *get_thread_from_pid( int pid );
71 extern int suspend_thread( struct thread *thread, int check_limit );
72 extern int resume_thread( struct thread *thread );
73 extern void suspend_all_threads( void );
74 extern void resume_all_threads( void );
75 extern int add_queue( struct object *obj, struct wait_queue_entry *entry );
76 extern void remove_queue( struct object *obj, struct wait_queue_entry *entry );
77 extern void kill_thread( struct thread *thread, int exit_code );
78 extern void wake_up( struct object *obj, int max );
79 extern int sleep_on( int count, struct object *objects[], int flags,
80 int timeout, sleep_reply func );
82 /* ptrace functions */
84 extern void sigchld_handler();
85 extern void wait4_thread( struct thread *thread, int signal );
86 extern void stop_thread( struct thread *thread );
87 extern void continue_thread( struct thread *thread );
88 extern void detach_thread( struct thread *thread );
89 extern int read_thread_int( struct thread *thread, const int *addr, int *data );
90 extern int write_thread_int( struct thread *thread, int *addr, int data, unsigned int mask );
93 static inline int get_error(void) { return current->error; }
94 static inline void set_error( int err ) { current->error = err; }
95 static inline void clear_error(void) { set_error(0); }
97 static inline void *get_thread_id( struct thread *thread ) { return thread; }
99 #endif /* __WINE_SERVER_THREAD_H */