diff options
Diffstat (limited to 'libshouldbeinlibc/portinfo.c')
-rw-r--r-- | libshouldbeinlibc/portinfo.c | 52 |
1 files changed, 27 insertions, 25 deletions
diff --git a/libshouldbeinlibc/portinfo.c b/libshouldbeinlibc/portinfo.c index cb4e9605..e6305c6e 100644 --- a/libshouldbeinlibc/portinfo.c +++ b/libshouldbeinlibc/portinfo.c @@ -1,8 +1,7 @@ /* Print information about a task's ports - Copyright (C) 1996 Free Software Foundation, Inc. - - Written by Miles Bader <miles@gnu.ai.mit.edu> + Copyright (C) 1996,98,99,2002 Free Software Foundation, Inc. + Written by Miles Bader <miles@gnu.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -18,6 +17,9 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include <sys/types.h> +#include <sys/mman.h> + #include "portinfo.h" /* Prints info about NAME in TASK to STREAM, in a way described by the flags @@ -41,7 +43,7 @@ print_port_info (mach_port_t name, mach_port_type_t type, task_t task, mach_port_urefs_t refs; error_t err = mach_port_get_refs (task, name, right, &refs); if (! err) - fprintf (stream, " (refs: %u)", refs); + fprintf (stream, " (refs: %zu)", refs); } if (type == 0) @@ -51,7 +53,7 @@ print_port_info (mach_port_t name, mach_port_type_t type, task_t task, return err; } - fprintf (stream, hex_names ? "%#6x: " : "%6d: ", name); + fprintf (stream, hex_names ? "%#6zx: " : "%6zd: ", name); if (type & MACH_PORT_TYPE_RECEIVE) { @@ -66,15 +68,15 @@ print_port_info (mach_port_t name, mach_port_type_t type, task_t task, fprintf (stream, " ("); if (status.mps_pset != MACH_PORT_NULL) fprintf (stream, - hex_names ? "port-set: %#x, " : "port-set: %d, ", + hex_names ? "port-set: %#zx, " : "port-set: %zd, ", status.mps_pset); - fprintf (stream, "seqno: %u", status.mps_seqno); + fprintf (stream, "seqno: %zu", status.mps_seqno); if (status.mps_mscount) - fprintf (stream, ", ms-count: %u", status.mps_mscount); + fprintf (stream, ", ms-count: %zu", status.mps_mscount); if (status.mps_qlimit != MACH_PORT_QLIMIT_DEFAULT) - fprintf (stream, ", qlimit: %u", status.mps_qlimit); + fprintf (stream, ", qlimit: %zu", status.mps_qlimit); if (status.mps_msgcount) - fprintf (stream, ", msgs: %u", status.mps_msgcount); + fprintf (stream, ", msgs: %zu", status.mps_msgcount); fprintf (stream, "%s%s%s)", status.mps_srights ? ", send-rights" : "", status.mps_pdrequest ? ", pd-req" : "", @@ -112,17 +114,19 @@ print_port_info (mach_port_t name, mach_port_type_t type, task_t task, error_t err = mach_port_get_set_status (task, name, &members, &members_len); if (! err) - if (members_len == 0) - fprintf (stream, " (empty)"); - else - { - fprintf (stream, hex_names ? " (%#x" : " (%u", members[0]); - for (i = 1; i < members_len; i++) - fprintf (stream, hex_names ? ", %#x" : ", %u", members[i]); - fprintf (stream, ")"); - vm_deallocate (mach_task_self (), (vm_address_t)members, - members_len * sizeof *members); - } + { + if (members_len == 0) + fprintf (stream, " (empty)"); + else + { + fprintf (stream, hex_names ? " (%#zx" : " (%zu", members[0]); + for (i = 1; i < members_len; i++) + fprintf (stream, hex_names ? ", %#zx" : ", %zu", + members[i]); + fprintf (stream, ")"); + munmap ((caddr_t) members, members_len * sizeof *members); + } + } } } putc ('\n', stream); @@ -147,10 +151,8 @@ print_task_ports_info (task_t task, mach_port_type_t only, if (types[i] & only) print_port_info (names[i], types[i], task, show, stream); - vm_deallocate (mach_task_self (), - (vm_address_t)names, names_len * sizeof *names); - vm_deallocate (mach_task_self (), - (vm_address_t)types, types_len * sizeof *types); + munmap ((caddr_t) names, names_len * sizeof *names); + munmap ((caddr_t) types, types_len * sizeof *types); return 0; } |