Portability fixes:

- Use fcntl.h for O_RDONLY and friends.
- Only use mallinfo with glibc.
- Use PTHREAD_MUTEX_RECURSIVE rather than the _NP (non portable) variants.

--- lib/mm/memlock.c      2014-11-29 00:07:42.000000000 +0100
+++ lib/mm/memlock.c      2014-12-28 08:25:12.424935165 +0100
@@ -133,7 +133,7 @@ static void _touch_memory(void *mem, siz
 
 static void _allocate_memory(void)
 {
-#ifndef VALGRIND_POOL
+#if !defined(VALGRIND_POOL) && defined(__GLIBC__)
        void *stack_mem;
        struct rlimit limit;
        int i, area = 0, missing = _size_malloc_tmp, max_areas = 32, hblks;

--- daemons/lvmetad/lvmetad-core.c        2014-11-29 00:07:42.000000000 +0100
+++ daemons/lvmetad/lvmetad-core.c        2014-12-28 08:29:16.406946052 +0100
@@ -124,7 +124,7 @@ static struct dm_config_tree *lock_vg(lv
        if (!(vg = dm_hash_lookup(s->lock.vg, id))) {
                if (!(vg = malloc(sizeof(pthread_mutex_t))) ||
                    pthread_mutexattr_init(&rec) ||
-                   pthread_mutexattr_settype(&rec, PTHREAD_MUTEX_RECURSIVE_NP) ||
+                   pthread_mutexattr_settype(&rec, PTHREAD_MUTEX_RECURSIVE) ||
                    pthread_mutex_init(vg, &rec))
                        goto bad;
                if (!dm_hash_insert(s->lock.vg, id, vg)) {
@@ -1152,7 +1152,7 @@ static int init(daemon_state *s)
        ls->log = s->log;
 
        pthread_mutexattr_init(&rec);
-       pthread_mutexattr_settype(&rec, PTHREAD_MUTEX_RECURSIVE_NP);
+       pthread_mutexattr_settype(&rec, PTHREAD_MUTEX_RECURSIVE);
        pthread_mutex_init(&ls->lock.pvid_to_pvmeta, &rec);
        pthread_mutex_init(&ls->lock.vgid_to_metadata, &rec);
        pthread_mutex_init(&ls->lock.pvid_to_vgid, NULL);
--- libdaemon/server/daemon-server.c      2014-11-29 00:07:42.000000000 +0100
+++ libdaemon/server/daemon-server.c      2014-12-28 08:22:40.985928408 +0100
@@ -14,6 +14,7 @@
 #include "daemon-server.h"
 #include "daemon-log.h"
 
+#include <fcntl.h>
 #include <dlfcn.h>
 #include <errno.h>
 #include <pthread.h>

