From: Howard Chu Date: Mon, 18 Aug 2014 03:44:53 +0000 (-0700) Subject: Partially revert ada26306992babeccad0c5443fbd76e28dd24cd6 X-Git-Tag: OPENLDAP_REL_ENG_2_4_40~43^2 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=4008e5e58337feb8a5ab29b7f939b1831d3f6d75;p=openldap Partially revert ada26306992babeccad0c5443fbd76e28dd24cd6 Of course, MacOSX only has posix_memalign, and only in recent versions. (Older versions could use valloc instead. That precludes ever changing the LMDB pagesize to be different from the OS pagesize.) Not all that crucial since it only affects mdb_env_copyfd1. --- diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index 6afd615621..74d3678c45 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -79,17 +79,23 @@ extern int cacheflush(char *addr, int nbytes, int cache); #define CACHEFLUSH(addr, bytes, cache) #endif + #include #include #include #include #include #include -#include #include #include #include +#if defined(__sun) +/* Most platforms have posix_memalign, older may only have memalign */ +#define HAVE_MEMALIGN 1 +#include +#endif + #if !(defined(BYTE_ORDER) || defined(__BYTE_ORDER)) #include #include /* defines BYTE_ORDER on HPUX and Solaris */ @@ -8480,9 +8486,15 @@ mdb_env_copyfd1(MDB_env *env, HANDLE fd) #else pthread_mutex_init(&my.mc_mutex, NULL); pthread_cond_init(&my.mc_cond, NULL); +#ifdef HAVE_MEMALIGN my.mc_wbuf[0] = memalign(env->me_os_psize, MDB_WBUF*2); if (my.mc_wbuf[0] == NULL) return errno; +#else + rc = posix_memalign((void **)&my.mc_wbuf[0], env->me_os_psize, MDB_WBUF*2); + if (rc) + return rc; +#endif #endif memset(my.mc_wbuf[0], 0, MDB_WBUF*2); my.mc_wbuf[1] = my.mc_wbuf[0] + MDB_WBUF;