X11DRV_DrawArc: Don't overwrite the ENDCAP style.
[wine/multimedia.git] / server / thread.h
blob218a7b3a4b2ec775451df8c318f4fe6068a90097
1 /*
2 * Wine server threads
4 * Copyright (C) 1998 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #ifndef __WINE_SERVER_THREAD_H
22 #define __WINE_SERVER_THREAD_H
24 #include "object.h"
26 /* thread structure */
28 struct process;
29 struct thread_wait;
30 struct thread_apc;
31 struct mutex;
32 struct debug_ctx;
33 struct debug_event;
34 struct startup_info;
35 struct msg_queue;
36 struct hook_table;
38 enum run_state
40 RUNNING, /* running normally */
41 TERMINATED /* terminated */
44 struct apc_queue
46 struct thread_apc *head;
47 struct thread_apc *tail;
50 /* descriptor for fds currently in flight from client to server */
51 struct inflight_fd
53 int client; /* fd on the client side (or -1 if entry is free) */
54 int server; /* fd on the server side */
56 #define MAX_INFLIGHT_FDS 16 /* max number of fds in flight per thread */
58 struct thread
60 struct object obj; /* object header */
61 struct thread *next; /* system-wide thread list */
62 struct thread *prev;
63 struct thread *proc_next; /* per-process thread list */
64 struct thread *proc_prev;
65 struct process *process;
66 struct mutex *mutex; /* list of currently owned mutexes */
67 struct debug_ctx *debug_ctx; /* debugger context if this thread is a debugger */
68 struct debug_event *debug_event; /* debug event being sent to debugger */
69 struct msg_queue *queue; /* message queue */
70 struct hook_table *hooks; /* hooks table */
71 struct startup_info *info; /* startup info for child process */
72 struct thread_wait *wait; /* current wait condition if sleeping */
73 struct apc_queue system_apc; /* queue of system async procedure calls */
74 struct apc_queue user_apc; /* queue of user async procedure calls */
75 struct inflight_fd inflight[MAX_INFLIGHT_FDS]; /* fds currently in flight */
76 unsigned int error; /* current error code */
77 union generic_request req; /* current request */
78 void *req_data; /* variable-size data for request */
79 unsigned int req_toread; /* amount of data still to read in request */
80 void *reply_data; /* variable-size data for reply */
81 unsigned int reply_size; /* size of reply data */
82 unsigned int reply_towrite; /* amount of data still to write in reply */
83 int request_fd; /* fd for receiving client requests */
84 int reply_fd; /* fd to send a reply to a client */
85 int wait_fd; /* fd to use to wake a sleeping client */
86 enum run_state state; /* running state */
87 int attached; /* is thread attached with ptrace? */
88 int exit_code; /* thread exit code */
89 int unix_pid; /* Unix pid of client */
90 CONTEXT *context; /* current context if in an exception handler */
91 void *teb; /* TEB address (in client address space) */
92 int priority; /* priority level */
93 int affinity; /* affinity mask */
94 int suspend; /* suspend count */
95 time_t creation_time; /* Thread creation time */
96 time_t exit_time; /* Thread exit time */
99 struct thread_snapshot
101 struct thread *thread; /* thread ptr */
102 int count; /* thread refcount */
103 int priority; /* priority class */
106 extern struct thread *current;
108 /* thread functions */
110 extern struct thread *create_thread( int fd, struct process *process );
111 extern struct thread *get_thread_from_id( thread_id_t id );
112 extern struct thread *get_thread_from_handle( obj_handle_t handle, unsigned int access );
113 extern struct thread *get_thread_from_pid( int pid );
114 extern int suspend_thread( struct thread *thread, int check_limit );
115 extern int resume_thread( struct thread *thread );
116 extern int add_queue( struct object *obj, struct wait_queue_entry *entry );
117 extern void remove_queue( struct object *obj, struct wait_queue_entry *entry );
118 extern void kill_thread( struct thread *thread, int violent_death );
119 extern void wake_up( struct object *obj, int max );
120 extern int thread_queue_apc( struct thread *thread, struct object *owner, void *func,
121 enum apc_type type, int system, int nb_args, ... );
122 extern void thread_cancel_apc( struct thread *thread, struct object *owner, int system );
123 extern int thread_add_inflight_fd( struct thread *thread, int client, int server );
124 extern int thread_get_inflight_fd( struct thread *thread, int client );
125 extern struct thread_snapshot *thread_snap( int *count );
127 /* ptrace functions */
129 extern void sigchld_handler();
130 extern void wait4_thread( struct thread *thread, int signal );
131 extern void stop_thread( struct thread *thread );
132 extern void continue_thread( struct thread *thread );
133 extern void detach_thread( struct thread *thread, int sig );
134 extern int suspend_for_ptrace( struct thread *thread );
135 extern int read_thread_int( struct thread *thread, const int *addr, int *data );
136 extern int write_thread_int( struct thread *thread, int *addr, int data, unsigned int mask );
137 extern void *get_thread_ip( struct thread *thread );
138 extern int get_thread_single_step( struct thread *thread );
140 extern unsigned int global_error; /* global error code for when no thread is current */
142 static inline unsigned int get_error(void) { return current ? current->error : global_error; }
143 static inline void set_error( unsigned int err ) { global_error = err; if (current) current->error = err; }
144 static inline void clear_error(void) { set_error(0); }
146 static inline thread_id_t get_thread_id( struct thread *thread ) { return (thread_id_t)thread; }
148 #endif /* __WINE_SERVER_THREAD_H */