[io-layer] Add typename and typesize handle operations
authorLudovic Henry <ludovic@xamarin.com>
Thu, 30 Jun 2016 14:37:32 +0000 (16:37 +0200)
committerLudovic Henry <ludovic@xamarin.com>
Tue, 12 Jul 2016 12:53:23 +0000 (14:53 +0200)
mono/io-layer/events.c
mono/io-layer/handles-private.h
mono/io-layer/handles.c
mono/io-layer/io.c
mono/io-layer/mutexes.c
mono/io-layer/processes.c
mono/io-layer/semaphores.c
mono/io-layer/sockets.c
mono/io-layer/wapi-private.h
mono/io-layer/wthreads.c

index bb0e26f678de18d6c70fb0fa87dc2d6a570de0a1..9f716db1b78796ba42b5ca16f035766ee5a15c06 100644 (file)
 static void event_signal(gpointer handle);
 static gboolean event_own (gpointer handle);
 static void event_details (gpointer data);
+static const gchar* event_typename (void);
+static gsize event_typesize (void);
 
 static void namedevent_signal (gpointer handle);
 static gboolean namedevent_own (gpointer handle);
 static void namedevent_details (gpointer data);
+static const gchar* namedevent_typename (void);
+static gsize namedevent_typesize (void);
 
 struct _WapiHandleOps _wapi_event_ops = {
        NULL,                   /* close */
@@ -35,7 +39,9 @@ struct _WapiHandleOps _wapi_event_ops = {
        NULL,                   /* is_owned */
        NULL,                   /* special_wait */
        NULL,                   /* prewait */
-       event_details   /* details */
+       event_details,  /* details */
+       event_typename, /* typename */
+       event_typesize, /* typesize */
 };
 
 struct _WapiHandleOps _wapi_namedevent_ops = {
@@ -45,7 +51,9 @@ struct _WapiHandleOps _wapi_namedevent_ops = {
        NULL,                   /* is_owned */
        NULL,                   /* special_wait */
        NULL,                   /* prewait */
-       namedevent_details      /* details */
+       namedevent_details,     /* details */
+       namedevent_typename, /* typename */
+       namedevent_typesize, /* typesize */
 };
 
 static mono_once_t event_ops_once=MONO_ONCE_INIT;
@@ -129,6 +137,26 @@ static void namedevent_details (gpointer data)
                namedevent->e.manual ? "TRUE" : "FALSE", namedevent->e.set_count, namedevent->sharedns.name);
 }
 
