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>
19 /* Catch this here rather than corrupt the shared data at runtime */
20 #if MONO_SIZEOF_SUNPATH==0
21 #error configure failed to discover size of unix socket path
24 /* Increment this whenever an incompatible change is made to the
25 * shared handle structure.
27 #define _WAPI_HANDLE_VERSION 4
41 WAPI_HANDLE_NAMEDMUTEX,
45 extern const char *_wapi_handle_typename[];
47 #define _WAPI_SHARED_HANDLE(type) (type == WAPI_HANDLE_THREAD || \
48 type == WAPI_HANDLE_PROCESS || \
49 type == WAPI_HANDLE_NAMEDMUTEX)
51 #define _WAPI_FD_HANDLE(type) (type == WAPI_HANDLE_FILE || \
52 type == WAPI_HANDLE_CONSOLE || \
53 type == WAPI_HANDLE_SOCKET || \
54 type == WAPI_HANDLE_PIPE)
56 #define _WAPI_SHARED_NAMESPACE(type) (type == WAPI_HANDLE_NAMEDMUTEX)
60 gchar name[MAX_PATH + 1];
61 } WapiSharedNamespace;
64 WAPI_HANDLE_CAP_WAIT=0x01,
65 WAPI_HANDLE_CAP_SIGNAL=0x02,
66 WAPI_HANDLE_CAP_OWN=0x04,
67 WAPI_HANDLE_CAP_SPECIAL_WAIT=0x08
68 } WapiHandleCapability;
72 void (*close)(gpointer handle);
74 /* SignalObjectAndWait */
75 void (*signal)(gpointer signal);
77 /* Called by WaitForSingleObject and WaitForMultipleObjects,
78 * with the handle locked (shared handles aren't locked.)
79 * Returns TRUE if ownership was established, false otherwise.
81 gboolean (*own_handle)(gpointer handle);
83 /* Called by WaitForSingleObject and WaitForMultipleObjects, if the
84 * handle in question is "ownable" (ie mutexes), to see if the current
85 * thread already owns this handle
87 gboolean (*is_owned)(gpointer handle);
89 /* Called by WaitForSingleObject, if the handle in question
90 * needs a special wait function instead of using the normal
91 * handle signal mechanism. Returns the WaitForSingleObject
94 guint32 (*special_wait)(gpointer handle, guint32 timeout);
97 #include <mono/io-layer/event-private.h>
98 #include <mono/io-layer/io-private.h>
99 #include <mono/io-layer/mutex-private.h>
100 #include <mono/io-layer/semaphore-private.h>
101 #include <mono/io-layer/socket-private.h>
102 #include <mono/io-layer/thread-private.h>
103 #include <mono/io-layer/process-private.h>
105 struct _WapiHandle_shared_ref
107 /* This will be split 16:16 with the shared file segment in
108 * the top half, when I implement space increases
113 #define _WAPI_HANDLE_INITIAL_COUNT 4096
114 #define _WAPI_HEADROOM 16
116 struct _WapiHandleUnshared
121 mono_mutex_t signal_mutex;
122 pthread_cond_t signal_cond;
126 struct _WapiHandle_event event;
127 struct _WapiHandle_file file;
128 struct _WapiHandle_find find;
129 struct _WapiHandle_mutex mutex;
130 struct _WapiHandle_sem sem;
131 struct _WapiHandle_socket sock;
132 struct _WapiHandle_shared_ref shared;
136 struct _WapiHandleSharedMetadata
138 volatile guint32 offset;
140 volatile gboolean signalled;
141 volatile guint32 checking;
144 struct _WapiHandleShared
151 struct _WapiHandle_thread thread;
152 struct _WapiHandle_process process;
153 struct _WapiHandle_namedmutex namedmutex;
157 struct _WapiHandleSharedLayout
159 guint32 namespace_check;
160 volatile guint32 signal_count;
162 guint32 master_timestamp;
163 volatile guint32 collection_count;
165 struct _WapiHandleSharedMetadata metadata[_WAPI_HANDLE_INITIAL_COUNT];
166 struct _WapiHandleShared handles[_WAPI_HANDLE_INITIAL_COUNT];
169 #define _WAPI_FILESHARE_SIZE 102400
171 struct _WapiFileShare
181 struct _WapiFileShareLayout
186 struct _WapiFileShare share_info[_WAPI_FILESHARE_SIZE];
191 #define _WAPI_HANDLE_INVALID (gpointer)-1
193 #endif /* _WAPI_PRIVATE_H_ */