X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftdb%2Fio.c;h=c25f1cb447f8578ea58ca2a68c81412f311bc38b;hp=172ab69d8c9e69ae7f160071567c4d885ac7848c;hb=46b1a03e21303e03b68de213b41c0840767fbc96;hpb=7104b7bc2e7f9829891477dbb04a9df926a656a7 diff --git a/ccan/tdb/io.c b/ccan/tdb/io.c index 172ab69d..c25f1cb4 100644 --- a/ccan/tdb/io.c +++ b/ccan/tdb/io.c @@ -25,8 +25,10 @@ License along with this library; if not, see . */ - #include "tdb_private.h" +#ifndef MAX +#define MAX(a,b) ((a) > (b) ? (a) : (b)) +#endif /* check for an out of bounds access - if it is out of bounds then see if the database has been expanded by someone else and expand @@ -187,7 +189,7 @@ int tdb_munmap(struct tdb_context *tdb) if (tdb->flags & TDB_INTERNAL) return 0; -#ifdef HAVE_MMAP +#if HAVE_MMAP if (tdb->map_ptr) { int ret = munmap(tdb->map_ptr, tdb->map_size); if (ret != 0) @@ -203,11 +205,11 @@ void tdb_mmap(struct tdb_context *tdb) if (tdb->flags & TDB_INTERNAL) return; -#ifdef HAVE_MMAP +#if HAVE_MMAP if (!(tdb->flags & TDB_NOMMAP)) { tdb->map_ptr = mmap(NULL, tdb->map_size, PROT_READ|(tdb->read_only? 0:PROT_WRITE), - MAP_SHARED|MAP_FILE, tdb->fd, 0); + MAP_SHARED, tdb->fd, 0); /* * NB. When mmap fails it returns MAP_FAILED *NOT* NULL !!!!