+static const gchar* event_typename (void)
+{
+       return "Event";
+}
+
+static gsize event_typesize (void)
+{
+       return sizeof (struct _WapiHandle_event);
+}
+
+static const gchar* namedevent_typename (void)
+{
+       return "N.Event";
+}
+
+static gsize namedevent_typesize (void)
+{
+       return sizeof (struct _WapiHandle_namedevent);
+}
+
 static gpointer event_handle_create (struct _WapiHandle_event *event_handle, WapiHandleType type, gboolean manual, gboolean initial)
 {
        gpointer handle;
index e73392ae0c77cf39940f961d753d4ccfc5ca7e5b..de64dc3e94a38fcf613d333c87eb9c43450ee7eb 100644 (file)
@@ -58,6 +58,8 @@ extern guint32 _wapi_handle_ops_special_wait (gpointer handle,
                                              gboolean alertable);
 extern void _wapi_handle_ops_prewait (gpointer handle);
 extern void _wapi_handle_ops_details (WapiHandleType type, gpointer data);
+extern const gchar* _wapi_handle_ops_typename (WapiHandleType type);
+extern gsize _wapi_handle_ops_typesize (WapiHandleType type);
 
 extern gboolean _wapi_handle_count_signalled_handles (guint32 numhandles,
                                                      gpointer *handles,
index e0bc5751cdc3ee1758f16d0e8f7a4ae33e78ffc3..01b80ff2fc96940ef59b530eeed0c9e4c07d7312 100644 (file)
@@ -106,24 +106,6 @@ static struct _WapiHandleOps *handle_ops[WAPI_HANDLE_COUNT]={
        &_wapi_namedevent_ops,
 };
 
-const char *_wapi_handle_typename[] = {
-       "Unused",
-       "File",
-       "Console",
-       "Thread",
-       "Sem",
-       "Mutex",
-       "Event",
-       "Socket",
-       "Find",
-       "Process",
-       "Pipe",
-       "N.Mutex",
-       "N.Sem",
-       "N.Event",
-       "Error!!"
-};
-
 /*
  * We can hold _WAPI_PRIVATE_MAX_SLOTS * _WAPI_HANDLE_INITIAL_COUNT handles.
  * If 4M handles are not enough... Oh, well... we will crash.
@@ -407,57 +389,10 @@ _wapi_handle_cleanup (void)
                g_free (_wapi_private_handles [i]);
 }
 
-static size_t _wapi_handle_struct_size (WapiHandleType type)
-{
-       size_t type_size;
-
-       switch (type) {
-               case WAPI_HANDLE_FILE: case WAPI_HANDLE_CONSOLE: case WAPI_HANDLE_PIPE:
-                       type_size = sizeof (struct _WapiHandle_file);
-                       break;
-               case WAPI_HANDLE_THREAD:
-                       type_size = sizeof (struct _WapiHandle_thread);
-                       break;
-               case WAPI_HANDLE_SEM:
-                       type_size = sizeof (struct _WapiHandle_sem);
-                       break;
-               case WAPI_HANDLE_MUTEX:
-                       type_size = sizeof (struct _WapiHandle_mutex);
-                       break;
-               case WAPI_HANDLE_EVENT:
-                       type_size = sizeof (struct _WapiHandle_event);
-                       break;
-               case WAPI_HANDLE_SOCKET:
-                       type_size = sizeof (struct _WapiHandle_socket);
-                       break;
-               case WAPI_HANDLE_FIND:
-                       type_size = sizeof (struct _WapiHandle_find);
-                       break;
-               case WAPI_HANDLE_PROCESS:
-                       type_size = sizeof (struct _WapiHandle_process);
-                       break;
-               case WAPI_HANDLE_NAMEDMUTEX:
-                       type_size = sizeof (struct _WapiHandle_namedmutex);
-                       break;
-               case WAPI_HANDLE_NAMEDSEM:
-                       type_size = sizeof (struct _WapiHandle_namedsem);
-                       break;
-               case WAPI_HANDLE_NAMEDEVENT:
-                       type_size = sizeof (struct _WapiHandle_namedevent);
-                       break;
-
-               default:
-                       g_error ("Unknown WapiHandleType: %d\n", type);
-       }
-
-       return type_size;
-}
-
 static void _wapi_handle_init_handle (WapiHandleBase *handle,
                               WapiHandleType type, gpointer handle_specific)
 {
        int thr_ret;
-       int type_size;
        
        g_assert (_wapi_has_shut_down == FALSE);
        
@@ -472,9 +407,8 @@ static void _wapi_handle_init_handle (WapiHandleBase *handle,
        g_assert (thr_ret == 0);
 
        if (handle_specific != NULL) {
-               type_size = _wapi_handle_struct_size (type);
                memcpy (&((struct _WapiHandleUnshared*) handle)->u, handle_specific,
-                       type_size);
+                       _wapi_handle_ops_typesize (type));
        }
 }
 
@@ -546,7 +480,7 @@ _wapi_handle_new (WapiHandleType type, gpointer handle_specific)
        g_assert (_wapi_has_shut_down == FALSE);
                
        MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Creating new handle of type %s", __func__,
-                  _wapi_handle_typename[type]);
+                  _wapi_handle_ops_typename (type));
 
        g_assert(!_WAPI_FD_HANDLE(type));
        
@@ -614,7 +548,7 @@ gpointer _wapi_handle_new_fd (WapiHandleType type, int fd,
        g_assert (_wapi_has_shut_down == FALSE);
        
        MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Creating new handle of type %s", __func__,
-                  _wapi_handle_typename[type]);
+                  _wapi_handle_ops_typename (type));
        
        g_assert(_WAPI_FD_HANDLE(type));
 
@@ -783,7 +717,7 @@ gpointer _wapi_search_handle_namespace (WapiHandleType type,
        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, _wapi_handle_typename[type]);
+                  utf8_name, _wapi_handle_ops_typename (type));
 
        thr_ret = mono_os_mutex_lock (&scan_mutex);
        g_assert (thr_ret == 0);
@@ -804,7 +738,7 @@ gpointer _wapi_search_handle_namespace (WapiHandleType type,
                                continue;
                        }
 
-                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: found a shared namespace handle at 0x%x (type %s)", __func__, i, _wapi_handle_typename[handle_data->type]);
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: found a shared namespace handle at 0x%x (type %s)", __func__, i, _wapi_handle_ops_typename (handle_data->type));
 
                        switch (handle_data->type) {
                        case WAPI_HANDLE_NAMEDMUTEX: sharedns = &((struct _WapiHandleUnshared*) handle_data)->u.namedmutex.sharedns; break;
@@ -819,7 +753,7 @@ gpointer _wapi_search_handle_namespace (WapiHandleType type,
                        if (strcmp (sharedns->name, utf8_name) == 0) {
                                if (handle_data->type != type) {
                                        /* Its the wrong type, so fail now */
-                                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle 0x%x matches name but is wrong type: %s", __func__, i, _wapi_handle_typename[handle_data->type]);
+                                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle 0x%x matches name but is wrong type: %s", __func__, i, _wapi_handle_ops_typename (handle_data->type));
                                        ret = _WAPI_HANDLE_INVALID;
                                        goto done;
                                } else {
@@ -859,7 +793,7 @@ void _wapi_handle_ref (gpointer handle)
        
 #ifdef DEBUG_REFS
        g_message ("%s: %s handle %p ref now %d",
-               __func__, _wapi_handle_typename[handle_data->type], handle, handle_data->ref);
+               __func__, _wapi_handle_ops_typename (handle_data->type), handle, handle_data->ref);
 #endif
 }
 
