Merge pull request #3337 from akoeplinger/fix-alpine
[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 /* There doesn't seem to be a defined symbol for this */
24 #define _WAPI_THREAD_CURRENT (gpointer)0xFFFFFFFE
25
26 extern gboolean _wapi_has_shut_down;
27
28 typedef struct 
29 {
30         gchar name[MAX_PATH + 1];
31 } WapiSharedNamespace;
32
33 #include <mono/io-layer/event-private.h>
34 #include <mono/io-layer/io-private.h>
35 #include <mono/io-layer/mutex-private.h>
36 #include <mono/io-layer/semaphore-private.h>
37 #include <mono/io-layer/socket-private.h>
38 #include <mono/io-layer/process-private.h>
39 #include <mono/utils/w32handle.h>
40
41 struct _WapiHandle_shared_ref
42 {
43         /* This will be split 16:16 with the shared file segment in
44          * the top half, when I implement space increases
45          */
46         guint32 offset;
47 };
48
49 #define _WAPI_SHARED_SEM_NAMESPACE 0
50 /*#define _WAPI_SHARED_SEM_COLLECTION 1*/
51 #define _WAPI_SHARED_SEM_FILESHARE 2
52 #define _WAPI_SHARED_SEM_PROCESS_COUNT_LOCK 6
53 #define _WAPI_SHARED_SEM_PROCESS_COUNT 7
54 #define _WAPI_SHARED_SEM_COUNT 8        /* Leave some future expansion space */
55
56 struct _WapiFileShare
57 {
58 #ifdef WAPI_FILE_SHARE_PLATFORM_EXTRA_DATA
59         WAPI_FILE_SHARE_PLATFORM_EXTRA_DATA
60 #endif
61         guint64 device;
62         guint64 inode;
63         pid_t opened_by_pid;
64         guint32 sharemode;
65         guint32 access;
66         guint32 handle_refs;
67         guint32 timestamp;
68 };
69
70 typedef struct _WapiFileShare _WapiFileShare;
71
72 gpointer
73 _wapi_search_handle_namespace (MonoW32HandleType type, gchar *utf8_name);
74
75 static inline int _wapi_namespace_lock (void)
76 {
77         return(_wapi_shm_sem_lock (_WAPI_SHARED_SEM_NAMESPACE));
78 }
79
80 /* This signature makes it easier to use in pthread cleanup handlers */
81 static inline int _wapi_namespace_unlock (gpointer data G_GNUC_UNUSED)
82 {
83         return(_wapi_shm_sem_unlock (_WAPI_SHARED_SEM_NAMESPACE));
84 }
85
86 #endif /* _WAPI_PRIVATE_H_ */