From a096270c77b1f6461a2ef58660ad9cfa9cbb32bb Mon Sep 17 00:00:00 2001 From: Flavio Cruz Date: Sat, 8 Apr 2023 01:03:31 -0400 Subject: Further modernize Hurd code by enforcing strict prototypes and no implicit function declarations. Most of the changes land in one of these buckets: * Removed unused declarations. * Used (void) to represent no parameters instead of () which means an undeterminate number of parameters. * Included missing header files whenever necessary (stdlib.h, sys/mman.h, etc) * Typedefed function pointers to be able to fully declare the parameter types. * Added declarations of library functions that are used elsewhere (example is libps/ps.h). * Made functions static whenever they are only used in that file. * Forwarded declarations of some methods that were made static. Message-Id: --- libps/ps.h | 48 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 5 deletions(-) (limited to 'libps/ps.h') diff --git a/libps/ps.h b/libps/ps.h index 2725b1f4..a3c938e1 100644 --- a/libps/ps.h +++ b/libps/ps.h @@ -535,7 +535,7 @@ struct ps_getter /* A function that will get the value; the protocol between this function and its caller is type-dependent. */ - void (*fn) (); + void (*fn) (void); }; /* Access macros: */ @@ -987,15 +987,17 @@ error_t proc_stat_list_filter1 (struct proc_stat_list *pp, error_t proc_stat_list_filter (struct proc_stat_list *pp, const struct ps_filter *filter, int invert); +typedef int (*proc_stat_cmp_fun)(struct proc_stat *ps1, + struct proc_stat *ps2, + const struct ps_getter *getter); + /* Destructively sort proc_stats in PP by ascending value of the field returned by GETTER, and compared by CMP_FN; If REVERSE is true, use the opposite order. If a fatal error occurs, the error code is returned, it returns 0. */ error_t proc_stat_list_sort1 (struct proc_stat_list *pp, const struct ps_getter *getter, - int (*cmp_fn)(struct proc_stat *ps1, - struct proc_stat *ps2, - const struct ps_getter *getter), + proc_stat_cmp_fun cmp_fn, int reverse); /* Destructively sort proc_stats in PP by ascending value of the field KEY; @@ -1044,7 +1046,7 @@ int proc_stat_list_spec_nominal (struct proc_stat_list *pp, information on the data types these routines return. */ /* Return the current host port. */ -mach_port_t ps_get_host (); +mach_port_t ps_get_host (void); /* Return a pointer to basic info about the current host in HOST_INFO. Since this is static global information we just use a static buffer. If a @@ -1062,4 +1064,40 @@ error_t ps_host_sched_info (host_sched_info_t *host_info); to). If a system error occurs, the error code is returned, otherwise 0. */ error_t ps_host_load_info (host_load_info_t *host_info); +error_t ps_emit_string (struct proc_stat *ps, struct ps_fmt_field *field, + struct ps_stream *stream); + +/* Returns 1 if string from GETTER is empty or -. */ +int ps_nominal_string (struct proc_stat *ps, const struct ps_getter *getter); + +/* Emits user name from FIELD into STREAM. */ +error_t +ps_emit_user_name (struct proc_stat *ps, struct ps_fmt_field *field, + struct ps_stream *stream); + +/* Emits time from FIELD into STREAM. */ +error_t +ps_emit_past_time (struct proc_stat *ps, struct ps_fmt_field *field, + struct ps_stream *stream); + +/* Emits minutes from FIELD into STREAM. */ +error_t +ps_emit_minutes (struct proc_stat *ps, struct ps_fmt_field *field, + struct ps_stream *stream); + +/* Emits minutes from FIELD into STREAM. */ +int +ps_cmp_times (struct proc_stat *ps1, struct proc_stat *ps2, + const struct ps_getter *getter); + +/* Compares the times between PS1 and PS2 using GETTER. */ +int +ps_cmp_strings (struct proc_stat *ps1, struct proc_stat *ps2, + const struct ps_getter *getter); + +/* Compares user names of PS1 and PS2 using GETTER. */ +int +ps_cmp_unames (struct proc_stat *ps1, struct proc_stat *ps2, + const struct ps_getter *getter); + #endif /* __PS_H__ */ -- cgit v1.2.3