Better fake implementation of SetThreadExecutionState.
[wine.git] / server / object.h
blob12cf7c6d71943899266d9cb67c96d89e29bc2b32
1 /*
2 * Wine server objects
4 * Copyright (C) 1998 Alexandre Julliard
5 */
7 #ifndef __WINE_SERVER_OBJECT_H
8 #define __WINE_SERVER_OBJECT_H
10 #include <sys/poll.h>
11 #include <sys/time.h>
12 #include "wine/server_protocol.h"
14 #define DEBUG_OBJECTS
16 /* kernel objects */
18 struct object;
19 struct object_name;
20 struct thread;
21 struct process;
22 struct file;
23 struct wait_queue_entry;
24 struct async;
26 /* operations valid on all objects */
27 struct object_ops
29 /* size of this object type */
30 size_t size;
31 /* dump the object (for debugging) */
32 void (*dump)(struct object *,int);
33 /* add a thread to the object wait queue */
34 int (*add_queue)(struct object *,struct wait_queue_entry *);
35 /* remove a thread from the object wait queue */
36 void (*remove_queue)(struct object *,struct wait_queue_entry *);
37 /* is object signaled? */
38 int (*signaled)(struct object *,struct thread *);
39 /* wait satisfied; return 1 if abandoned */
40 int (*satisfied)(struct object *,struct thread *);
41 /* get the events we want to poll() for on this object */
42 int (*get_poll_events)(struct object *);
43 /* a poll() event occured */
44 void (*poll_event)(struct object *,int event);
45 /* return a Unix fd that can be used to read/write from the object */
46 int (*get_fd)(struct object *);
47 /* flush the object buffers */
48 int (*flush)(struct object *);
49 /* get file information */
50 int (*get_file_info)(struct object *,struct get_file_info_request *);
51 /* destroy on refcount == 0 */
52 void (*destroy)(struct object *);
55 struct object
57 unsigned int refcount; /* reference count */
58 int fd; /* file descriptor */
59 int select; /* select() user id */
60 const struct object_ops *ops;
61 struct wait_queue_entry *head;
62 struct wait_queue_entry *tail;
63 struct object_name *name;
64 #ifdef DEBUG_OBJECTS
65 struct object *prev;
66 struct object *next;
67 #endif
70 struct wait_queue_entry
72 struct wait_queue_entry *next;
73 struct wait_queue_entry *prev;
74 struct object *obj;
75 struct thread *thread;
78 extern void *mem_alloc( size_t size ); /* malloc wrapper */
79 extern void *memdup( const void *data, size_t len );
80 extern void *alloc_object( const struct object_ops *ops, int fd );
81 extern void dump_object_name( struct object *obj );
82 extern void *create_named_object( const struct object_ops *ops, const WCHAR *name, size_t len );
83 /* grab/release_object can take any pointer, but you better make sure */
84 /* that the thing pointed to starts with a struct object... */
85 extern struct object *grab_object( void *obj );
86 extern void release_object( void *obj );
87 extern struct object *find_object( const WCHAR *name, size_t len );
88 extern int no_add_queue( struct object *obj, struct wait_queue_entry *entry );
89 extern int no_satisfied( struct object *obj, struct thread *thread );
90 extern int no_get_fd( struct object *obj );
91 extern int no_flush( struct object *obj );
92 extern int no_get_file_info( struct object *obj, struct get_file_info_request *info );
93 extern void no_destroy( struct object *obj );
94 extern int default_poll_add_queue( struct object *obj, struct wait_queue_entry *entry );
95 extern void default_poll_remove_queue( struct object *obj, struct wait_queue_entry *entry );
96 extern int default_poll_signaled( struct object *obj, struct thread *thread );
97 extern void default_poll_event( struct object *obj, int event );
98 #ifdef DEBUG_OBJECTS
99 extern void dump_objects(void);
100 #endif
102 /* select functions */
104 extern int add_select_user( struct object *obj );
105 extern void remove_select_user( struct object *obj );
106 extern void change_select_fd( struct object *obj, int fd );
107 extern void set_select_events( struct object *obj, int events );
108 extern int check_select_events( int fd, int events );
109 extern void select_loop(void);
111 /* timeout functions */
113 struct timeout_user;
115 typedef void (*timeout_callback)( void *private );
117 extern struct timeout_user *add_timeout_user( struct timeval *when,
118 timeout_callback func, void *private );
119 extern void remove_timeout_user( struct timeout_user *user );
120 extern void add_timeout( struct timeval *when, int timeout );
121 /* return 1 if t1 is before t2 */
122 static inline int time_before( struct timeval *t1, struct timeval *t2 )
124 return ((t1->tv_sec < t2->tv_sec) ||
125 ((t1->tv_sec == t2->tv_sec) && (t1->tv_usec < t2->tv_usec)));
128 /* event functions */
130 struct event;
132 extern struct event *create_event( const WCHAR *name, size_t len,
133 int manual_reset, int initial_state );
134 extern struct event *get_event_obj( struct process *process, handle_t handle, unsigned int access );
135 extern void pulse_event( struct event *event );
136 extern void set_event( struct event *event );
137 extern void reset_event( struct event *event );
139 /* mutex functions */
141 extern void abandon_mutexes( struct thread *thread );
143 /* file functions */
145 extern struct file *get_file_obj( struct process *process, handle_t handle,
146 unsigned int access );
147 extern int is_same_file( struct file *file1, struct file *file2 );
148 extern int grow_file( struct file *file, int size_high, int size_low );
149 extern int create_anonymous_file(void);
150 extern struct file *create_temp_file( int access );
151 extern void file_set_error(void);
153 /* serial functions */
155 int get_serial_async_timeout(struct object *obj, int type, int count);
157 /* console functions */
159 extern int alloc_console( struct process *process );
160 extern int free_console( struct process *process );
162 /* debugger functions */
164 extern int set_process_debugger( struct process *process, struct thread *debugger );
165 extern void generate_debug_event( struct thread *thread, int code, void *arg );
166 extern void generate_startup_debug_events( struct process *process, void *entry );
167 extern void debug_exit_thread( struct thread *thread );
169 /* mapping functions */
171 extern int get_page_size(void);
173 /* registry functions */
175 extern void init_registry(void);
176 extern void close_registry(void);
178 /* atom functions */
180 extern void close_atom_table(void);
182 /* global variables */
184 /* command-line options */
185 extern int debug_level;
186 extern int persistent_server;
188 /* server start time used for GetTickCount() */
189 extern unsigned int server_start_ticks;
191 #endif /* __WINE_SERVER_OBJECT_H */