1 #ifndef _WAPI_PRIVATE_H_
2 #define _WAPI_PRIVATE_H_
7 #include "mono/io-layer/handles.h"
8 #include "mono/io-layer/io.h"
10 /* Increment this whenever an incompatible change is made to the
11 * shared handle structure.
13 * If this ever reaches 255, we have problems :-(
15 #define _WAPI_HANDLE_VERSION 1
32 WAPI_HANDLE_CAP_WAIT=0x01,
33 WAPI_HANDLE_CAP_SIGNAL=0x02,
34 WAPI_HANDLE_CAP_OWN=0x04,
35 } WapiHandleCapability;
39 /* All handle types */
40 void (*close)(gpointer handle);
42 /* File, console and pipe handles */
43 WapiFileType (*getfiletype)(void);
45 /* File and console handles */
46 gboolean (*readfile)(gpointer handle, gpointer buffer,
47 guint32 numbytes, guint32 *bytesread,
48 WapiOverlapped *overlapped);
49 gboolean (*writefile)(gpointer handle, gconstpointer buffer,
50 guint32 numbytes, guint32 *byteswritten,
51 WapiOverlapped *overlapped);
52 gboolean (*flushfile)(gpointer handle);
55 guint32 (*seek)(gpointer handle, gint32 movedistance,
56 gint32 *highmovedistance, WapiSeekMethod method);
57 gboolean (*setendoffile)(gpointer handle);
58 guint32 (*getfilesize)(gpointer handle, guint32 *highsize);
59 gboolean (*getfiletime)(gpointer handle, WapiFileTime *create_time,
60 WapiFileTime *last_access,
61 WapiFileTime *last_write);
62 gboolean (*setfiletime)(gpointer handle,
63 const WapiFileTime *create_time,
64 const WapiFileTime *last_access,
65 const WapiFileTime *last_write);
67 /* SignalObjectAndWait */
68 void (*signal)(gpointer signal);
70 /* Called by WaitForSingleObject and WaitForMultipleObjects,
71 * with the handle locked
73 void (*own_handle)(gpointer handle);
75 /* Called by WaitForSingleObject and WaitForMultipleObjects, if the
76 * handle in question is "ownable" (ie mutexes), to see if the current
77 * thread already owns this handle
79 gboolean (*is_owned)(gpointer handle);
82 #include <mono/io-layer/event-private.h>
83 #include <mono/io-layer/io-private.h>
84 #include <mono/io-layer/mutex-private.h>
85 #include <mono/io-layer/semaphore-private.h>
86 #include <mono/io-layer/socket-private.h>
87 #include <mono/io-layer/thread-private.h>
88 #include <mono/io-layer/process-private.h>
90 struct _WapiHandleShared
95 mono_mutex_t signal_mutex;
96 pthread_cond_t signal_cond;
100 struct _WapiHandle_event event;
101 struct _WapiHandle_file file;
102 struct _WapiHandle_find find;
103 struct _WapiHandle_mutex mutex;
104 struct _WapiHandle_sem sem;
105 struct _WapiHandle_socket sock;
106 struct _WapiHandle_thread thread;
107 struct _WapiHandle_process process;
111 #define _WAPI_MAX_HANDLES 4096
112 #define _WAPI_HANDLE_INVALID (gpointer)-1
115 * This is the layout of the shared memory segment
117 struct _WapiHandleShared_list
119 #ifdef _POSIX_THREAD_PROCESS_SHARED
120 mono_mutex_t signal_mutex;
121 pthread_cond_t signal_cond;
124 struct _WapiHandleShared handles[_WAPI_MAX_HANDLES];
125 guchar scratch_base[0];
128 struct _WapiHandlePrivate
132 struct _WapiHandlePrivate_event event;
133 struct _WapiHandlePrivate_file file;
134 struct _WapiHandlePrivate_find find;
135 struct _WapiHandlePrivate_mutex mutex;
136 struct _WapiHandlePrivate_sem sem;
137 struct _WapiHandlePrivate_socket sock;
138 struct _WapiHandlePrivate_thread thread;
139 struct _WapiHandlePrivate_process process;
143 /* Per-process handle info. For lookup convenience, each index matches
144 * the corresponding shared data.
146 struct _WapiHandlePrivate_list
148 #ifndef _POSIX_THREAD_PROCESS_SHARED
149 mono_mutex_t signal_mutex;
150 pthread_cond_t signal_cond;
152 struct _WapiHandlePrivate handles[_WAPI_MAX_HANDLES];
156 #endif /* _WAPI_PRIVATE_H_ */