libc: Add program_invocation_name variables
 
Redis relies on the variables being present and correctly set.

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_at_fork: bogus implementation

Because we do not support fork, there is no need to do anything upon fork (and if
it changes in the future, we should revisit this)

So we can get away with this simple implementation that just returns 0.

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

The implementation won't do anything anyway until we have setcancelstate().

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>
mmu: correctly calculate size for unmap operations

Right now, we graciously accept - as does Linux - a mmap call for a size
smaller than a page: we align it up, and serve it. But the same alignment is
missing from unmap: so if the user rightfully tries to unmap using the same
size, it will fail.

The following test program succeeds on Linux but fails on OSv:

    int main () {
        void *ret = mmap(NULL, 64, PROT_READ, MAP_ANON | MAP_PRIVATE, -1, 0);
        if (ret == NULL) {
            return 1;
        }
        return munmap(ret, 64);
    }

After this patch, it works for us as well.

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>
tests: enhance mmap test

We have recently discovered a bug through which we fail to unmap a valid region.
This is fixed now, and this patch adds the failing condition to the test suite.

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

redis (jemalloc to be precise) actually expects that functions to succeed.
Returning -1 here means it will not initialize correctly its memory allocator.

This simple implementation just stores the desired value, but does not change
anything in the underlying mutex.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
linux: make write syscall available

The jemalloc memory allocator likes to bypass the libc when calling write, so
it calls the syscall directly. Let's make write available through this interface
as well.

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>