bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 11/41] libps: Port to x86_64


From: Sergey Bugaev
Subject: [PATCH 11/41] libps: Port to x86_64
Date: Tue, 9 May 2023 00:31:06 +0300

---
 libps/host.c     |  6 +++---
 libps/proclist.c | 21 ++++++++++++---------
 libps/procstat.c | 18 ++++++++++++------
 libps/ps.h       |  7 ++++---
 4 files changed, 31 insertions(+), 21 deletions(-)

diff --git a/libps/host.c b/libps/host.c
index 3ef83cae..8b45639f 100644
--- a/libps/host.c
+++ b/libps/host.c
@@ -58,7 +58,7 @@ ps_host_basic_info (host_basic_info_t *info)
 
   if (!initialized)
     {
-      size_t size = sizeof (buf);
+      mach_msg_type_number_t size = sizeof (buf);
       error_t err = host_info (ps_get_host (), HOST_BASIC_INFO,
                              (host_info_t) &buf, &size);
       if (err)
@@ -82,7 +82,7 @@ ps_host_sched_info (host_sched_info_t *info)
 
   if (!initialized)
     {
-      size_t size = sizeof (buf);
+      mach_msg_type_number_t size = sizeof (buf);
       error_t err = host_info (ps_get_host (), HOST_SCHED_INFO,
                              (host_info_t) &buf, &size);
       if (err)
@@ -102,7 +102,7 @@ error_t
 ps_host_load_info (host_load_info_t *info)
 {
   static host_load_info_data_t buf;
-  size_t size = sizeof (buf);
+  mach_msg_type_number_t size = sizeof (buf);
   error_t err = host_info (ps_get_host (), HOST_LOAD_INFO,
                          (host_info_t) &buf, &size);
 
diff --git a/libps/proclist.c b/libps/proclist.c
index 814ae30e..3d84c49b 100644
--- a/libps/proclist.c
+++ b/libps/proclist.c
@@ -257,20 +257,21 @@ proc_stat_list_merge (struct proc_stat_list *pp, struct 
proc_stat_list *mergee)
    which mig will vm_allocate space for them) */
 #define STATICPIDS 200
 
+typedef kern_return_t fetch_fn_pids_t (process_t proc, pid_t **pids,
+                                      mach_msg_type_number_t *num_pids);
+
 /* Add to PP entries for all processes in the collection fetched from the
    proc server by the function FETCH_FN.  If an error occurs, the system
    error code is returned, otherwise 0.  If PROC_STATS and NUM_PROCS are
    non-NULL, a malloced vector of the resulting entries is returned in them. */
 static error_t
 proc_stat_list_add_fn_pids (struct proc_stat_list *pp,
-                           kern_return_t (*fetch_fn)(process_t proc,
-                                                     pid_t **pids,
-                                                     size_t *num_pids),
+                           fetch_fn_pids_t fetch_fn,
                            struct proc_stat ***proc_stats, size_t *num_procs)
 {
   error_t err;
   pid_t pid_array[STATICPIDS], *pids = pid_array;
-  size_t num_pids = STATICPIDS;
+  mach_msg_type_number_t num_pids = STATICPIDS;
 
   err = (*fetch_fn)(ps_context_server (pp->context), &pids, &num_pids);
   if (err)
@@ -286,6 +287,10 @@ proc_stat_list_add_fn_pids (struct proc_stat_list *pp,
   return err;
 }
 
+typedef kern_return_t fetch_id_fn_pids_t (process_t proc, pid_t id,
+                                         pid_t **pids,
+                                         mach_msg_type_number_t *num_pids);
+
 /* Add to PP entries for all processes in the collection fetched from the
    proc server by the function FETCH_FN and ID.  If an error occurs, the
    system error code is returned, otherwise 0.  If PROC_STATS and NUM_PROCS
@@ -293,14 +298,12 @@ proc_stat_list_add_fn_pids (struct proc_stat_list *pp,
    them.  */
 static error_t
 proc_stat_list_add_id_fn_pids (struct proc_stat_list *pp, unsigned id,
-                              kern_return_t (*fetch_fn)(process_t proc,
-                                                        pid_t id,
-                                                        pid_t **pids,
-                                                        size_t *num_pids),
+                              fetch_id_fn_pids_t fetch_fn,
                               struct proc_stat ***proc_stats,
                               size_t *num_procs)
 {
-  error_t id_fetch_fn (process_t proc, pid_t **pids, size_t *num_pids)
+  error_t id_fetch_fn (process_t proc, pid_t **pids,
+                      mach_msg_type_number_t *num_pids)
     {
       return (*fetch_fn)(proc, id, pids, num_pids);
     }
diff --git a/libps/procstat.c b/libps/procstat.c
index 45ae562f..09c07e2a 100644
--- a/libps/procstat.c
+++ b/libps/procstat.c
@@ -106,8 +106,10 @@ thread_state (thread_basic_info_t bi)
 static error_t
 fetch_procinfo (process_t server, pid_t pid,
                ps_flags_t need, ps_flags_t *have,
-               struct procinfo **pi, size_t *pi_size,
-               char **waits, size_t *waits_len)
+               struct procinfo **pi,
+               mach_msg_type_number_t *pi_size,
+               char **waits,
+               mach_msg_type_number_t *waits_len)
 {
   static const struct { ps_flags_t ps_flag; int pi_flags; } map[] =
   {
@@ -166,9 +168,9 @@ merge_procinfo (struct proc_stat *ps, ps_flags_t need, 
ps_flags_t have)
 {
   error_t err;
   struct procinfo *new_pi, old_pi_hdr;
-  size_t new_pi_size;
+  mach_msg_type_number_t new_pi_size;
   char *new_waits = 0;
-  size_t new_waits_len = 0;
+  mach_msg_type_number_t new_waits_len = 0;
   /* We always re-fetch any thread-specific info, as the set of threads could
      have changed since the last time we did this, and we can't tell.  */
   ps_flags_t really_need = need | (have & PSTAT_PROCINFO_REFETCH);
@@ -924,11 +926,13 @@ proc_stat_set_flags (struct proc_stat *ps, ps_flags_t 
flags)
       ps->args = buf;
       if (ps->args)
        {
-         if (proc_getprocargs (server, ps->pid, &ps->args, &ps->args_len))
+         mach_msg_type_number_t args_len;
+         if (proc_getprocargs (server, ps->pid, &ps->args, &args_len))
            free (buf);
          else
            {
              have |= PSTAT_ARGS;
+             ps->args_len = (size_t) args_len;
              ps->args_vm_alloced = (ps->args != buf);
              if (ps->args_vm_alloced)
                free (buf);
@@ -944,11 +948,13 @@ proc_stat_set_flags (struct proc_stat *ps, ps_flags_t 
flags)
       ps->env = buf;
       if (ps->env)
        {
-         if (proc_getprocenv (server, ps->pid, &ps->env, &ps->env_len))
+         mach_msg_type_number_t env_len;
+         if (proc_getprocenv (server, ps->pid, &ps->env, &env_len))
            free (buf);
          else
            {
              have |= PSTAT_ENV;
+             ps->env_len = (size_t) env_len;
              ps->env_vm_alloced = (ps->env != buf);
              if (ps->env_vm_alloced)
                free (buf);
diff --git a/libps/ps.h b/libps/ps.h
index a3c938e1..192847b5 100644
--- a/libps/ps.h
+++ b/libps/ps.h
@@ -603,18 +603,19 @@ void ps_stream_free (struct ps_stream *stream);
    length of STRING, then write all of it; if MAX_LEN == -1, then write all
    of STRING regardless).  */
 error_t ps_stream_write (struct ps_stream *stream,
-                        const char *string, int max_len);
+                        const char *string, ssize_t max_len);
 
 /* Write NUM spaces to STREAM.  NUM may be negative, in which case the same
    number of adjacent spaces (written by other calls to ps_stream_space) are
    consumed if possible.  If an error occurs, the error code is returned,
    otherwise 0.  */
-error_t ps_stream_space (struct ps_stream *stream, int num);
+error_t ps_stream_space (struct ps_stream *stream, ssize_t num);
 
 /* Write as many spaces to STREAM as required to make a field of width SOFAR
    be at least WIDTH characters wide (the absolute value of WIDTH is used).
    If an error occurs, the error code is returned, otherwise 0.  */
-error_t ps_stream_pad (struct ps_stream *stream, int sofar, int width);
+error_t ps_stream_pad (struct ps_stream *stream,
+                      ssize_t sofar, ssize_t width);
 
 /* Write a newline to STREAM, resetting its position to zero.  */
 error_t ps_stream_newline (struct ps_stream *stream);
-- 
2.40.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]