Tested on hppa64-hp-hpux11.11 and hppa-unknown-linux-gnu.

Okay for trunk?

Dave
---

c++: Use mapped reads and writes when munmap and msync are available

Module support is broken when MAPPED_READING and MAPPED_WRITING
are defined to 0.  This causes internal compiler errors in the
permissive-error-1.C and permissive-error-2.C tests.

HP-UX 11.11 doesn't define _POSIX_MAPPED_FILES but it does have
munmap and msync.  Testing indicates support is sufficient for
c++ modules, so use checks for these functions instead of
_POSIX_MAPPED_FILES check.

2025-01-16  John David Anglin  <dang...@gcc.gnu.org>

gcc/ChangeLog:

        PR c++/116524
        * configure.ac: Check for munmap and msync.
        * configure: Regenerate.
        * config.in: Regenerate.

gcc/cp/ChangeLog:
        * module.cc: Test HAVE_MUNMAP and HAVE_MSYNC instead of
        _POSIX_MAPPED_FILES > 0.

diff --git a/gcc/configure.ac b/gcc/configure.ac
index 6c38c4925fb..8fab93c9365 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -1574,7 +1574,7 @@ AC_CHECK_FUNCS(times clock kill getrlimit setrlimit atoq \
        popen sysconf strsignal getrusage nl_langinfo \
        gettimeofday mbstowcs wcswidth mmap posix_fallocate setlocale \
        gcc_UNLOCKED_FUNCS madvise mallinfo mallinfo2 fstatat getauxval \
-       clock_gettime)
+       clock_gettime munmap msync)
 
 # At least for glibc, clock_gettime is in librt.  But don't pull that
 # in if it still doesn't give us the function we want.
diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index 61116fe7669..9b2bbdb2988 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -241,11 +241,11 @@ Classes used:
 #define MAPPED_READING 0
 #define MAPPED_WRITING 0
 #else
-#if HAVE_MMAP_FILE && _POSIX_MAPPED_FILES > 0
-/* mmap, munmap.  */
+#if HAVE_MMAP_FILE && HAVE_MUNMAP && HAVE_MSYNC
+/* mmap, munmap, msync.  */
 #define MAPPED_READING 1
 #if HAVE_SYSCONF && defined (_SC_PAGE_SIZE)
-/* msync, sysconf (_SC_PAGE_SIZE), ftruncate  */
+/* sysconf (_SC_PAGE_SIZE), ftruncate  */
 /* posix_fallocate used if available.  */
 #define MAPPED_WRITING 1
 #else

Attachment: signature.asc
Description: PGP signature

Reply via email to