From bb0f7089fea7318a48b0fc3a4b052330a9fabcc3 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 26 May 1998 14:18:59 +0000 Subject: [PATCH] check for munmap as well as mmap. NextStep only has mmap in standard libs --- configure.in | 2 +- rsync.h | 3 ++- syscall.c | 2 +- util.c | 6 +++--- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/configure.in b/configure.in index ab4c097c..f328b9a4 100644 --- a/configure.in +++ b/configure.in @@ -39,7 +39,7 @@ echo no) AC_FUNC_MEMCMP AC_FUNC_UTIME_NULL -AC_CHECK_FUNCS(mmap waitpid getcwd strdup strerror chown chmod mknod) +AC_CHECK_FUNCS(mmap munmap waitpid getcwd strdup strerror chown chmod mknod) AC_CHECK_FUNCS(fchmod fstat strchr bcopy bzero readlink link utime utimes) AC_CHECK_FUNCS(memmove getopt_long lchown setlinebuf vsnprintf setsid glob) diff --git a/rsync.h b/rsync.h index f98ca6ae..7e2967b7 100644 --- a/rsync.h +++ b/rsync.h @@ -142,8 +142,9 @@ #endif #include -#ifdef HAVE_MMAP +#if defined(HAVE_MMAP) && defined(HAVE_MUNMAP) #include +#define USE_MMAP 1 #endif #ifdef HAVE_UTIME_H diff --git a/syscall.c b/syscall.c index a8470e14..16d0a964 100644 --- a/syscall.c +++ b/syscall.c @@ -149,7 +149,7 @@ OFF_T do_lseek(int fd, OFF_T offset, int whence) #endif } -#if HAVE_MMAP +#ifdef USE_MMAP void *do_mmap(void *start, int len, int prot, int flags, int fd, OFF_T offset) { #if HAVE_OFF64_T diff --git a/util.c b/util.c index b94262f3..f54acd2c 100644 --- a/util.c +++ b/util.c @@ -46,7 +46,7 @@ struct map_struct *map_file(int fd,OFF_T len) ret->p_offset = 0; ret->p_len = 0; -#ifdef HAVE_MMAP +#ifdef USE_MMAP len = MIN(len, MAX_MAP_SIZE); ret->map = (char *)do_mmap(NULL,len,PROT_READ,MAP_SHARED,fd,0); if (ret->map == (char *)-1) { @@ -69,7 +69,7 @@ char *map_ptr(struct map_struct *map,OFF_T offset,int len) if (len > (map->size-offset)) len = map->size-offset; -#ifdef HAVE_MMAP +#ifdef USE_MMAP if (map->map) { if (offset >= map->p_offset && offset+len <= map->p_offset+map->p_len) { @@ -143,7 +143,7 @@ char *map_ptr(struct map_struct *map,OFF_T offset,int len) void unmap_file(struct map_struct *map) { -#ifdef HAVE_MMAP +#ifdef USE_MMAP if (map->map) { munmap(map->map,map->p_len); map->map = NULL; -- 2.34.1