From fb62738f7284be7ced10d4e5d2ccd6880c53b013 Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Mon, 6 Nov 2023 16:05:24 -0500 Subject: [PATCH] Renamed mmap variable, which conflicts with mmap() function on FreeBSD This fixes compiler errors on FreeBSD 14. --- libdispatch/dfile.c | 20 ++++++++++---------- nc_test/tst_diskless.c | 12 ++++++------ nc_test/tst_diskless3.c | 12 ++++++------ 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/libdispatch/dfile.c b/libdispatch/dfile.c index 7dba910f30..7447db3511 100644 --- a/libdispatch/dfile.c +++ b/libdispatch/dfile.c @@ -1770,7 +1770,7 @@ static int check_create_mode(int mode) { int mode_format; - int mmap = 0; + int use_mmap = 0; int inmemory = 0; int diskless = 0; @@ -1781,17 +1781,17 @@ check_create_mode(int mode) if (mode_format && (mode_format & (mode_format - 1))) return NC_EINVAL; - mmap = ((mode & NC_MMAP) == NC_MMAP); + use_mmap = ((mode & NC_MMAP) == NC_MMAP); inmemory = ((mode & NC_INMEMORY) == NC_INMEMORY); diskless = ((mode & NC_DISKLESS) == NC_DISKLESS); /* NC_INMEMORY and NC_DISKLESS and NC_MMAP are all mutually exclusive */ if(diskless && inmemory) return NC_EDISKLESS; - if(diskless && mmap) return NC_EDISKLESS; - if(inmemory && mmap) return NC_EINMEMORY; + if(diskless && use_mmap) return NC_EDISKLESS; + if(inmemory && use_mmap) return NC_EINMEMORY; /* mmap is not allowed for netcdf-4 */ - if(mmap && (mode & NC_NETCDF4)) return NC_EINVAL; + if(use_mmap && (mode & NC_NETCDF4)) return NC_EINVAL; #ifndef USE_NETCDF4 /* If the user asks for a netCDF-4 file, and the library was built @@ -1973,7 +1973,7 @@ NC_open(const char *path0, int omode, int basepe, size_t *chunksizehintp, const NC_Dispatch* dispatcher = NULL; int inmemory = 0; int diskless = 0; - int mmap = 0; + int use_mmap = 0; char* path = NULL; NCmodel model; char* newpath = NULL; @@ -1989,17 +1989,17 @@ NC_open(const char *path0, int omode, int basepe, size_t *chunksizehintp, {stat = NC_EINVAL; goto done;} /* Capture the inmemory related flags */ - mmap = ((omode & NC_MMAP) == NC_MMAP); + use_mmap = ((omode & NC_MMAP) == NC_MMAP); diskless = ((omode & NC_DISKLESS) == NC_DISKLESS); inmemory = ((omode & NC_INMEMORY) == NC_INMEMORY); /* NC_INMEMORY and NC_DISKLESS and NC_MMAP are all mutually exclusive */ if(diskless && inmemory) {stat = NC_EDISKLESS; goto done;} - if(diskless && mmap) {stat = NC_EDISKLESS; goto done;} - if(inmemory && mmap) {stat = NC_EINMEMORY; goto done;} + if(diskless && use_mmap) {stat = NC_EDISKLESS; goto done;} + if(inmemory && use_mmap) {stat = NC_EINMEMORY; goto done;} /* mmap is not allowed for netcdf-4 */ - if(mmap && (omode & NC_NETCDF4)) {stat = NC_EINVAL; goto done;} + if(use_mmap && (omode & NC_NETCDF4)) {stat = NC_EINVAL; goto done;} /* Attempt to do file path conversion: note that this will do nothing if path is a 'file:...' url, so it will need to be diff --git a/nc_test/tst_diskless.c b/nc_test/tst_diskless.c index 13ae21b354..279685539a 100644 --- a/nc_test/tst_diskless.c +++ b/nc_test/tst_diskless.c @@ -46,7 +46,7 @@ void fail(int line) { #endif /* Control flags */ -static int flags, persist, usenetcdf4, mmap, diskless; +static int flags, persist, usenetcdf4, use_mmap, diskless; char* smode(int mode) @@ -90,13 +90,13 @@ main(int argc, char **argv) /* Set defaults */ persist = 0; usenetcdf4 = 0; - mmap = 0; + use_mmap = 0; diskless = 0; for(i=1;i