libc: import if_nametoindex() from musl

Needed for debug build (some random boost dependency).

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
libc: implement passwd handling functions

We have already some of the user handling functions, but not others, like
getpwent, endpwent, and their group variants.

Those functions read entries from the passwd file, and we can emulate them
easily, by just keeping a counter of whether or not we should return our single
user/group, or go back to the beginning of the file. Those functions are not
reentrant.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
pthread: implement pthread_rwlock functions

Most of them are trivial wrappers around our rwlock. Unfortunately, the
placement trick won't work and we will have to allocate the rwlock through the
lazy_indirect mechanism.

We also have to check if the lock is taken for write or read before unlocking,
because there is only one unlock function in the pthread family. Other than
that, it is the exact same as our pthread_mutex implementation - including the
missing attr handling =)

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>