[io-layer] Move handles out of the io-layer to utils/w32handle
[mono.git] / mono / io-layer / wapi-private.h
1 /*
2  * wapi-private.h:  internal definitions of handles and shared memory layout
3  *
4  * Author:
5  *      Dick Porter (dick@ximian.com)
6  *
7  * (C) 2002-2006 Novell, Inc.
8  */
9
10 #ifndef _WAPI_PRIVATE_H_
11 #define _WAPI_PRIVATE_H_
12
13 #include <config.h>
14 #include <glib.h>
15 #include <sys/stat.h>
16
17 #include <mono/io-layer/wapi.h>
18 #include <mono/io-layer/io.h>
19 #include <mono/io-layer/shared.h>
20
21 #include <mono/utils/mono-os-mutex.h>
22
23 extern gboolean _wapi_has_shut_down;
24
25 typedef struct 
26 {
27         gchar name[MAX_PATH + 1];
28 } WapiSharedNamespace;
29
30 #include <mono/io-layer/event-private.h>
31 #include <mono/io-layer/io-private.h>
32 #include <mono/io-layer/mutex-private.h>
33 #include <mono/io-layer/semaphore-private.h>
34 #include <mono/io-layer/socket-private.h>
35 #include <mono/io-layer/thread-private.h>
36 #include <mono/io-layer/process-private.h>
37 #include <mono/utils/w32handle.h>
38
39 struct _WapiHandle_shared_ref
40 {
41         /* This will be split 16:16 with the shared file segment in
42          * the top half, when I implement space increases
43          */
44         guint32 offset;
45 };
46
47 #define _WAPI_SHARED_SEM_NAMESPACE 0
48 /*#define _WAPI_SHARED_SEM_COLLECTION 1*/
49 #define _WAPI_SHARED_SEM_FILESHARE 2
50 #define _WAPI_SHARED_SEM_PROCESS_COUNT_LOCK 6
51 #define _WAPI_SHARED_SEM_PROCESS_COUNT 7
52 #define _WAPI_SHARED_SEM_COUNT 8        /* Leave some future expansion space */
53
54 struct _WapiFileShare
55 {
56 #ifdef WAPI_FILE_SHARE_PLATFORM_EXTRA_DATA
57         WAPI_FILE_SHARE_PLATFORM_EXTRA_DATA
58 #endif
59         guint64 device;
60         guint64 inode;
61         pid_t opened_by_pid;
62         guint32 sharemode;
63         guint32 access;
64         guint32 handle_refs;
65         guint32 timestamp;
66 };
67
68 typedef struct _WapiFileShare _WapiFileShare;
69
70 pid_t
71 _wapi_getpid (void);
72
73 gpointer
74 _wapi_search_handle_namespace (MonoW32HandleType type, gchar *utf8_name);
75
76 static inline int _wapi_namespace_lock (void)
77 {
78         return(_wapi_shm_sem_lock (_WAPI_SHARED_SEM_NAMESPACE));
79 }
80
81 /* This signature makes it easier to use in pthread cleanup handlers */
82 static inline int _wapi_namespace_unlock (gpointer data G_GNUC_UNUSED)
83 {
84         return(_wapi_shm_sem_unlock (_WAPI_SHARED_SEM_NAMESPACE));
85 }
86
87 #endif /* _WAPI_PRIVATE_H_ */