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 /* Shared threads don't seem to work yet */
21 #undef _POSIX_THREAD_PROCESS_SHARED
23 /* Increment this whenever an incompatible change is made to the
24 * shared handle structure.
26 #define _WAPI_HANDLE_VERSION 0
44 WAPI_HANDLE_CAP_WAIT=0x01,
45 WAPI_HANDLE_CAP_SIGNAL=0x02,
46 WAPI_HANDLE_CAP_OWN=0x04,
47 } WapiHandleCapability;
51 void (*close_shared)(gpointer handle);
52 void (*close_private)(gpointer handle);
54 /* SignalObjectAndWait */
55 void (*signal)(gpointer signal);
57 /* Called by WaitForSingleObject and WaitForMultipleObjects,
58 * with the handle locked
60 void (*own_handle)(gpointer handle);
62 /* Called by WaitForSingleObject and WaitForMultipleObjects, if the
63 * handle in question is "ownable" (ie mutexes), to see if the current
64 * thread already owns this handle
66 gboolean (*is_owned)(gpointer handle);
69 #include <mono/io-layer/event-private.h>
70 #include <mono/io-layer/io-private.h>
71 #include <mono/io-layer/mutex-private.h>
72 #include <mono/io-layer/semaphore-private.h>
73 #include <mono/io-layer/socket-private.h>
74 #include <mono/io-layer/thread-private.h>
75 #include <mono/io-layer/process-private.h>
77 struct _WapiHandleShared
82 mono_mutex_t signal_mutex;
83 pthread_cond_t signal_cond;
87 struct _WapiHandle_event event;
88 struct _WapiHandle_file file;
89 struct _WapiHandle_find find;
90 struct _WapiHandle_mutex mutex;
91 struct _WapiHandle_sem sem;
92 struct _WapiHandle_socket sock;
93 struct _WapiHandle_thread thread;
94 struct _WapiHandle_process process;
98 #define _WAPI_MAX_HANDLES 4096
99 #define _WAPI_HANDLE_INVALID (gpointer)-1
102 * This is the layout of the shared memory segment
104 struct _WapiHandleShared_list
106 guchar daemon[MONO_SIZEOF_SUNPATH];
107 _wapi_daemon_status daemon_running;
109 #ifdef _POSIX_THREAD_PROCESS_SHARED
110 mono_mutex_t signal_mutex;
111 pthread_cond_t signal_cond;
113 struct _WapiHandleShared handles[_WAPI_MAX_HANDLES];
114 guchar scratch_base[0];
117 struct _WapiHandlePrivate
121 struct _WapiHandlePrivate_event event;
122 struct _WapiHandlePrivate_file file;
123 struct _WapiHandlePrivate_find find;
124 struct _WapiHandlePrivate_mutex mutex;
125 struct _WapiHandlePrivate_sem sem;
126 struct _WapiHandlePrivate_socket sock;
127 struct _WapiHandlePrivate_thread thread;
128 struct _WapiHandlePrivate_process process;
132 /* Per-process handle info. For lookup convenience, each index matches
133 * the corresponding shared data.
135 struct _WapiHandlePrivate_list
137 #ifndef _POSIX_THREAD_PROCESS_SHARED
138 mono_mutex_t signal_mutex;
139 pthread_cond_t signal_cond;
141 struct _WapiHandlePrivate handles[_WAPI_MAX_HANDLES];
145 #endif /* _WAPI_PRIVATE_H_ */