2 * wapi-private.h: internal definitions of handles and shared memory layout
5 * Dick Porter (dick@ximian.com)
7 * (C) 2002 Ximian, Inc.
10 #ifndef _WAPI_PRIVATE_H_
11 #define _WAPI_PRIVATE_H_
16 #include <mono/io-layer/handles.h>
17 #include <mono/io-layer/io.h>
18 #include <mono/io-layer/daemon-private.h>
20 /* Catch this here rather than corrupt the shared data at runtime */
21 #if MONO_SIZEOF_SUNPATH==0
22 #error configure failed to discover size of unix socket path
25 /* Increment this whenever an incompatible change is made to the
26 * shared handle structure.
28 #define _WAPI_HANDLE_VERSION 4
42 WAPI_HANDLE_NAMEDMUTEX,
46 extern const char *_wapi_handle_typename[];
48 #define _WAPI_SHARED_HANDLE(type) (type == WAPI_HANDLE_THREAD || \
49 type == WAPI_HANDLE_PROCESS || \
50 type == WAPI_HANDLE_NAMEDMUTEX)
52 #define _WAPI_FD_HANDLE(type) (type == WAPI_HANDLE_FILE || \
53 type == WAPI_HANDLE_CONSOLE || \
54 type == WAPI_HANDLE_SOCKET || \
55 type == WAPI_HANDLE_PIPE)
57 #define _WAPI_SHARED_NAMESPACE(type) (type == WAPI_HANDLE_NAMEDMUTEX)
61 gchar name[MAX_PATH + 1];
62 } WapiSharedNamespace;
65 WAPI_HANDLE_CAP_WAIT=0x01,
66 WAPI_HANDLE_CAP_SIGNAL=0x02,
67 WAPI_HANDLE_CAP_OWN=0x04,
68 WAPI_HANDLE_CAP_SPECIAL_WAIT=0x08
69 } WapiHandleCapability;
73 void (*close)(gpointer handle);
75 /* SignalObjectAndWait */
76 void (*signal)(gpointer signal);
78 /* Called by WaitForSingleObject and WaitForMultipleObjects,
79 * with the handle locked (shared handles aren't locked.)
80 * Returns TRUE if ownership was established, false otherwise.
82 gboolean (*own_handle)(gpointer handle);
84 /* Called by WaitForSingleObject and WaitForMultipleObjects, if the
85 * handle in question is "ownable" (ie mutexes), to see if the current
86 * thread already owns this handle
88 gboolean (*is_owned)(gpointer handle);
90 /* Called by WaitForSingleObject, if the handle in question
91 * needs a special wait function instead of using the normal
92 * handle signal mechanism. Returns the WaitForSingleObject
95 guint32 (*special_wait)(gpointer handle, guint32 timeout);
98 #include <mono/io-layer/event-private.h>
99 #include <mono/io-layer/io-private.h>
100 #include <mono/io-layer/mutex-private.h>
101 #include <mono/io-layer/semaphore-private.h>
102 #include <mono/io-layer/socket-private.h>
103 #include <mono/io-layer/thread-private.h>
104 #include <mono/io-layer/process-private.h>
106 struct _WapiHandle_shared_ref
108 /* This will be split 16:16 with the shared file segment in
109 * the top half, when I implement space increases
114 #define _WAPI_HANDLE_INITIAL_COUNT 4096
115 #define _WAPI_HEADROOM 16
117 struct _WapiHandleUnshared
122 mono_mutex_t signal_mutex;
123 pthread_cond_t signal_cond;
127 struct _WapiHandle_event event;
128 struct _WapiHandle_file file;
129 struct _WapiHandle_find find;
130 struct _WapiHandle_mutex mutex;
131 struct _WapiHandle_sem sem;
132 struct _WapiHandle_socket sock;
133 struct _WapiHandle_shared_ref shared;
137 struct _WapiHandleSharedMetadata
139 volatile guint32 offset;
141 volatile gboolean signalled;
142 volatile guint32 checking;
145 struct _WapiHandleShared
152 struct _WapiHandle_thread thread;
153 struct _WapiHandle_process process;
154 struct _WapiHandle_namedmutex namedmutex;
158 struct _WapiHandleSharedLayout
160 guint32 namespace_check;
161 volatile guint32 signal_count;
163 guint32 master_timestamp;
164 volatile guint32 collection_count;
166 struct _WapiHandleSharedMetadata metadata[_WAPI_HANDLE_INITIAL_COUNT];
167 struct _WapiHandleShared handles[_WAPI_HANDLE_INITIAL_COUNT];
170 #define _WAPI_FILESHARE_SIZE 102400
172 struct _WapiFileShare
182 struct _WapiFileShareLayout
187 struct _WapiFileShare share_info[_WAPI_FILESHARE_SIZE];
192 #define _WAPI_HANDLE_INVALID (gpointer)-1
194 #endif /* _WAPI_PRIVATE_H_ */