#include "wapi.h"
-#include "event-private.h"
#include "io-trace.h"
#include "io.h"
-#include "mutex-private.h"
#include "process-private.h"
-#include "semaphore-private.h"
-#include "shared.h"
#include "socket-private.h"
#include "mono/utils/mono-lazy-init.h"
void
wapi_init (void)
{
- _wapi_shm_semaphores_init ();
_wapi_io_init ();
_wapi_processes_init ();
- _wapi_semaphore_init ();
- _wapi_mutex_init ();
- _wapi_event_init ();
_wapi_socket_init ();
}
return _wapi_pid;
}
-static gboolean
-_WAPI_SHARED_NAMESPACE (MonoW32HandleType type)
-{
- switch (type) {
- case MONO_W32HANDLE_NAMEDMUTEX:
- case MONO_W32HANDLE_NAMEDSEM:
- case MONO_W32HANDLE_NAMEDEVENT:
- return TRUE;
- default:
- return FALSE;
- }
-}
-
-typedef struct {
- gpointer ret;
- MonoW32HandleType type;
- gchar *utf8_name;
-} _WapiSearchHandleNamespaceData;
-
-static gboolean mono_w32handle_search_namespace_callback (gpointer handle, gpointer data, gpointer user_data)
-{
- _WapiSearchHandleNamespaceData *search_data;
- MonoW32HandleType type;
- WapiSharedNamespace *sharedns;
-
- type = mono_w32handle_get_type (handle);
- if (!_WAPI_SHARED_NAMESPACE (type))
- return FALSE;
-
- search_data = (_WapiSearchHandleNamespaceData*) user_data;
-
- switch (type) {
- case MONO_W32HANDLE_NAMEDMUTEX: sharedns = &((struct _WapiHandle_namedmutex*) data)->sharedns; break;
- case MONO_W32HANDLE_NAMEDSEM: sharedns = &((struct _WapiHandle_namedsem*) data)->sharedns; break;
- case MONO_W32HANDLE_NAMEDEVENT: sharedns = &((struct _WapiHandle_namedevent*) data)->sharedns; break;
- default:
- g_assert_not_reached ();
- }
-
- if (strcmp (sharedns->name, search_data->utf8_name) == 0) {
- if (type != search_data->type) {
- /* Its the wrong type, so fail now */
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p matches name but is wrong type: %s",
- __func__, handle, mono_w32handle_ops_typename (type));
- search_data->ret = INVALID_HANDLE_VALUE;
- } else {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p matches name and type",
- __func__, handle);
- search_data->ret = handle;
- }
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-/* Returns the offset of the metadata array, or INVALID_HANDLE_VALUE on error, or NULL for
- * not found
- */
-gpointer _wapi_search_handle_namespace (MonoW32HandleType type, gchar *utf8_name)
-{
- _WapiSearchHandleNamespaceData search_data;
-
- g_assert(_WAPI_SHARED_NAMESPACE(type));
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Lookup for handle named [%s] type %s",
- __func__, utf8_name, mono_w32handle_ops_typename (type));
-
- search_data.ret = NULL;
- search_data.type = type;
- search_data.utf8_name = utf8_name;
- mono_w32handle_foreach (mono_w32handle_search_namespace_callback, &search_data);
- return search_data.ret;
-}
-
/* Lots more to implement here, but this is all we need at the moment */
gboolean
DuplicateHandle (gpointer srcprocess, gpointer src, gpointer targetprocess, gpointer *target,