@@ -892,7 +826,7 @@ static void _wapi_handle_unref_full (gpointer handle, gboolean ignore_private_bu
        
 #ifdef DEBUG_REFS
        g_message ("%s: %s handle %p ref now %d (destroy %s)",
-               __func__, _wapi_handle_typename[handle_data->type], handle, handle_data->ref, destroy?"TRUE":"FALSE");
+               __func__, _wapi_handle_ops_typename (handle_data->type), handle, handle_data->ref, destroy?"TRUE":"FALSE");
 #endif
        
        if(destroy==TRUE) {
@@ -914,7 +848,7 @@ static void _wapi_handle_unref_full (gpointer handle, gboolean ignore_private_bu
                        sizeof (struct _WapiHandleUnshared));
 
                memset (&((struct _WapiHandleUnshared*) handle_data)->u, '\0',
-                       sizeof(((struct _WapiHandleUnshared*) handle_data)->u));
+                       _wapi_handle_ops_typesize (type));
 
                handle_data->type = WAPI_HANDLE_UNUSED;
 
@@ -1014,6 +948,20 @@ void _wapi_handle_ops_details (WapiHandleType type, gpointer data)
        }
 }
 
+const gchar* _wapi_handle_ops_typename (WapiHandleType type)
+{
+       g_assert (handle_ops [type]);
+       g_assert (handle_ops [type]->typename);
+       return handle_ops [type]->typename ();
+}
+
+gsize _wapi_handle_ops_typesize (WapiHandleType type)
+{
+       g_assert (handle_ops [type]);
+       g_assert (handle_ops [type]->typesize);
+       return handle_ops [type]->typesize ();
+}
+
 void _wapi_handle_ops_signal (gpointer handle)
 {
        guint32 idx = GPOINTER_TO_UINT(handle);
@@ -1311,7 +1259,7 @@ _wapi_handle_timedwait_signal_handle (gpointer handle, guint32 timeout, gboolean
        mono_mutex_t *mutex;
 
        MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: waiting for %p (type %s)", __func__, handle,
-                  _wapi_handle_typename[_wapi_handle_type (handle)]);
+                  _wapi_handle_ops_typename (_wapi_handle_type (handle)));
 
        if (alerted)
                *alerted = FALSE;
