[io-layer] Move file_share_hash to io.c
[mono-project.git] / mono / io-layer / handles-private.h
blobd2d3bad70ad24298c29b28425c8771914191db0c
1 /*
2 * handles-private.h: Internal operations on handles
4 * Author:
5 * Dick Porter (dick@ximian.com)
7 * (C) 2002-2006 Novell, Inc.
8 */
10 #ifndef _WAPI_HANDLES_PRIVATE_H_
11 #define _WAPI_HANDLES_PRIVATE_H_
13 #include <config.h>
14 #include <glib.h>
15 #include <errno.h>
16 #include <string.h>
17 #include <sys/types.h>
19 #include <mono/io-layer/wapi-private.h>
20 #include <mono/io-layer/shared.h>
21 #include <mono/utils/atomic.h>
23 #undef DEBUG
25 extern guint32 _wapi_fd_reserve;
26 extern gboolean _wapi_has_shut_down;
28 extern pid_t _wapi_getpid (void);
29 extern gpointer _wapi_handle_new (WapiHandleType type,
30 gpointer handle_specific);
31 extern gpointer _wapi_handle_new_fd (WapiHandleType type, int fd,
32 gpointer handle_specific);
33 extern gboolean _wapi_lookup_handle (gpointer handle, WapiHandleType type,
34 gpointer *handle_specific);
35 extern gpointer _wapi_search_handle (WapiHandleType type,
36 gboolean (*check)(gpointer, gpointer),
37 gpointer user_data,
38 gpointer *handle_specific,
39 gboolean search_shared);
40 extern gpointer _wapi_search_handle_namespace (WapiHandleType type,
41 gchar *utf8_name);
42 extern void _wapi_handle_ref (gpointer handle);
43 extern void _wapi_handle_unref (gpointer handle);
44 extern void _wapi_handle_register_capabilities (WapiHandleType type,
45 WapiHandleCapability caps);
46 extern gboolean _wapi_handle_test_capabilities (gpointer handle,
47 WapiHandleCapability caps);
48 extern void _wapi_handle_ops_close (gpointer handle, gpointer data);
49 extern void _wapi_handle_ops_signal (gpointer handle);
50 extern gboolean _wapi_handle_ops_own (gpointer handle);
51 extern gboolean _wapi_handle_ops_isowned (gpointer handle);
52 extern guint32 _wapi_handle_ops_special_wait (gpointer handle,
53 guint32 timeout,
54 gboolean alertable);
55 extern void _wapi_handle_ops_prewait (gpointer handle);
57 extern gboolean _wapi_handle_count_signalled_handles (guint32 numhandles,
58 gpointer *handles,
59 gboolean waitall,
60 guint32 *retcount,
61 guint32 *lowest);
62 extern void _wapi_handle_unlock_handles (guint32 numhandles,
63 gpointer *handles);
64 extern int _wapi_handle_timedwait_signal_handle (gpointer handle, guint32 timeout, gboolean poll, gboolean *alerted);
65 extern int _wapi_handle_timedwait_signal (guint32 timeout, gboolean poll, gboolean *alerted);
66 extern void _wapi_handle_dump (void);
67 extern void _wapi_handle_foreach (WapiHandleType type,
68 gboolean (*on_each)(gpointer test, gpointer user),
69 gpointer user_data);
71 WapiHandleType
72 _wapi_handle_type (gpointer handle);
74 void
75 _wapi_handle_set_signal_state (gpointer handle, gboolean state, gboolean broadcast);
77 gboolean
78 _wapi_handle_issignalled (gpointer handle);
80 int
81 _wapi_handle_lock_signal_mutex (void);
83 int
84 _wapi_handle_unlock_signal_mutex (void);
86 int
87 _wapi_handle_lock_handle (gpointer handle);
89 int
90 _wapi_handle_trylock_handle (gpointer handle);
92 int
93 _wapi_handle_unlock_handle (gpointer handle);
95 static inline void _wapi_handle_spin (guint32 ms)
97 struct timespec sleepytime;
99 g_assert (ms < 1000);
101 sleepytime.tv_sec = 0;
102 sleepytime.tv_nsec = ms * 1000000;
104 nanosleep (&sleepytime, NULL);
107 static inline int _wapi_namespace_lock (void)
109 return(_wapi_shm_sem_lock (_WAPI_SHARED_SEM_NAMESPACE));
112 /* This signature makes it easier to use in pthread cleanup handlers */
113 static inline int _wapi_namespace_unlock (gpointer data G_GNUC_UNUSED)
115 return(_wapi_shm_sem_unlock (_WAPI_SHARED_SEM_NAMESPACE));
118 #endif /* _WAPI_HANDLES_PRIVATE_H_ */