[procps] Re: newlib - drip, drip

  • From: Craig Small <csmall@xxxxxxxxxx>
  • To: procps@xxxxxxxxxxxxx
  • Date: Fri, 13 May 2016 12:16:42 +0000

On Fri, May 13, 2016 at 7:40 PM Jim Warner <james.warner@xxxxxxxxxxx> wrote:

Well done on vmstat.  I assume you intentionally left those individual
meminfo and stat 'get' calls under sum_format.  Perhaps just for contrast.

Um.. yeah.
Wasn't at all because I was looking at new_format and completely missed
them at all!


Anyway, why not share your experience.  Were those APIs easy to work
with and/or what could be made better?

The best part about it is you just call select and all the stuff happens in
the background to get you want you want. No need to get the wchan address
and then run another function each time on get the function name, its just
there.

The make two arrays of enums is a little odd. I know why you do it and its
a simple shortcut but that takes a little getting used to.

The main thing that caught me a lot was the different types. There is
nothing short of looking up the header field to work out what your
extractor do with the union. I didn't realise at first the actual and
deltas are different types and of course the compiler didn't warn me. I got
some odd values sometimes.

Made me think is there a way of somehow encoding this? Can't be done by the
program itself, its just an array of unions.

Now the library knows what is in each "row" of the stack. Could it somehow
say "this is an int" and then the program use some sort of extractor?
You have R->results.s_int = value, could it also set R->mytype = s_int?

And then the extractor would return R->results.(r->mytype)
I'm not sure how you get mytype to come out and reference part of the union
but it might be possible.

In other words the library sets that stack row to s_int and the value
extractor looks at that field to work out what the type is.

 - Craig

-- 
Craig Small (@smallsees)   http://enc.com.au/     csmall at : dropbear.xyz
Debian GNU/Linux           http://www.debian.org/   csmall at : debian.org
GPG fingerprint:        5D2F B320 B825 D939 04D2  0519 3938 F96B DF50 FEA5

Other related posts: