2003-06-05 Dick Porter <dick@ximian.com>
authorDick Porter <dick@acm.org>
Thu, 5 Jun 2003 21:02:47 +0000 (21:02 -0000)
committerDick Porter <dick@acm.org>
Thu, 5 Jun 2003 21:02:47 +0000 (21:02 -0000)
* hps.c:
* shmdel.c:
* scratch.c: Update to new api

svn path=/trunk/mono/; revision=15138

mono/handles/ChangeLog
mono/handles/hps.c
mono/handles/scratch.c
mono/handles/shmdel.c

index f4ed279de037f48642a68f3c138d47bc5a509b44..570c79dd71dc3eff927b0bc392eb81380db77ace 100644 (file)
@@ -1,3 +1,8 @@
+2003-06-05  Dick Porter  <dick@ximian.com>
+
+       * hps.c:
+       * shmdel.c:
+       * scratch.c: Update to new api
 
 Sat Jun 1 13:54:29 CEST 2002 Paolo Molaro <lupus@ximian.com>
 
index 70ebaded67e6a6e8bc6257c3ad8361794de7c9ab..6ac75721905eb76e961fe22b60be90b64d2540ae 100644 (file)
@@ -56,21 +56,32 @@ static const guchar * (*details[])(struct _WapiHandleShared *)=
 
 int main (int argc, char **argv)
 {
-       guint32 idx;
+       guint32 handle_idx;
        gboolean success;
        
-       _wapi_shared_data=_wapi_shm_attach (&success);
+       _wapi_shared_data=g_new0 (struct _WapiHandleShared_list *, 1);
+       _wapi_shared_scratch=g_new0 (struct _WapiHandleScratch, 1);
+       
+       success=_wapi_shm_attach (&_wapi_shared_data[0],
+                                 &_wapi_shared_scratch);
        if(success==FALSE) {
                g_error ("Failed to attach shared memory!");
                exit (-1);
        }
        
        /* Make sure index 0 is actually unused */
-       for(idx=0; idx<_WAPI_MAX_HANDLES; idx++) {
-               struct _WapiHandleShared *shared=&_wapi_shared_data->handles[idx];
+       for(handle_idx=0; handle_idx<_wapi_shared_data[0]->num_segments * _WAPI_HANDLES_PER_SEGMENT; handle_idx++) {
+               guint32 segment, idx;
+               struct _WapiHandleShared *shared;
+
+               _wapi_handle_segment (GUINT_TO_POINTER (handle_idx), &segment,
+                                     &idx);
+               _wapi_handle_ensure_mapped (segment);
+               
+               shared=&_wapi_shared_data[segment]->handles[idx];
                
                if(shared->type!=WAPI_HANDLE_UNUSED) {
-                       g_print ("%4x [%7s] %4u %s (%s)\n", idx,
+                       g_print ("%6x [%7s] %4u %s (%s)\n", handle_idx,
                                 typename[shared->type], shared->ref,
                                 shared->signalled?"Sg":"Un",
                                 details[shared->type](shared));
@@ -91,7 +102,7 @@ static const guchar *file_details (struct _WapiHandleShared *handle)
        guchar *name;
        struct _WapiHandle_file *file=&handle->u.file;
        
-       name=_wapi_handle_scratch_lookup_as_string (file->filename);
+       name=_wapi_handle_scratch_lookup (file->filename);
        
        g_snprintf (buf, sizeof(buf),
                    "[%20s] acc: %c%c%c, shr: %c%c%c, attrs: %5u",
@@ -145,7 +156,7 @@ static const guchar *mutex_details (struct _WapiHandleShared *handle)
        guchar *name;
        struct _WapiHandle_mutex *mut=&handle->u.mutex;
        
-       name=_wapi_handle_scratch_lookup_as_string (mut->name);
+       name=_wapi_handle_scratch_lookup (mut->name);
        
        g_snprintf (buf, sizeof(buf), "[%20s] own: %5d:%5ld, count: %5u",
                    name==NULL?(guchar *)"":name, mut->pid, mut->tid,
@@ -192,7 +203,7 @@ static const guchar *process_details (struct _WapiHandleShared *handle)
        guchar *name;
        struct _WapiHandle_process *proc=&handle->u.process;
        
-       name=_wapi_handle_scratch_lookup_as_string (proc->proc_name);
+       name=_wapi_handle_scratch_lookup (proc->proc_name);
        
        g_snprintf (buf, sizeof(buf), "[%20s] pid: %5u",
                    name==NULL?(guchar *)"":name, proc->id);
index b1b62e2174095db1efdf398bc502eca3d249000a..b0288e7703058986e3f25311a53a614ff8f09ef9 100644 (file)
@@ -37,25 +37,28 @@ int main (int argc, char **argv)
        struct _WapiScratchHeader *hdr;
        gboolean success;
        
-       _wapi_shared_data=_wapi_shm_attach (&success);
+       _wapi_shared_data=g_new0 (struct _WapiHandleShared_list *, 1);
+       _wapi_shared_scratch=g_new0 (struct _WapiHandleScratch, 1);
+       
+       success=_wapi_shm_attach (&_wapi_shared_data[0], &_wapi_shared_scratch);
        if(success==FALSE) {
                g_error ("Failed to attach shared memory!");
                exit (-1);
        }
 
-       hdr=(struct _WapiScratchHeader *)&_wapi_shared_data->scratch_base[0];
+       hdr=(struct _WapiScratchHeader *)&_wapi_shared_scratch->scratch_data;
        if(hdr->flags==0 && hdr->length==0) {
                g_print ("Scratch space unused\n");
                exit (0);
        }
        
-       while(idx < _WAPI_SHM_SCRATCH_SIZE) {
-               hdr=(struct _WapiScratchHeader *)&_wapi_shared_data->scratch_base[idx];
+       while(idx < _wapi_shared_scratch->data_len) {
+               hdr=(struct _WapiScratchHeader *)&_wapi_shared_scratch->scratch_data[idx];
                if(hdr->flags & WAPI_SHM_SCRATCH_FREE) {
                        g_print ("Free block at %6d (index %6d), length %6d\n",
                                 idx, idx+HDRSIZE, hdr->length);
                } else {
-                       guchar *data=&_wapi_shared_data->scratch_base[idx+HDRSIZE];
+                       guchar *data=&_wapi_shared_scratch->scratch_data[idx+HDRSIZE];
                        
                        g_print ("Used block at %6d (index %6d), length %6d, [%s]\n",
                                 idx, idx+HDRSIZE, hdr->length,
index 173fc664dfee8cfa8eb5492afbbc893bf509ec64..7c0ba8b2f2ae1c7daf95786f1115a018ac57d9e1 100644 (file)
@@ -1,6 +1,8 @@
 #include <config.h>
 #include <glib.h>
 
+#include <mono/io-layer/io-layer.h>
+
 /* We're digging into handle internals here... */
 #include <mono/io-layer/shared.h>