-Fixed MESSAGE functions that were thunking down to 16 bits implementation.
[wine] / include / 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 "server/object.h"
15
16 /* thread structure */
17
18 struct process;
19 struct thread_wait;
20 struct thread_apc;
21 struct mutex;
22
23 enum run_state { STARTING, RUNNING, TERMINATED };
24
25 struct thread
26 {
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) */
46     char               *name;
47 };
48
49 extern struct thread *current;
50
51 /* thread functions */
52
53 extern struct thread *create_thread( int fd, void *pid, int *thread_handle,
54                                      int *process_handle );
55 extern struct thread *get_thread_from_id( void *id );
56 extern struct thread *get_thread_from_handle( int handle, unsigned int access );
57 extern void get_thread_info( struct thread *thread,
58                              struct get_thread_info_reply *reply );
59 extern void set_thread_info( struct thread *thread,
60                              struct set_thread_info_request *req );
61 extern int suspend_thread( struct thread *thread );
62 extern int resume_thread( struct thread *thread );
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 int thread_queue_apc( struct thread *thread, void *func, void *param );
68 extern void kill_thread( struct thread *thread, int exit_code );
69 extern void thread_killed( struct thread *thread, int exit_code );
70 extern void thread_timeout(void);
71 extern void sleep_on( struct thread *thread, int count, int *handles,
72                       int flags, int timeout );
73 extern void wake_up( struct object *obj, int max );
74
75 #define GET_ERROR()     (current->error)
76 #define SET_ERROR(err)  (current->error = (err))
77 #define CLEAR_ERROR()   (current->error = 0)
78
79 #endif  /* __WINE_SERVER_THREAD_H */