From: John David Anglin Date: Mon, 27 Jan 2025 17:39:00 +0000 (-0500) Subject: c++: Use mapped reads and writes when munmap and msync are available X-Git-Tag: basepoints/gcc-16~2320 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9d450dee7112635a541c5a34268d54f63da48f71;p=thirdparty%2Fgcc.git 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-27 John David Anglin 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/config.in b/gcc/config.in index 44de5a54611..3b06533c482 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -1972,6 +1972,18 @@ #endif +/* Define to 1 if you have the `msync' function. */ +#ifndef USED_FOR_TARGET +#undef HAVE_MSYNC +#endif + + +/* Define to 1 if you have the `munmap' function. */ +#ifndef USED_FOR_TARGET +#undef HAVE_MUNMAP +#endif + + /* Define if GCC has been configured with --enable-newlib-nano-formatted-io. */ #ifndef USED_FOR_TARGET diff --git a/gcc/configure b/gcc/configure index b4c52de6218..e36d1d91612 100755 --- a/gcc/configure +++ b/gcc/configure @@ -10637,7 +10637,7 @@ for ac_func in times clock kill getrlimit setrlimit atoq \ popen sysconf strsignal getrusage nl_langinfo \ gettimeofday mbstowcs wcswidth mmap posix_fallocate setlocale \ clearerr_unlocked feof_unlocked ferror_unlocked fflush_unlocked fgetc_unlocked fgets_unlocked fileno_unlocked fprintf_unlocked fputc_unlocked fputs_unlocked fread_unlocked fwrite_unlocked getchar_unlocked getc_unlocked putchar_unlocked putc_unlocked madvise mallinfo mallinfo2 fstatat getauxval \ - clock_gettime + clock_gettime munmap msync do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_cxx_check_func "$LINENO" "$ac_func" "$as_ac_var" 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 312ff668750..59716e1873e 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