From 539aae190ba82a705d8d466d3fd00907c3c291a3 Mon Sep 17 00:00:00 2001 From: Keith Bostic Date: Wed, 24 Aug 2016 13:53:29 -0400 Subject: WT-2857 POSIX ftruncate calls should be #ifdef'd HAVE_FTRUNCATE (#2975) * WT-2857 POSIX ftruncate calls should be #ifdef'd HAVE_FTRUNCATE * Remove fcntl from the list of functions autoconf checks for, WiredTiger requires it for OS X fsync and the file-lock function, it's not optional. * If the Windows configuration #defines don't match, it can be because there are too many there, not just there are too few. * Remove fread_unlocked from the list of functions autoconf checks for, it was added a long time ago as part of the Riak eleveldb work, and as far as I can tell, it's never used. Remove the Windows HAVE_FCNTL and HAVE_FREAD_UNLOCKED #defines. * Another try at a reasonable error message. --- build_posix/configure.ac.in | 5 ++--- build_win/wiredtiger_config.h | 6 ------ dist/s_win | 2 +- src/os_posix/os_fs.c | 6 +++++- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/build_posix/configure.ac.in b/build_posix/configure.ac.in index 52c49c25caa..a34cb1ce0b4 100644 --- a/build_posix/configure.ac.in +++ b/build_posix/configure.ac.in @@ -121,9 +121,8 @@ AC_CHECK_LIB(dl, dlopen) AC_CHECK_LIB(rt, sched_yield) AC_CHECK_FUNCS([\ - clock_gettime fallocate fcntl fread_unlocked ftruncate gettimeofday\ - posix_fadvise posix_fallocate posix_madvise\ - strtouq sync_file_range]) + clock_gettime fallocate ftruncate gettimeofday posix_fadvise\ + posix_fallocate posix_madvise strtouq sync_file_range]) # OS X wrongly reports that it has fdatasync AS_CASE([$host_os], [darwin*], [], [AC_CHECK_FUNCS([fdatasync])]) diff --git a/build_win/wiredtiger_config.h b/build_win/wiredtiger_config.h index 33dbc9b724d..ad82b13f8a8 100644 --- a/build_win/wiredtiger_config.h +++ b/build_win/wiredtiger_config.h @@ -31,15 +31,9 @@ /* Define to 1 if you have the `fallocate' function. */ /* #undef HAVE_FALLOCATE */ -/* Define to 1 if you have the `fcntl' function. */ -/* #undef HAVE_FCNTL 1 */ - /* Define to 1 if you have the `fdatasync' function. */ /* #undef HAVE_FDATASYNC */ -/* Define to 1 if you have the `fread_unlocked' function. */ -/* #undef HAVE_FREAD_UNLOCKED */ - /* Define to 1 if you have the `ftruncate' function. */ /* #undef HAVE_FTRUNCATE */ diff --git a/dist/s_win b/dist/s_win index 49deb348bc3..5b45cacf0f4 100755 --- a/dist/s_win +++ b/dist/s_win @@ -19,7 +19,7 @@ win_config() test -s $t && { echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=" - echo "Windows #defines missing from $f" + echo "$f: configuration #defines do not match POSIX" echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=" cat $t exit 1 diff --git a/src/os_posix/os_fs.c b/src/os_posix/os_fs.c index 06ec521e1d9..c6272b5da52 100644 --- a/src/os_posix/os_fs.c +++ b/src/os_posix/os_fs.c @@ -469,6 +469,7 @@ __posix_file_sync_nowait(WT_FILE_HANDLE *file_handle, WT_SESSION *wt_session) } #endif +#ifdef HAVE_FTRUNCATE /* * __posix_file_truncate -- * POSIX ftruncate. @@ -490,6 +491,7 @@ __posix_file_truncate( WT_RET_MSG(session, ret, "%s: handle-truncate: ftruncate", file_handle->name); } +#endif /* * __posix_file_write -- @@ -536,7 +538,7 @@ __posix_file_write(WT_FILE_HANDLE *file_handle, WT_SESSION *wt_session, static inline int __posix_open_file_cloexec(WT_SESSION_IMPL *session, int fd, const char *name) { -#if defined(HAVE_FCNTL) && defined(FD_CLOEXEC) && !defined(O_CLOEXEC) +#if defined(FD_CLOEXEC) && !defined(O_CLOEXEC) int f; /* @@ -722,7 +724,9 @@ directory_open: #ifdef HAVE_SYNC_FILE_RANGE file_handle->fh_sync_nowait = __posix_file_sync_nowait; #endif +#ifdef HAVE_FTRUNCATE file_handle->fh_truncate = __posix_file_truncate; +#endif file_handle->fh_write = __posix_file_write; *file_handlep = file_handle; -- cgit v1.2.1