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 <yury@shurup.com>
This commit is contained in:
Yury V. Zaytsev 2024-07-30 21:11:21 +02:00
parent 0749b6d2d3
commit 5b335920aa
4 changed files with 4 additions and 43 deletions

View File

@ -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

View File

@ -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

View File

@ -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 \

View File

@ -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;
}