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_
17 #include <mono/io-layer/handles.h>
18 #include <mono/io-layer/io.h>
20 /* Increment this whenever an incompatible change is made to the
21 * shared handle structure.
23 #define _WAPI_HANDLE_VERSION 12
37 WAPI_HANDLE_NAMEDMUTEX
,
39 WAPI_HANDLE_NAMEDEVENT
,
43 extern const char *_wapi_handle_typename
[];
45 #define _WAPI_SHARED_HANDLE(type) (type == WAPI_HANDLE_PROCESS || \
46 type == WAPI_HANDLE_NAMEDMUTEX || \
47 type == WAPI_HANDLE_NAMEDSEM || \
48 type == WAPI_HANDLE_NAMEDEVENT)
50 #define _WAPI_FD_HANDLE(type) (type == WAPI_HANDLE_FILE || \
51 type == WAPI_HANDLE_CONSOLE || \
52 type == WAPI_HANDLE_SOCKET || \
53 type == WAPI_HANDLE_PIPE)
55 #define _WAPI_SHARED_NAMESPACE(type) (type == WAPI_HANDLE_NAMEDMUTEX || \
56 type == WAPI_HANDLE_NAMEDSEM || \
57 type == WAPI_HANDLE_NAMEDEVENT)
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
, gpointer data
);
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 and WaitForMultipleObjects,
91 * if the handle in question needs a special wait function
92 * instead of using the normal handle signal mechanism.
93 * Returns the WaitForSingleObject return code.
95 guint32 (*special_wait
)(gpointer handle
, guint32 timeout
);
97 /* Called by WaitForSingleObject and WaitForMultipleObjects,
98 * if the handle in question needs some preprocessing before the
101 void (*prewait
)(gpointer handle
);
104 #include <mono/io-layer/event-private.h>
105 #include <mono/io-layer/io-private.h>
106 #include <mono/io-layer/mutex-private.h>
107 #include <mono/io-layer/semaphore-private.h>
108 #include <mono/io-layer/socket-private.h>
109 #include <mono/io-layer/thread-private.h>
110 #include <mono/io-layer/process-private.h>
112 struct _WapiHandle_shared_ref
114 /* This will be split 16:16 with the shared file segment in
115 * the top half, when I implement space increases
120 #define _WAPI_HANDLE_INITIAL_COUNT 256
122 struct _WapiHandleUnshared
127 mono_mutex_t signal_mutex
;
128 pthread_cond_t signal_cond
;
132 struct _WapiHandle_event event
;
133 struct _WapiHandle_file file
;
134 struct _WapiHandle_find find
;
135 struct _WapiHandle_mutex mutex
;
136 struct _WapiHandle_sem sem
;
137 struct _WapiHandle_socket sock
;
138 struct _WapiHandle_thread thread
;
139 struct _WapiHandle_shared_ref shared
;
143 struct _WapiHandleShared
148 volatile gboolean signalled
;
152 struct _WapiHandle_process process
;
153 struct _WapiHandle_namedmutex namedmutex
;
154 struct _WapiHandle_namedsem namedsem
;
155 struct _WapiHandle_namedevent namedevent
;
159 #define _WAPI_SHARED_SEM_NAMESPACE 0
160 /*#define _WAPI_SHARED_SEM_COLLECTION 1*/
161 #define _WAPI_SHARED_SEM_FILESHARE 2
162 #define _WAPI_SHARED_SEM_SHARED_HANDLES 3
163 #define _WAPI_SHARED_SEM_PROCESS_COUNT_LOCK 6
164 #define _WAPI_SHARED_SEM_PROCESS_COUNT 7
165 #define _WAPI_SHARED_SEM_COUNT 8 /* Leave some future expansion space */
167 struct _WapiHandleSharedLayout
169 volatile guint32 collection_count
;
170 volatile key_t sem_key
;
172 struct _WapiHandleShared handles
[_WAPI_HANDLE_INITIAL_COUNT
];
175 #define _WAPI_FILESHARE_SIZE 102400
177 struct _WapiFileShare
179 #ifdef WAPI_FILE_SHARE_PLATFORM_EXTRA_DATA
180 WAPI_FILE_SHARE_PLATFORM_EXTRA_DATA
191 struct _WapiFileShareLayout
195 struct _WapiFileShare share_info
[_WAPI_FILESHARE_SIZE
];
200 #define _WAPI_HANDLE_INVALID (gpointer)-1
202 #endif /* _WAPI_PRIVATE_H_ */