@@ -1389,7 +1337,7 @@ void _wapi_handle_dump (void)
                
                                g_print ("%3x [%7s] %s %d ",
                                                 i * _WAPI_HANDLE_INITIAL_COUNT + k,
-                                                _wapi_handle_typename[handle_data->type],
+                                                _wapi_handle_ops_typename (handle_data->type),
                                                 handle_data->signalled?"Sg":"Un",
                                                 handle_data->ref);
                                _wapi_handle_ops_details (handle_data->type, &((struct _WapiHandleUnshared*)handle_data)->u);
index 4f365cbe0a752e7ecc3d215173f07997f27c4a85..54582d33adb4e8234717e9d7f26aea1827b409d8 100644 (file)
@@ -158,6 +158,8 @@ _wapi_handle_get_or_set_share (guint64 device, guint64 inode, guint32 new_sharem
 
 static void file_close (gpointer handle, gpointer data);
 static void file_details (gpointer data);
+static const gchar* file_typename (void);
+static gsize file_typesize (void);
 static WapiFileType file_getfiletype(void);
 static gboolean file_read(gpointer handle, gpointer buffer,
                          guint32 numbytes, guint32 *bytesread,
@@ -187,11 +189,15 @@ struct _WapiHandleOps _wapi_file_ops = {
        NULL,                   /* is_owned */
        NULL,                   /* special_wait */
        NULL,                   /* prewait */
-       file_details    /* details */
+       file_details,   /* details */
+       file_typename,  /* typename */
+       file_typesize,  /* typesize */
 };
 
 static void console_close (gpointer handle, gpointer data);
 static void console_details (gpointer data);
+static const gchar* console_typename (void);
+static gsize console_typesize (void);
 static WapiFileType console_getfiletype(void);
 static gboolean console_read(gpointer handle, gpointer buffer,
                             guint32 numbytes, guint32 *bytesread,
@@ -210,11 +216,14 @@ struct _WapiHandleOps _wapi_console_ops = {
        NULL,                   /* is_owned */
        NULL,                   /* special_wait */
        NULL,                   /* prewait */
-       console_details /* details */
+       console_details,        /* details */
+       console_typename,       /* typename */
+       console_typesize,       /* typesize */
 };
 
-/* Find handle has no ops.
- */
+static const gchar* find_typename (void);
+static gsize find_typesize (void);
+
 struct _WapiHandleOps _wapi_find_ops = {
        NULL,                   /* close */
        NULL,                   /* signal */
@@ -222,11 +231,15 @@ struct _WapiHandleOps _wapi_find_ops = {
        NULL,                   /* is_owned */
        NULL,                   /* special_wait */
        NULL,                   /* prewait */
-       NULL                    /* details */
+       NULL,                   /* details */
+       find_typename,  /* typename */
+       find_typesize,  /* typesize */
 };
 
 static void pipe_close (gpointer handle, gpointer data);
 static void pipe_details (gpointer data);
+static const gchar* pipe_typename (void);
+static gsize pipe_typesize (void);
 static WapiFileType pipe_getfiletype (void);
 static gboolean pipe_read (gpointer handle, gpointer buffer, guint32 numbytes,
                           guint32 *bytesread, WapiOverlapped *overlapped);
@@ -243,7 +256,9 @@ struct _WapiHandleOps _wapi_pipe_ops = {
        NULL,                   /* is_owned */
        NULL,                   /* special_wait */
        NULL,                   /* prewait */
-       pipe_details    /* details */
+       pipe_details,   /* details */
+       pipe_typename,  /* typename */
+       pipe_typesize,  /* typesize */
 };
 
 static const struct {
@@ -489,6 +504,16 @@ static void file_details (gpointer data)
                 file->attrs);
 }
 
+static const gchar* file_typename (void)
+{
+       return "File";
+}
+
+static gsize file_typesize (void)
+{
+       return sizeof (struct _WapiHandle_file);
+}
+
 static WapiFileType file_getfiletype(void)
 {
        return(FILE_TYPE_DISK);
@@ -1168,6 +1193,16 @@ static void console_details (gpointer data)
        file_details (data);
 }
 
+static const gchar* console_typename (void)
+{
+       return "Console";
+}
+
+static gsize console_typesize (void)
+{
+       return sizeof (struct _WapiHandle_file);
+}
+
 static WapiFileType console_getfiletype(void)
 {
        return(FILE_TYPE_CHAR);
@@ -1277,6 +1312,16 @@ static gboolean console_write(gpointer handle, gconstpointer buffer,
        return(TRUE);
 }
 
+static const gchar* find_typename (void)
+{
+       return "Find";
+}
+
+static gsize find_typesize (void)
+{
+       return sizeof (struct _WapiHandle_find);
+}
+
 static void pipe_close (gpointer handle, gpointer data)
 {
        struct _WapiHandle_file *pipe_handle = (struct _WapiHandle_file*)data;
@@ -1297,6 +1342,16 @@ static void pipe_details (gpointer data)
        file_details (data);
 }
 
+static const gchar* pipe_typename (void)
+{
+       return "Pipe";
+}
+
+static gsize pipe_typesize (void)
+{
+       return sizeof (struct _WapiHandle_file);
+}
+
 static WapiFileType pipe_getfiletype(void)
 {
        return(FILE_TYPE_PIPE);
index 382a0295e940cb423002653840f8df435acca0c0..28f66693f19c729ca114a181d5566dde7fc2d6e1 100644 (file)
@@ -26,12 +26,16 @@ static gboolean mutex_own (gpointer handle);
 static gboolean mutex_is_owned (gpointer handle);
 static void mutex_prewait (gpointer handle);
 static void mutex_details (gpointer data);
+static const gchar* mutex_typename (void);
+static gsize mutex_typesize (void);
 
 static void namedmutex_signal (gpointer handle);
 static gboolean namedmutex_own (gpointer handle);
 static gboolean namedmutex_is_owned (gpointer handle);
 static void namedmutex_prewait (gpointer handle);
 static void namedmutex_details (gpointer data);
+static const gchar* namedmutex_typename (void);
+static gsize namedmutex_typesize (void);
 
 struct _WapiHandleOps _wapi_mutex_ops = {
        NULL,                   /* close */
@@ -40,7 +44,9 @@ struct _WapiHandleOps _wapi_mutex_ops = {
        mutex_is_owned,         /* is_owned */
        NULL,                   /* special_wait */
        mutex_prewait,                  /* prewait */
-       mutex_details   /* details */
+       mutex_details,  /* details */
+       mutex_typename, /* typename */
+       mutex_typesize, /* typesize */
 };
 
 struct _WapiHandleOps _wapi_namedmutex_ops = {
@@ -50,7 +56,9 @@ struct _WapiHandleOps _wapi_namedmutex_ops = {
        namedmutex_is_owned,    /* is_owned */
        NULL,                   /* special_wait */
        namedmutex_prewait,     /* prewait */
-       namedmutex_details      /* details */
+       namedmutex_details,     /* details */
+       namedmutex_typename,    /* typename */
+       namedmutex_typesize,    /* typesize */
 };
 
 static mono_once_t mutex_ops_once=MONO_ONCE_INIT;
@@ -208,6 +216,26 @@ static void namedmutex_details (gpointer data)
 #endif
 }
 
+static const gchar* mutex_typename (void)
+{
+       return "Mutex";
+}
+
+static gsize mutex_typesize (void)
+{
+       return sizeof (struct _WapiHandle_mutex);
+}
+
+static const gchar* namedmutex_typename (void)
+{
+       return "N.Mutex";
+}
+
+static gsize namedmutex_typesize (void)
+{
+       return sizeof (struct _WapiHandle_namedmutex);
+}
+
 /* When a thread exits, any mutexes it still holds need to be signalled. */
 void _wapi_mutex_abandon (gpointer handle, pid_t pid, pthread_t tid)
 {
index c940c3b0292c960bf1a8e5ca53d55d4e17441425..d4b7d58d846c213864f4d96160cfc489a8e890c6 100644 (file)
@@ -130,6 +130,8 @@ extern char **environ;
 static guint32 process_wait (gpointer handle, guint32 timeout, gboolean alertable);
 static void process_close (gpointer handle, gpointer data);
 static void process_details (gpointer data);
+static const gchar* process_typename (void);
+static gsize process_typesize (void);
 static gboolean is_pid_valid (pid_t pid);
 
 #if !(defined(USE_OSX_LOADER) || defined(USE_BSD_LOADER) || defined(USE_HAIKU_LOADER))
@@ -144,7 +146,9 @@ struct _WapiHandleOps _wapi_process_ops = {
        NULL,                           /* is_owned */
        process_wait,                   /* special_wait */
        NULL,                           /* prewait */
-       process_details         /* details */
+       process_details,        /* details */
+       process_typename,       /* typename */
+       process_typesize,       /* typesize */
 };
 
 #if HAVE_SIGACTION
@@ -2666,6 +2670,16 @@ static void process_details (gpointer data)
                process_handle->id, process_handle->exited ? "true" : "false", process_handle->exitstatus);
 }
 
+static const gchar* process_typename (void)
+{
+       return "Process";
+}
+
+static gsize process_typesize (void)
+{
+       return sizeof (WapiHandle_process);
+}
+
 #if HAVE_SIGACTION
 MONO_SIGNAL_HANDLER_FUNC (static, mono_sigchld_signal_handler, (int _dummy, siginfo_t *info, void *context))
 {
index de49148ad3ce10d3505e2b4b8a58b1c87ccb2b35..62a384139d9a4b12d75dd7ed2692dd7c59285b5e 100644 (file)
 static void sema_signal(gpointer handle);
 static gboolean sema_own (gpointer handle);
 static void sema_details (gpointer data);
+static const gchar* sema_typename (void);
+static gsize sema_typesize (void);
 
 static void namedsema_signal (gpointer handle);
 static gboolean namedsema_own (gpointer handle);
 static void namedsema_details (gpointer data);
+static const gchar* namedsema_typename (void);
+static gsize namedsema_typesize (void);
 
 struct _WapiHandleOps _wapi_sem_ops = {
        NULL,                   /* close */
@@ -40,7 +44,9 @@ struct _WapiHandleOps _wapi_sem_ops = {
        NULL,                   /* is_owned */
        NULL,                   /* special_wait */
        NULL,                   /* prewait */
-       sema_details    /* details */
+       sema_details,   /* details */
+       sema_typename,  /* typename */
+       sema_typesize,  /* typesize */
 };
 
 struct _WapiHandleOps _wapi_namedsem_ops = {
@@ -50,7 +56,9 @@ struct _WapiHandleOps _wapi_namedsem_ops = {
        NULL,                   /* is_owned */
        NULL,                   /* special_wait */
        NULL,                   /* prewait */
-       namedsema_details       /* details */
+       namedsema_details,      /* details */
+       namedsema_typename,     /* typename */
+       namedsema_typesize,     /* typesize */
 };
 
 static mono_once_t sem_ops_once=MONO_ONCE_INIT;
@@ -127,6 +135,26 @@ static void namedsema_details (gpointer data)
        g_print ("val: %5u, max: %5d, name: \"%s\"", namedsem->s.val, namedsem->s.max, namedsem->sharedns.name);
 }
 
+static const gchar* sema_typename (void)
+{
+       return "Semaphore";
+}
+
+static gsize sema_typesize (void)
+{
+       return sizeof (struct _WapiHandle_sem);
+}
+
+static const gchar* namedsema_typename (void)
+{
+       return "N.Semaphore";
+}
+
+static gsize namedsema_typesize (void)
+{
+       return sizeof (struct _WapiHandle_namedsem);
+}
+
 static gpointer sem_handle_create (struct _WapiHandle_sem *sem_handle, WapiHandleType type, gint32 initial, gint32 max)
 {
        gpointer handle;
index d5a90ecb18f7d3c85a02e79a5edd298889492462..55050eab627b5a292e03829ef7d0eef32b5dcf28 100644 (file)
@@ -60,6 +60,8 @@ static guint32 in_cleanup = 0;
 
 static void socket_close (gpointer handle, gpointer data);
 static void socket_details (gpointer data);
+static const gchar* socket_typename (void);
+static gsize socket_typesize (void);
 
 struct _WapiHandleOps _wapi_socket_ops = {
        socket_close,           /* close */
@@ -68,7 +70,9 @@ struct _WapiHandleOps _wapi_socket_ops = {
        NULL,                   /* is_owned */
        NULL,                   /* special_wait */
        NULL,                   /* prewait */
-       socket_details  /* details */
+       socket_details, /* details */
+       socket_typename,        /* typename */
+       socket_typesize,        /* typesize */
 };
 
 static mono_once_t socket_ops_once=MONO_ONCE_INIT;
@@ -112,6 +116,16 @@ static void socket_details (gpointer data)
        /* FIXME: do something */
 }
 
+static const gchar* socket_typename (void)
+{
+       return "Socket";
+}
+
+static gsize socket_typesize (void)
+{
+       return sizeof (struct _WapiHandle_socket);
+}
+
 static gboolean
 cleanup_close (gpointer handle, gpointer data)
 {
index 824a69170337b56ca418d9824e47634cef313ba9..450bea2cb59a408f1362f8777e7c44ffa21a89aa 100644 (file)
@@ -97,6 +97,12 @@ struct _WapiHandleOps
 
        /* Called when dumping the handles */
        void (*details)(gpointer data);
+
+       /* Called to get the name of the handle type */
+       const gchar* (*typename) (void);
+
+       /* Called to get the size of the handle type */
+       gsize (*typesize) (void);
 };
 
 #include <mono/io-layer/event-private.h>
index 24fafb98daf1c0388e0ddb739aec91d02036c69f..afb643e8299ae24016dcaca3e45b14814d1deeba 100644 (file)
@@ -39,6 +39,8 @@
 #endif
 
 static void thread_details (gpointer data);
+static const gchar* thread_typename (void);
+static gsize thread_typesize (void);
 
 struct _WapiHandleOps _wapi_thread_ops = {
        NULL,                           /* close */
@@ -47,7 +49,9 @@ struct _WapiHandleOps _wapi_thread_ops = {
        NULL,                           /* is_owned */
        NULL,                           /* special_wait */
        NULL,                           /* prewait */
-       thread_details          /* details */
+       thread_details,         /* details */
+       thread_typename,        /* typename */
+       thread_typesize,        /* typesize */
 };
 
 static mono_once_t thread_ops_once = MONO_ONCE_INIT;
@@ -66,6 +70,16 @@ static void thread_details (gpointer data)
                thread->id, thread->owned_mutexes->len, thread->priority);
 }
 
+static const gchar* thread_typename (void)
+{
+       return "Thread";
+}
+
+static gsize thread_typesize (void)
+{
+       return sizeof (WapiHandle_thread);
+}
+
 void
 _wapi_thread_cleanup (void)
 {