2 * wapi-private.h: internal definitions of handles and shared memory layout
5 * Dick Porter (dick@ximian.com)
7 * (C) 2002-2006 Novell, 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 12
41 WAPI_HANDLE_NAMEDMUTEX
,
43 WAPI_HANDLE_NAMEDEVENT
,
47 extern const char *_wapi_handle_typename
[];
49 #define _WAPI_SHARED_HANDLE(type) (type == WAPI_HANDLE_PROCESS || \
50 type == WAPI_HANDLE_NAMEDMUTEX || \
51 type == WAPI_HANDLE_NAMEDSEM || \
52 type == WAPI_HANDLE_NAMEDEVENT)
54 #define _WAPI_FD_HANDLE(type) (type == WAPI_HANDLE_FILE || \
55 type == WAPI_HANDLE_CONSOLE || \
56 type == WAPI_HANDLE_SOCKET || \
57 type == WAPI_HANDLE_PIPE)
59 #define _WAPI_SHARED_NAMESPACE(type) (type == WAPI_HANDLE_NAMEDMUTEX || \
60 type == WAPI_HANDLE_NAMEDSEM || \
61 type == WAPI_HANDLE_NAMEDEVENT)
65 gchar name
[MAX_PATH
+ 1];
66 } WapiSharedNamespace
;
69 WAPI_HANDLE_CAP_WAIT
=0x01,
70 WAPI_HANDLE_CAP_SIGNAL
=0x02,
71 WAPI_HANDLE_CAP_OWN
=0x04,
72 WAPI_HANDLE_CAP_SPECIAL_WAIT
=0x08
73 } WapiHandleCapability
;
77 void (*close
)(gpointer handle
, gpointer data
);
79 /* SignalObjectAndWait */
80 void (*signal
)(gpointer signal
);
82 /* Called by WaitForSingleObject and WaitForMultipleObjects,
83 * with the handle locked (shared handles aren't locked.)
84 * Returns TRUE if ownership was established, false otherwise.
86 gboolean (*own_handle
)(gpointer handle
);
88 /* Called by WaitForSingleObject and WaitForMultipleObjects, if the
89 * handle in question is "ownable" (ie mutexes), to see if the current
90 * thread already owns this handle
92 gboolean (*is_owned
)(gpointer handle
);
94 /* Called by WaitForSingleObject and WaitForMultipleObjects,
95 * if the handle in question needs a special wait function
96 * instead of using the normal handle signal mechanism.
97 * Returns the WaitForSingleObject return code.
99 guint32 (*special_wait
)(gpointer handle
, guint32 timeout
);
101 /* Called by WaitForSingleObject and WaitForMultipleObjects,
102 * if the handle in question needs some preprocessing before the
105 void (*prewait
)(gpointer handle
);
108 #include <mono/io-layer/event-private.h>
109 #include <mono/io-layer/io-private.h>
110 #include <mono/io-layer/mutex-private.h>
111 #include <mono/io-layer/semaphore-private.h>
112 #include <mono/io-layer/socket-private.h>
113 #include <mono/io-layer/thread-private.h>
114 #include <mono/io-layer/process-private.h>
116 struct _WapiHandle_shared_ref
118 /* This will be split 16:16 with the shared file segment in
119 * the top half, when I implement space increases
124 #define _WAPI_HANDLE_INITIAL_COUNT 256
126 struct _WapiHandleUnshared
131 mono_mutex_t signal_mutex
;
132 pthread_cond_t signal_cond
;
136 struct _WapiHandle_event event
;
137 struct _WapiHandle_file file
;
138 struct _WapiHandle_find find
;
139 struct _WapiHandle_mutex mutex
;
140 struct _WapiHandle_sem sem
;
141 struct _WapiHandle_socket sock
;
142 struct _WapiHandle_thread thread
;
143 struct _WapiHandle_shared_ref shared
;
147 struct _WapiHandleShared
152 volatile gboolean signalled
;
156 struct _WapiHandle_process process
;
157 struct _WapiHandle_namedmutex namedmutex
;
158 struct _WapiHandle_namedsem namedsem
;
159 struct _WapiHandle_namedevent namedevent
;
163 #define _WAPI_SHARED_SEM_NAMESPACE 0
164 /*#define _WAPI_SHARED_SEM_COLLECTION 1*/
165 #define _WAPI_SHARED_SEM_FILESHARE 2
166 #define _WAPI_SHARED_SEM_SHARED_HANDLES 3
167 #define _WAPI_SHARED_SEM_PROCESS_COUNT_LOCK 6
168 #define _WAPI_SHARED_SEM_PROCESS_COUNT 7
169 #define _WAPI_SHARED_SEM_COUNT 8 /* Leave some future expansion space */
171 struct _WapiHandleSharedLayout
173 volatile guint32 collection_count
;
174 volatile key_t sem_key
;
176 struct _WapiHandleShared handles
[_WAPI_HANDLE_INITIAL_COUNT
];
179 #define _WAPI_FILESHARE_SIZE 102400
181 struct _WapiFileShare
192 struct _WapiFileShareLayout
196 struct _WapiFileShare share_info
[_WAPI_FILESHARE_SIZE
];
201 #define _WAPI_HANDLE_INVALID (gpointer)-1
203 #endif /* _WAPI_PRIVATE_H_ */