2008-10-24 Mark Probst <mark.probst@gmail.com>
[mono.git] / mono / handles / hps.c
index 157d45f4f08b0019b931191867b0eb37c742da2f..506a8812a74c1942696e92eff1e6905f58c5a11f 100644 (file)
 
 static const guchar *unused_details (struct _WapiHandleShared *handle);
 static const guchar *unshared_details (struct _WapiHandleShared *handle);
-#if 0
 static const guchar *thread_details (struct _WapiHandleShared *handle);
-#endif
 static const guchar *namedmutex_details (struct _WapiHandleShared *handle);
+static const guchar *namedsem_details (struct _WapiHandleShared *handle);
+static const guchar *namedevent_details (struct _WapiHandleShared *handle);
 static const guchar *process_details (struct _WapiHandleShared *handle);
 
 /* This depends on the ordering of the enum WapiHandleType in
@@ -25,11 +25,7 @@ static const guchar * (*details[])(struct _WapiHandleShared *)=
        unused_details,
        unshared_details,               /* file */
        unshared_details,               /* console */
-#if 0
        thread_details,
-#else
-       unshared_details,               /* thread */
-#endif
        unshared_details,               /* sem */
        unshared_details,               /* mutex */
        unshared_details,               /* event */
@@ -38,6 +34,8 @@ static const guchar * (*details[])(struct _WapiHandleShared *)=
        process_details,
        unshared_details,               /* pipe */
        namedmutex_details,
+       namedsem_details,
+       namedevent_details,
        unused_details,
 };
 
@@ -45,7 +43,7 @@ int main (int argc, char **argv)
 {
        guint32 i;
        guint32 now;
-       
+
        _wapi_shared_layout = _wapi_shm_attach(WAPI_SHM_DATA);
        if (_wapi_shared_layout == NULL) {
                g_error ("Failed to attach shared memory!");
@@ -107,7 +105,6 @@ static const guchar *unshared_details (struct _WapiHandleShared *handle)
        return("unshared details");
 }
 
-#if 0
 static const guchar *thread_details (struct _WapiHandleShared *handle)
 {
        static guchar buf[80];
@@ -120,7 +117,6 @@ static const guchar *thread_details (struct _WapiHandleShared *handle)
        
        return(buf);
 }
-#endif
 
 static const guchar *namedmutex_details (struct _WapiHandleShared *handle)
 {
@@ -137,6 +133,35 @@ static const guchar *namedmutex_details (struct _WapiHandleShared *handle)
        return(buf);
 }
 
+static const guchar *namedsem_details (struct _WapiHandleShared *handle)
+{
+       static guchar buf[80];
+       gchar *name;
+       struct _WapiHandle_namedsem *sem = &handle->u.namedsem;
+       
+       name = sem->sharedns.name;
+       
+       g_snprintf (buf, sizeof(buf), "[%15s] val: %5u, max: %5d",
+                   name == NULL?(gchar *)"":name, sem->val, sem->max);
+
+       return(buf);
+}
+
+static const guchar *namedevent_details (struct _WapiHandleShared *handle)
+{
+       static guchar buf[80];
+       gchar *name;
+       struct _WapiHandle_namedevent *event = &handle->u.namedevent;
+       
+       name = event->sharedns.name;
+       
+       g_snprintf (buf, sizeof(buf), "[%15s] %s count: %5u",
+                   name == NULL?(gchar *)"":name,
+                   event->manual?"Manual":"Auto", event->set_count);
+
+       return(buf);
+}
+
 static const guchar *process_details (struct _WapiHandleShared *handle)
 {
        static guchar buf[80];