[Toybox] [PATCH] macOS: move struct sysinfo out of GLOBALS.

Rob Landley rob at landley.net
Fri Nov 30 14:36:56 PST 2018



On 11/30/18 3:11 PM, enh via Toybox wrote:
> Even if we don't build ps, we can't have a Linux-only struct in GLOBALS.
> The obvious alternative to this would be to have a fake struct sysinfo
> in lib/portability.h. Since having a real macOS replacement for
> sysinfo(2) seems unlikely at this point, I went this route instead.
> ---
>  toys/posix/ps.c | 22 ++++++++++++----------
>  1 file changed, 12 insertions(+), 10 deletions(-)
> 
> diff --git a/toys/posix/ps.c b/toys/posix/ps.c
> index 833ecabe..b0cf78b0 100644
> --- a/toys/posix/ps.c
> +++ b/toys/posix/ps.c
> @@ -207,7 +207,6 @@ GLOBALS(
>      } pgrep;
>    };
> 
> -  struct sysinfo si;
>    struct ptr_len gg, GG, pp, PP, ss, tt, uu, UU;
>    struct dirtree *threadparent;
>    unsigned width, height;
> @@ -261,12 +260,13 @@ enum {
>   SLOT_gtime,    /*guest jiffies of task*/ SLOT_cgtime,    // gtime+child
>   SLOT_startbss, /*data/bss address*/      SLOT_endbss,    // end addr data+bss
>   SLOT_upticks,  /*uptime-starttime*/      SLOT_argv0len,  // argv[0] length
> - SLOT_uptime,   /*si.uptime @read time*/  SLOT_vsz,       // Virtual mem Size
> - SLOT_shr,      /*Shared memory*/         SLOT_pcy,       // Android sched pol
> - SLOT_rchar,    /*All bytes read*/        SLOT_wchar,     // All bytes written
> - SLOT_rbytes,   /*Disk bytes read*/       SLOT_wbytes,    // Disk bytes written
> - SLOT_swap,     /*Swap pages used*/       SLOT_bits,      // 32 or 64
> - SLOT_tid,      /*Thread ID*/             SLOT_tcount,    // Thread count
> + SLOT_uptime,   /*si.uptime @read time*/  SLOT_totalram,  //
> si.totalram @read time
> + SLOT_vsz,      /*Virtual mem Size*/      SLOT_shr,       // Shared memory
> + SLOT_pcy,      /*Android sched pol*/     SLOT_rchar,     // All bytes read
> + SLOT_wchar,    /*All bytes written*/     SLOT_rbytes,    // Disk bytes read
> + SLOT_wbytes,   /*Disk bytes written*/    SLOT_swap,      // Swap pages used
> + SLOT_bits,     /*32 or 64*/              SLOT_tid,       // Thread ID
> + SLOT_tcount,   /*Thread count*/

I need to add a comment in that list where we stop populating that from
/proc/$PID/stat and start just adding new fields to the end. (You inserted and
moved stuff and I went "um...".)

Just looked it up, and the last one from stat is SLOT_endbss. So this is all
after that and can move freely. Ok then.

Rob



More information about the Toybox mailing list