Discussion:
[Toybox] [PATCH] macOS: move struct sysinfo out of GLOBALS.
Rob Landley
2018-11-30 22:36:56 UTC
Permalink
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_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_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

Loading...