[io-layer] Remove pseudo global handle
[mono.git] / mono / io-layer / wapi-private.h
index 4123152e4bb1124f4c402ff11b77a22087c223ef..7df49b9b1a5961dbe1771215b1fdda420efe3dd8 100644 (file)
 
 #include <mono/io-layer/wapi.h>
 #include <mono/io-layer/handles.h>
+#include <mono/io-layer/handles-private.h>
 #include <mono/io-layer/io.h>
+#include <mono/io-layer/shared.h>
 
 #include <mono/utils/mono-os-mutex.h>
 
-/* Increment this whenever an incompatible change is made to the
- * shared handle structure.
- */
-#define _WAPI_HANDLE_VERSION 12
-
-typedef enum {
-       WAPI_HANDLE_UNUSED=0,
-       WAPI_HANDLE_FILE,
-       WAPI_HANDLE_CONSOLE,
-       WAPI_HANDLE_THREAD,
-       WAPI_HANDLE_SEM,
-       WAPI_HANDLE_MUTEX,
-       WAPI_HANDLE_EVENT,
-       WAPI_HANDLE_SOCKET,
-       WAPI_HANDLE_FIND,
-       WAPI_HANDLE_PROCESS,
-       WAPI_HANDLE_PIPE,
-       WAPI_HANDLE_NAMEDMUTEX,
-       WAPI_HANDLE_NAMEDSEM,
-       WAPI_HANDLE_NAMEDEVENT,
-       WAPI_HANDLE_COUNT
-} WapiHandleType;
+extern gboolean _wapi_has_shut_down;
 
 extern const char *_wapi_handle_typename[];
 
@@ -59,46 +40,6 @@ typedef struct
        gchar name[MAX_PATH + 1];
 } WapiSharedNamespace;
 
-typedef enum {
-       WAPI_HANDLE_CAP_WAIT=0x01,
-       WAPI_HANDLE_CAP_SIGNAL=0x02,
-       WAPI_HANDLE_CAP_OWN=0x04,
-       WAPI_HANDLE_CAP_SPECIAL_WAIT=0x08
-} WapiHandleCapability;
-
-struct _WapiHandleOps 
-{
-       void (*close)(gpointer handle, gpointer data);
-
-       /* SignalObjectAndWait */
-       void (*signal)(gpointer signal);
-
-       /* Called by WaitForSingleObject and WaitForMultipleObjects,
-        * with the handle locked (shared handles aren't locked.)
-        * Returns TRUE if ownership was established, false otherwise.
-        */
-       gboolean (*own_handle)(gpointer handle);
-
-       /* Called by WaitForSingleObject and WaitForMultipleObjects, if the
-        * handle in question is "ownable" (ie mutexes), to see if the current
-        * thread already owns this handle
-        */
-       gboolean (*is_owned)(gpointer handle);
-
-       /* Called by WaitForSingleObject and WaitForMultipleObjects,
-        * if the handle in question needs a special wait function
-        * instead of using the normal handle signal mechanism.
-        * Returns the WaitForSingleObject return code.
-        */
-       guint32 (*special_wait)(gpointer handle, guint32 timeout, gboolean alertable);
-
-       /* Called by WaitForSingleObject and WaitForMultipleObjects,
-        * if the handle in question needs some preprocessing before the
-        * signal wait.
-        */
-       void (*prewait)(gpointer handle);
-};
-
 #include <mono/io-layer/event-private.h>
 #include <mono/io-layer/io-private.h>
 #include <mono/io-layer/mutex-private.h>
@@ -115,8 +56,6 @@ struct _WapiHandle_shared_ref
        guint32 offset;
 };
 
-#define _WAPI_HANDLE_INITIAL_COUNT 256
-
 #define _WAPI_SHARED_SEM_NAMESPACE 0
 /*#define _WAPI_SHARED_SEM_COLLECTION 1*/
 #define _WAPI_SHARED_SEM_FILESHARE 2
@@ -142,4 +81,21 @@ typedef struct _WapiFileShare _WapiFileShare;
 
 #define _WAPI_HANDLE_INVALID (gpointer)-1
 
+pid_t
+_wapi_getpid (void);
+
+gpointer
+_wapi_search_handle_namespace (WapiHandleType type, gchar *utf8_name);
+
+static inline int _wapi_namespace_lock (void)
+{
+       return(_wapi_shm_sem_lock (_WAPI_SHARED_SEM_NAMESPACE));
+}
+
+/* This signature makes it easier to use in pthread cleanup handlers */
+static inline int _wapi_namespace_unlock (gpointer data G_GNUC_UNUSED)
+{
+       return(_wapi_shm_sem_unlock (_WAPI_SHARED_SEM_NAMESPACE));
+}
+
 #endif /* _WAPI_PRIVATE_H_ */