From 5b335920aa59a8a120914899b71a752acb29f1d9 Mon Sep 17 00:00:00 2001 From: "Yury V. Zaytsev" Date: Tue, 30 Jul 2024 21:11:21 +0200 Subject: [PATCH] Ticket #3960: remove mmap support in file comparison It's not working on AIX, but more importantly doesn't offer any benefits in terms of speed, and we have a fallback anyways. https://lists.gnu.org/archive/html/autoconf/2024-07/msg00006.html Signed-off-by: Yury V. Zaytsev --- configure.ac | 13 ------------- doc/INSTALL | 6 ------ maint/utils/travis-build.sh | 1 - src/filemanager/cmd.c | 27 ++++----------------------- 4 files changed, 4 insertions(+), 43 deletions(-) diff --git a/configure.ac b/configure.ac index e3d89eac4..5a9a4447f 100644 --- a/configure.ac +++ b/configure.ac @@ -320,19 +320,6 @@ dnl replacing lstat with statlstat on sco makes it more portable between dnl sco clones AC_CHECK_FUNCS(statlstat) -dnl Overriding mmap support. This has to be before AC_FUNC_MMAP is used. -dnl We use only part of the functionality of mmap, so on AIX, -dnl it's possible to use mmap, even if it doesn't pass the autoconf test. -AC_ARG_WITH([mmap], - AS_HELP_STRING([--with-mmap], [Use the mmap call @<:@yes if found@:>@])) -if test x$with_mmap != xno; then - if test x$with_mmap = x; then - AC_FUNC_MMAP - else - AC_DEFINE(HAVE_MMAP, 1) - fi -fi - mc_GET_FS_INFO diff --git a/doc/INSTALL b/doc/INSTALL index 7e248df70..99302b5fc 100644 --- a/doc/INSTALL +++ b/doc/INSTALL @@ -103,12 +103,6 @@ incomplete, use `configure --help' to get the full list): building binaries for distribution purposes and may not work on some operating systems. -`--with-mmap', `--without-mmap' - Force using or not using the mmap function. It is currently used - in the internal viewer. `--with-mmap' may be useful on some - versions of AIX where the `configure' script decides that mmap is - broken, but it's actually suitable for the internal viewer. - `--with-subshell[=optional]', `--without-subshell' The subshell support is by default turned on, you can disable this by using the --without-subshell option. If you pass the diff --git a/maint/utils/travis-build.sh b/maint/utils/travis-build.sh index d7a00ee0f..92c5f9b75 100755 --- a/maint/utils/travis-build.sh +++ b/maint/utils/travis-build.sh @@ -92,7 +92,6 @@ mkdir -p build-all-disabled && pushd $_ --disable-nls \ --disable-vfs \ --disable-background \ - --without-mmap \ --without-x \ --without-gpm-mouse \ --without-internal-edit \ diff --git a/src/filemanager/cmd.c b/src/filemanager/cmd.c index b1e9a0d6b..496d62793 100644 --- a/src/filemanager/cmd.c +++ b/src/filemanager/cmd.c @@ -91,6 +91,7 @@ #include "boxes.h" /* cd_box() */ #include "dir.h" #include "cd.h" +#include "ioblksize.h" /* IO_BUFSIZE */ #include "cmd.h" /* Our definitions */ @@ -189,27 +190,7 @@ compare_files (const vfs_path_t *vpath1, const vfs_path_t *vpath2, off_t size) file2 = open (vfs_path_as_str (vpath2), O_RDONLY); if (file2 >= 0) { -#ifdef HAVE_MMAP - char *data1; - - /* Ugly if jungle */ - data1 = mmap (0, size, PROT_READ, MAP_FILE | MAP_PRIVATE, file1, 0); - if (data1 != (char *) -1) - { - char *data2; - - data2 = mmap (0, size, PROT_READ, MAP_FILE | MAP_PRIVATE, file2, 0); - if (data2 != (char *) -1) - { - rotate_dash (TRUE); - result = memcmp (data1, data2, size); - munmap (data2, size); - } - munmap (data1, size); - } -#else - /* Don't have mmap() :( Even more ugly :) */ - char buf1[BUFSIZ], buf2[BUFSIZ]; + char buf1[IO_BUFSIZE], buf2[IO_BUFSIZE]; ssize_t n1, n2; rotate_dash (TRUE); @@ -222,12 +203,12 @@ compare_files (const vfs_path_t *vpath1, const vfs_path_t *vpath2, off_t size) } while (n1 == n2 && n1 == sizeof (buf1) && memcmp (buf1, buf2, sizeof (buf1)) == 0); result = (n1 != n2) || memcmp (buf1, buf2, n1); -#endif /* !HAVE_MMAP */ + rotate_dash (FALSE); + close (file2); } close (file1); } - rotate_dash (FALSE); return result; }