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 /* Increment this whenever an incompatible change is made to the
21 * shared handle structure.
23 * If this ever reaches 255, we have problems :-(
25 #define _WAPI_HANDLE_VERSION 4
42 WAPI_HANDLE_CAP_WAIT=0x01,
43 WAPI_HANDLE_CAP_SIGNAL=0x02,
44 WAPI_HANDLE_CAP_OWN=0x04,
45 } WapiHandleCapability;
49 void (*close_shared)(gpointer handle);
50 void (*close_private)(gpointer handle);
52 /* SignalObjectAndWait */
53 void (*signal)(gpointer signal);
55 /* Called by WaitForSingleObject and WaitForMultipleObjects,
56 * with the handle locked
58 void (*own_handle)(gpointer handle);
60 /* Called by WaitForSingleObject and WaitForMultipleObjects, if the
61 * handle in question is "ownable" (ie mutexes), to see if the current
62 * thread already owns this handle
64 gboolean (*is_owned)(gpointer handle);
67 #include <mono/io-layer/event-private.h>
68 #include <mono/io-layer/io-private.h>
69 #include <mono/io-layer/mutex-private.h>
70 #include <mono/io-layer/semaphore-private.h>
71 #include <mono/io-layer/socket-private.h>
72 #include <mono/io-layer/thread-private.h>
73 #include <mono/io-layer/process-private.h>
75 struct _WapiHandleShared
80 mono_mutex_t signal_mutex;
81 pthread_cond_t signal_cond;
85 struct _WapiHandle_event event;
86 struct _WapiHandle_file file;
87 struct _WapiHandle_find find;
88 struct _WapiHandle_mutex mutex;
89 struct _WapiHandle_sem sem;
90 struct _WapiHandle_socket sock;
91 struct _WapiHandle_thread thread;
92 struct _WapiHandle_process process;
96 #define _WAPI_MAX_HANDLES 4096
97 #define _WAPI_HANDLE_INVALID (gpointer)-1
100 * This is the layout of the shared memory segment
102 struct _WapiHandleShared_list
104 /* UNIX_PATH_MAX doesnt seem to be defined in any accessible
108 _wapi_daemon_status daemon_running;
110 #ifdef _POSIX_THREAD_PROCESS_SHARED
111 mono_mutex_t signal_mutex;
112 pthread_cond_t signal_cond;
114 struct _WapiHandleShared handles[_WAPI_MAX_HANDLES];
115 guchar scratch_base[0];
118 struct _WapiHandlePrivate
122 struct _WapiHandlePrivate_event event;
123 struct _WapiHandlePrivate_file file;
124 struct _WapiHandlePrivate_find find;
125 struct _WapiHandlePrivate_mutex mutex;
126 struct _WapiHandlePrivate_sem sem;
127 struct _WapiHandlePrivate_socket sock;
128 struct _WapiHandlePrivate_thread thread;
129 struct _WapiHandlePrivate_process process;
133 /* Per-process handle info. For lookup convenience, each index matches
134 * the corresponding shared data.
136 struct _WapiHandlePrivate_list
138 #ifndef _POSIX_THREAD_PROCESS_SHARED
139 mono_mutex_t signal_mutex;
140 pthread_cond_t signal_cond;
142 struct _WapiHandlePrivate handles[_WAPI_MAX_HANDLES];
146 #endif /* _WAPI_PRIVATE_H_ */