lib: Fix size of 'struct rusage'

We are currently stubbing getrusage, and zeroing out the whole structure. The
problem, is that the structure definition for OSv is just not conforming with
the one in the main page: it has a reserved field in the end.

That means that the memset() idiom will just overwrite 16 extra words in the
end with zero. That will cause a stack corruption (since getrusage comes from
the stack).

One could argue that once we would implement getrusage properly that would
disappear. While this is true, zeroing out the entire structure first keeps
being a perfectly valid idiom. There is absolutely no excuse for those reserved
fields in a structure that clearly defined in the syscall manpage.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
libc: Fix RUSAGE definitions

1 is for RUSAGE_THREAD. Linux defines RUSAGE_CHILDREN as -1. That is what we
have to use, since this is how the programs will be compiled.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
time: move process_time to common code

It is useful in other locations. Inside OSv, it is a lot more convenient
to call it and have access to a richer structure than to go through the
clock API.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
libc: Basic getrusage implementation

Most fields will be null, which is in accordance with what we are
already doing for procfs, for example. We can revisit this later. Right
now, this implementation exposes process / thread times through the
getrusage interface, which is a lot more useful.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>