~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/server/thread.h

Version: ~ [ wine-1.1.33 ] ~ [ wine-1.1.32 ] ~ [ wine-1.1.31 ] ~ [ wine-1.1.30 ] ~ [ wine-1.1.29 ] ~ [ wine-1.1.28 ] ~ [ wine-1.1.27 ] ~ [ wine-1.1.26 ] ~ [ wine-1.1.25 ] ~ [ wine-1.1.24 ] ~ [ wine-1.1.23 ] ~ [ wine-1.1.22 ] ~ [ wine-1.1.21 ] ~ [ wine-1.1.20 ] ~ [ wine-1.1.19 ] ~ [ wine-1.1.18 ] ~ [ wine-1.1.17 ] ~ [ wine-1.1.16 ] ~ [ wine-1.1.15 ] ~ [ wine-1.1.14 ] ~ [ wine-1.1.13 ] ~ [ wine-1.1.12 ] ~ [ wine-1.1.11 ] ~ [ wine-1.1.10 ] ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~

  1 /*
  2  * Wine server threads
  3  *
  4  * Copyright (C) 1998 Alexandre Julliard
  5  *
  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.
 10  *
 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.
 15  *
 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 19  */
 20 
 21 #ifndef __WINE_SERVER_THREAD_H
 22 #define __WINE_SERVER_THREAD_H
 23 
 24 #include "object.h"
 25 
 26 /* thread structure */
 27 
 28 struct process;
 29 struct thread_wait;
 30 struct thread_apc;
 31 struct debug_ctx;
 32 struct debug_event;
 33 struct msg_queue;
 34 
 35 enum run_state
 36 {
 37     RUNNING,    /* running normally */
 38     TERMINATED  /* terminated */
 39 };
 40 
 41 /* descriptor for fds currently in flight from client to server */
 42 struct inflight_fd
 43 {
 44     int client;  /* fd on the client side (or -1 if entry is free) */
 45     int server;  /* fd on the server side */
 46 };
 47 #define MAX_INFLIGHT_FDS 16  /* max number of fds in flight per thread */
 48 
 49 struct thread
 50 {
 51     struct object          obj;           /* object header */
 52     struct list            entry;         /* entry in system-wide thread list */
 53     struct list            proc_entry;    /* entry in per-process thread list */
 54     struct process        *process;
 55     thread_id_t            id;            /* thread id */
 56     struct list            mutex_list;    /* list of currently owned mutexes */
 57     struct debug_ctx      *debug_ctx;     /* debugger context if this thread is a debugger */
 58     struct debug_event    *debug_event;   /* debug event being sent to debugger */
 59     int                    debug_break;   /* debug breakpoint pending? */
 60     struct msg_queue      *queue;         /* message queue */
 61     struct thread_wait    *wait;          /* current wait condition if sleeping */
 62     struct list            system_apc;    /* queue of system async procedure calls */
 63     struct list            user_apc;      /* queue of user async procedure calls */
 64     struct inflight_fd     inflight[MAX_INFLIGHT_FDS];  /* fds currently in flight */
 65     unsigned int           error;         /* current error code */
 66     union generic_request  req;           /* current request */
 67     void                  *req_data;      /* variable-size data for request */
 68     unsigned int           req_toread;    /* amount of data still to read in request */
 69     void                  *reply_data;    /* variable-size data for reply */
 70     unsigned int           reply_size;    /* size of reply data */
 71     unsigned int           reply_towrite; /* amount of data still to write in reply */
 72     struct fd             *request_fd;    /* fd for receiving client requests */
 73     struct fd             *reply_fd;      /* fd to send a reply to a client */
 74     struct fd             *wait_fd;       /* fd to use to wake a sleeping client */
 75     enum run_state         state;         /* running state */
 76     int                    exit_code;     /* thread exit code */
 77     int                    unix_pid;      /* Unix pid of client */
 78     int                    unix_tid;      /* Unix tid of client */
 79     CONTEXT               *context;       /* current context if in an exception handler */
 80     CONTEXT               *suspend_context; /* current context if suspended */
 81     void                  *teb;           /* TEB address (in client address space) */
 82     int                    priority;      /* priority level */
 83     unsigned int           affinity;      /* affinity mask */
 84     int                    suspend;       /* suspend count */
 85     obj_handle_t           desktop;       /* desktop handle */
 86     int                    desktop_users; /* number of objects using the thread desktop */
 87     timeout_t              creation_time; /* Thread creation time */
 88     timeout_t              exit_time;     /* Thread exit time */
 89     struct token          *token;         /* security token associated with this thread */
 90 };
 91 
 92 struct thread_snapshot
 93 {
 94     struct thread  *thread;    /* thread ptr */
 95     int             count;     /* thread refcount */
 96     int             priority;  /* priority class */
 97 };
 98 
 99 extern struct thread *current;
100 
101 /* thread functions */
102 
103 extern struct thread *create_thread( int fd, struct process *process );
104 extern struct thread *get_thread_from_id( thread_id_t id );
105 extern struct thread *get_thread_from_handle( obj_handle_t handle, unsigned int access );
106 extern struct thread *get_thread_from_tid( int tid );
107 extern struct thread *get_thread_from_pid( int pid );
108 extern void stop_thread( struct thread *thread );
109 extern int wake_thread( struct thread *thread );
110 extern int add_queue( struct object *obj, struct wait_queue_entry *entry );
111 extern void remove_queue( struct object *obj, struct wait_queue_entry *entry );
112 extern void kill_thread( struct thread *thread, int violent_death );
113 extern void break_thread( struct thread *thread );
114 extern void wake_up( struct object *obj, int max );
115 extern int thread_queue_apc( struct thread *thread, struct object *owner, const apc_call_t *call_data );
116 extern void thread_cancel_apc( struct thread *thread, struct object *owner, enum apc_type type );
117 extern int thread_add_inflight_fd( struct thread *thread, int client, int server );
118 extern int thread_get_inflight_fd( struct thread *thread, int client );
119 extern struct thread_snapshot *thread_snap( int *count );
120 extern struct token *thread_get_impersonation_token( struct thread *thread );
121 
122 /* CPU context functions */
123 extern void copy_context( CONTEXT *to, const CONTEXT *from, unsigned int flags );
124 extern void *get_context_ip( const CONTEXT *context );
125 extern unsigned int get_context_cpu_flag(void);
126 extern unsigned int get_context_system_regs( unsigned int flags );
127 
128 /* ptrace functions */
129 
130 extern void sigchld_callback(void);
131 extern void get_thread_context( struct thread *thread, CONTEXT *context, unsigned int flags );
132 extern void set_thread_context( struct thread *thread, const CONTEXT *context, unsigned int flags );
133 extern int send_thread_signal( struct thread *thread, int sig );
134 extern void get_selector_entry( struct thread *thread, int entry, unsigned int *base,
135                                 unsigned int *limit, unsigned char *flags );
136 
137 extern unsigned int global_error;  /* global error code for when no thread is current */
138 
139 static inline unsigned int get_error(void)       { return current ? current->error : global_error; }
140 static inline void set_error( unsigned int err ) { global_error = err; if (current) current->error = err; }
141 static inline void clear_error(void)             { set_error(0); }
142 static inline void set_win32_error( unsigned int err ) { set_error( 0xc0010000 | err ); }
143 
144 static inline thread_id_t get_thread_id( struct thread *thread ) { return thread->id; }
145 
146 #endif  /* __WINE_SERVER_THREAD_H */
147 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.