libc: implement lockf

This is mainly a wrapper around fcntl, so it should work to the extent
that fcntl works and fail gracefully where it doesn't. Code is imported
from musl with some modifications to allow it to compile as C++ code.

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

Similar to pipe, but taking flags. We will ignore exec related flags.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
libc: implement ffsl and ffsll functions

We already have the ffs function, ffsl and ffsll are easy from here.
Theoretically, a_ctz_l should do the job here as well since we're 64 all
over, but I found a_ctz_64 safer.

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

Code from musl.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
pthread: implement raise() function

The man page for raise says:

In a single-threaded program it is equivalent to

           kill(getpid(), sig);

In a multithreaded program it is equivalent to

           pthread_kill(pthread_self(), sig);

In our case we should mimic the second. It is a good question then whether this
function should be in a more generic place or in pthread.cc itself, but I will
argue for the second, since it will make it easier for people to notice that
this is what our implementation does.

Of course at this moment pthread_kill is stubbed and so is raise. But if we
ever implement the first, we gain the later for free.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
tests: allow running tests/tst-mmap.cc

Fix a missing include to allow tst-mmap.cc to be compiled on Linux, and
add in a comment the (far from obvious) command line needed to compile it.

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