Escape the .file path name generated in the asembly code. clang does not mind, but...
[mono.git] / mono / io-layer / wapi-private.h
index 5d7305f562a2087b2145b852741c4145dcc0d364..f982d860607f49e1ae291b6d0b3ca7e123670c75 100644 (file)
@@ -4,7 +4,7 @@
  * Author:
  *     Dick Porter (dick@ximian.com)
  *
- * (C) 2002 Ximian, Inc.
+ * (C) 2002-2006 Novell, Inc.
  */
 
 #ifndef _WAPI_PRIVATE_H_
 
 #include <config.h>
 #include <glib.h>
+#include <sys/stat.h>
 
 #include <mono/io-layer/handles.h>
 #include <mono/io-layer/io.h>
-#include <mono/io-layer/daemon-private.h>
-
-/* Catch this here rather than corrupt the shared data at runtime */
-#if MONO_SIZEOF_SUNPATH==0
-#error configure failed to discover size of unix socket path
-#endif
 
 /* Increment this whenever an incompatible change is made to the
  * shared handle structure.
  */
-#define _WAPI_HANDLE_VERSION 4
+#define _WAPI_HANDLE_VERSION 12
 
 typedef enum {
        WAPI_HANDLE_UNUSED=0,
@@ -40,21 +35,26 @@ typedef enum {
        WAPI_HANDLE_PROCESS,
        WAPI_HANDLE_PIPE,
        WAPI_HANDLE_NAMEDMUTEX,
+       WAPI_HANDLE_NAMEDSEM,
+       WAPI_HANDLE_NAMEDEVENT,
        WAPI_HANDLE_COUNT
 } WapiHandleType;
 
 extern const char *_wapi_handle_typename[];
 
-#define _WAPI_SHARED_HANDLE(type) (type == WAPI_HANDLE_THREAD || \
-                                  type == WAPI_HANDLE_PROCESS || \
-                                  type == WAPI_HANDLE_NAMEDMUTEX)
+#define _WAPI_SHARED_HANDLE(type) (type == WAPI_HANDLE_PROCESS || \
+                                  type == WAPI_HANDLE_NAMEDMUTEX || \
+                                  type == WAPI_HANDLE_NAMEDSEM || \
+                                  type == WAPI_HANDLE_NAMEDEVENT)
 
 #define _WAPI_FD_HANDLE(type) (type == WAPI_HANDLE_FILE || \
                               type == WAPI_HANDLE_CONSOLE || \
                               type == WAPI_HANDLE_SOCKET || \
                               type == WAPI_HANDLE_PIPE)
 
-#define _WAPI_SHARED_NAMESPACE(type) (type == WAPI_HANDLE_NAMEDMUTEX)
+#define _WAPI_SHARED_NAMESPACE(type) (type == WAPI_HANDLE_NAMEDMUTEX || \
+                                     type == WAPI_HANDLE_NAMEDSEM || \
+                                     type == WAPI_HANDLE_NAMEDEVENT)
 
 typedef struct 
 {
@@ -64,12 +64,13 @@ typedef struct
 typedef enum {
        WAPI_HANDLE_CAP_WAIT=0x01,
        WAPI_HANDLE_CAP_SIGNAL=0x02,
-       WAPI_HANDLE_CAP_OWN=0x04
+       WAPI_HANDLE_CAP_OWN=0x04,
+       WAPI_HANDLE_CAP_SPECIAL_WAIT=0x08
 } WapiHandleCapability;
 
 struct _WapiHandleOps 
 {
-       void (*close)(gpointer handle);
+       void (*close)(gpointer handle, gpointer data);
 
        /* SignalObjectAndWait */
        void (*signal)(gpointer signal);
@@ -85,6 +86,19 @@ struct _WapiHandleOps
         * 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>
@@ -103,7 +117,7 @@ struct _WapiHandle_shared_ref
        guint32 offset;
 };
 
-#define _WAPI_HANDLE_INITIAL_COUNT 4096
+#define _WAPI_HANDLE_INITIAL_COUNT 256
 
 struct _WapiHandleUnshared
 {
@@ -121,40 +135,40 @@ struct _WapiHandleUnshared
                struct _WapiHandle_mutex mutex;
                struct _WapiHandle_sem sem;
                struct _WapiHandle_socket sock;
+               struct _WapiHandle_thread thread;
                struct _WapiHandle_shared_ref shared;
        } u;
 };
 
-struct _WapiHandleSharedMetadata
-{
-       volatile guint32 offset;
-       guint32 timestamp;
-       volatile gboolean signalled;
-       volatile guint32 checking;
-};
-
 struct _WapiHandleShared
 {
        WapiHandleType type;
-       gboolean stale;
+       guint32 timestamp;
+       guint32 handle_refs;
+       volatile gboolean signalled;
        
        union
        {
-               struct _WapiHandle_thread thread;
                struct _WapiHandle_process process;
                struct _WapiHandle_namedmutex namedmutex;
+               struct _WapiHandle_namedsem namedsem;
+               struct _WapiHandle_namedevent namedevent;
        } u;
 };
 
+#define _WAPI_SHARED_SEM_NAMESPACE 0
+/*#define _WAPI_SHARED_SEM_COLLECTION 1*/
+#define _WAPI_SHARED_SEM_FILESHARE 2
+#define _WAPI_SHARED_SEM_SHARED_HANDLES 3
+#define _WAPI_SHARED_SEM_PROCESS_COUNT_LOCK 6
+#define _WAPI_SHARED_SEM_PROCESS_COUNT 7
+#define _WAPI_SHARED_SEM_COUNT 8       /* Leave some future expansion space */
+
 struct _WapiHandleSharedLayout
 {
-       guint32 namespace_check;
-       volatile guint32 signal_count;
-
-       guint32 master_timestamp;
        volatile guint32 collection_count;
+       volatile key_t sem_key;
        
-       struct _WapiHandleSharedMetadata metadata[_WAPI_HANDLE_INITIAL_COUNT];
        struct _WapiHandleShared handles[_WAPI_HANDLE_INITIAL_COUNT];
 };
 
@@ -162,17 +176,22 @@ struct _WapiHandleSharedLayout
 
 struct _WapiFileShare
 {
+#ifdef WAPI_FILE_SHARE_PLATFORM_EXTRA_DATA
+       WAPI_FILE_SHARE_PLATFORM_EXTRA_DATA
+#endif
        dev_t device;
        ino_t inode;
+       pid_t opened_by_pid;
        guint32 sharemode;
        guint32 access;
        guint32 handle_refs;
        guint32 timestamp;
 };
 
+typedef struct _WapiFileShare _WapiFileShare;
+
 struct _WapiFileShareLayout
 {
-       guint32 share_check;
        guint32 hwm;
        
        struct _WapiFileShare share_info[_WAPI_FILESHARE_SIZE];