X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmetadata%2Fw32handle.h;h=741dd0832356212c99d603faf744da68e4ffc4cf;hb=f2dc087948dbcd319f276b6800c5496073d9d0a0;hp=54386fabeb15e2ccc70872eba4f4cef1d5918ffe;hpb=e5bf6d76129738d72c8227620ea2536f478cf736;p=mono.git diff --git a/mono/metadata/w32handle.h b/mono/metadata/w32handle.h index 54386fabeb1..741dd083235 100644 --- a/mono/metadata/w32handle.h +++ b/mono/metadata/w32handle.h @@ -1,3 +1,6 @@ +/** + * \file + */ #ifndef _MONO_METADATA_W32HANDLE_H_ #define _MONO_METADATA_W32HANDLE_H_ @@ -5,12 +8,20 @@ #include #include +#ifdef HOST_WIN32 +#include +#endif + #ifndef INVALID_HANDLE_VALUE #define INVALID_HANDLE_VALUE (gpointer)-1 #endif #define MONO_W32HANDLE_MAXIMUM_WAIT_OBJECTS 64 +#ifndef MONO_INFINITE_WAIT +#define MONO_INFINITE_WAIT ((guint32) 0xFFFFFFFF) +#endif + typedef enum { MONO_W32HANDLE_UNUSED = 0, MONO_W32HANDLE_FILE, @@ -41,31 +52,31 @@ typedef struct { void (*close)(gpointer handle, gpointer data); - /* SignalObjectAndWait */ + /* mono_w32handle_signal_and_wait */ void (*signal)(gpointer signal); - /* Called by WaitForSingleObject and WaitForMultipleObjects, + /* Called by mono_w32handle_wait_one and mono_w32handle_wait_multiple, * with the handle locked (shared handles aren't locked.) * Returns TRUE if ownership was established, false otherwise. - * If TRUE, *statuscode contains a status code such as + * If TRUE, *abandoned contains a status code such as * WAIT_OBJECT_0 or WAIT_ABANDONED_0. */ - gboolean (*own_handle)(gpointer handle, guint32 *statuscode); + gboolean (*own_handle)(gpointer handle, gboolean *abandoned); - /* Called by WaitForSingleObject and WaitForMultipleObjects, if the + /* Called by mono_w32handle_wait_one and mono_w32handle_wait_multiple, if the * handle in question is "ownable" (ie mutexes), to see if the current * thread already owns this handle */ gboolean (*is_owned)(gpointer handle); - /* Called by WaitForSingleObject and WaitForMultipleObjects, + /* Called by mono_w32handle_wait_one and mono_w32handle_wait_multiple, * if the handle in question needs a special wait function * instead of using the normal handle signal mechanism. - * Returns the WaitForSingleObject return code. + * Returns the mono_w32handle_wait_one return code. */ MonoW32HandleWaitRet (*special_wait)(gpointer handle, guint32 timeout, gboolean *alerted); - /* Called by WaitForSingleObject and WaitForMultipleObjects, + /* Called by mono_w32handle_wait_one and mono_w32handle_wait_multiple, * if the handle in question needs some preprocessing before the * signal wait. */ @@ -105,9 +116,15 @@ mono_w32handle_new (MonoW32HandleType type, gpointer handle_specific); gpointer mono_w32handle_new_fd (MonoW32HandleType type, int fd, gpointer handle_specific); +gboolean +mono_w32handle_close (gpointer handle); + MonoW32HandleType mono_w32handle_get_type (gpointer handle); +const gchar* +mono_w32handle_get_typename (MonoW32HandleType type); + gboolean mono_w32handle_lookup (gpointer handle, MonoW32HandleType type, gpointer *handle_specific); @@ -130,31 +147,7 @@ gboolean mono_w32handle_test_capabilities (gpointer handle, MonoW32HandleCapability caps); void -mono_w32handle_ops_close (gpointer handle, gpointer data); - -void -mono_w32handle_ops_signal (gpointer handle); - -gboolean -mono_w32handle_ops_own (gpointer handle, guint32 *statuscode); - -gboolean -mono_w32handle_ops_isowned (gpointer handle); - -MonoW32HandleWaitRet -mono_w32handle_ops_specialwait (gpointer handle, guint32 timeout, gboolean *alerted); - -void -mono_w32handle_ops_prewait (gpointer handle); - -void -mono_w32handle_ops_details (MonoW32HandleType type, gpointer data); - -const gchar* -mono_w32handle_ops_typename (MonoW32HandleType type); - -gsize -mono_w32handle_ops_typesize (MonoW32HandleType type); +mono_w32handle_force_close (gpointer handle, gpointer data); void mono_w32handle_set_signal_state (gpointer handle, gboolean state, gboolean broadcast); @@ -180,4 +173,24 @@ mono_w32handle_wait_multiple (gpointer *handles, gsize nhandles, gboolean waital MonoW32HandleWaitRet mono_w32handle_signal_and_wait (gpointer signal_handle, gpointer wait_handle, guint32 timeout, gboolean alertable); +#ifdef HOST_WIN32 +static inline MonoW32HandleWaitRet +mono_w32handle_convert_wait_ret (guint32 res, guint32 numobjects) +{ + if (res >= WAIT_OBJECT_0 && res <= WAIT_OBJECT_0 + numobjects - 1) + return MONO_W32HANDLE_WAIT_RET_SUCCESS_0 + (res - WAIT_OBJECT_0); + else if (res >= WAIT_ABANDONED_0 && res <= WAIT_ABANDONED_0 + numobjects - 1) + return MONO_W32HANDLE_WAIT_RET_ABANDONED_0 + (res - WAIT_ABANDONED_0); + else if (res == WAIT_IO_COMPLETION) + return MONO_W32HANDLE_WAIT_RET_ALERTED; + else if (res == WAIT_TIMEOUT) + return MONO_W32HANDLE_WAIT_RET_TIMEOUT; + else if (res == WAIT_FAILED) + return MONO_W32HANDLE_WAIT_RET_FAILED; + else + g_error ("%s: unknown res value %d", __func__, res); +} +#endif + + #endif /* _MONO_METADATA_W32HANDLE_H_ */