[io-layer] Move WapiHandleType and WapiHandleOps to handles-private.h
[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/handles.h>
19 #include <mono/io-layer/handles-private.h>
20 #include <mono/io-layer/io.h>
21 #include <mono/io-layer/shared.h>
22
23 #include <mono/utils/mono-os-mutex.h>
24
25 extern gboolean _wapi_has_shut_down;
26
27 extern const char *_wapi_handle_typename[];
28
29 #define _WAPI_FD_HANDLE(type) (type == WAPI_HANDLE_FILE || \
30                                type == WAPI_HANDLE_CONSOLE || \
31                                type == WAPI_HANDLE_SOCKET || \
32                                type == WAPI_HANDLE_PIPE)
33
34 #define _WAPI_SHARED_NAMESPACE(type) (type == WAPI_HANDLE_NAMEDMUTEX || \
35                                       type == WAPI_HANDLE_NAMEDSEM || \
36                                       type == WAPI_HANDLE_NAMEDEVENT)
37
38 typedef struct 
39 {
40         gchar name[MAX_PATH + 1];
41 } WapiSharedNamespace;
42
43 #include <mono/io-layer/event-private.h>
44 #include <mono/io-layer/io-private.h>
45 #include <mono/io-layer/mutex-private.h>
46 #include <mono/io-layer/semaphore-private.h>
47 #include <mono/io-layer/socket-private.h>
48 #include <mono/io-layer/thread-private.h>
49 #include <mono/io-layer/process-private.h>
50
51 struct _WapiHandle_shared_ref
52 {
53         /* This will be split 16:16 with the shared file segment in
54          * the top half, when I implement space increases
55          */
56         guint32 offset;
57 };
58
59 #define _WAPI_SHARED_SEM_NAMESPACE 0
60 /*#define _WAPI_SHARED_SEM_COLLECTION 1*/
61 #define _WAPI_SHARED_SEM_FILESHARE 2
62 #define _WAPI_SHARED_SEM_PROCESS_COUNT_LOCK 6
63 #define _WAPI_SHARED_SEM_PROCESS_COUNT 7
64 #define _WAPI_SHARED_SEM_COUNT 8        /* Leave some future expansion space */
65
66 struct _WapiFileShare
67 {
68 #ifdef WAPI_FILE_SHARE_PLATFORM_EXTRA_DATA
69         WAPI_FILE_SHARE_PLATFORM_EXTRA_DATA
70 #endif
71         guint64 device;
72         guint64 inode;
73         pid_t opened_by_pid;
74         guint32 sharemode;
75         guint32 access;
76         guint32 handle_refs;
77         guint32 timestamp;
78 };
79
80 typedef struct _WapiFileShare _WapiFileShare;
81
82 #define _WAPI_HANDLE_INVALID (gpointer)-1
83
84 pid_t
85 _wapi_getpid (void);
86
87 gpointer
88 _wapi_search_handle_namespace (WapiHandleType type, gchar *utf8_name);
89
90 static inline int _wapi_namespace_lock (void)
91 {
92         return(_wapi_shm_sem_lock (_WAPI_SHARED_SEM_NAMESPACE));
93 }
94
95 /* This signature makes it easier to use in pthread cleanup handlers */
96 static inline int _wapi_namespace_unlock (gpointer data G_GNUC_UNUSED)
97 {
98         return(_wapi_shm_sem_unlock (_WAPI_SHARED_SEM_NAMESPACE));
99 }
100
101 #endif /* _WAPI_PRIVATE_H_ */