2 * handles-private.h: Internal operations on handles
5 * Dick Porter (dick@ximian.com)
7 * (C) 2002-2006 Novell, Inc.
10 #ifndef _WAPI_HANDLES_PRIVATE_H_
11 #define _WAPI_HANDLES_PRIVATE_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>
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
),
38 gpointer
*handle_specific
,
39 gboolean search_shared
);
40 extern gpointer
_wapi_search_handle_namespace (WapiHandleType type
,
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
,
55 extern void _wapi_handle_ops_prewait (gpointer handle
);
57 extern gboolean
_wapi_handle_count_signalled_handles (guint32 numhandles
,
62 extern void _wapi_handle_unlock_handles (guint32 numhandles
,
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
),
72 _wapi_handle_type (gpointer handle
);
75 _wapi_handle_set_signal_state (gpointer handle
, gboolean state
, gboolean broadcast
);
78 _wapi_handle_issignalled (gpointer handle
);
81 _wapi_handle_lock_signal_mutex (void);
84 _wapi_handle_unlock_signal_mutex (void);
87 _wapi_handle_lock_handle (gpointer handle
);
90 _wapi_handle_trylock_handle (gpointer handle
);
93 _wapi_handle_unlock_handle (gpointer handle
);
95 static inline void _wapi_handle_spin (guint32 ms
)
97 struct timespec sleepytime
;
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_ */