From f313527fbbb455c11f6853f5f8fa034d4dbb32d2 Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Sat, 23 Jul 2022 23:49:27 +1200
Subject: [PATCH 03/13] Remove configure probe for shm_open.

shm_open() is in SUSv2 (realtime) and all targeted Unix systems have it.
---
 configure                      | 2 +-
 configure.ac                   | 1 -
 src/bin/initdb/initdb.c        | 4 ++--
 src/include/pg_config.h.in     | 3 ---
 src/include/storage/dsm_impl.h | 5 -----
 src/tools/msvc/Solution.pm     | 1 -
 6 files changed, 3 insertions(+), 13 deletions(-)

diff --git a/configure b/configure
index 3abc028412..276fcb647c 100755
--- a/configure
+++ b/configure
@@ -16039,7 +16039,7 @@ fi
 LIBS_including_readline="$LIBS"
 LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'`
 
-for ac_func in backtrace_symbols clock_gettime copyfile fdatasync getifaddrs getpeerucred inet_pton kqueue mbstowcs_l memset_s poll posix_fallocate ppoll pthread_is_threaded_np readlink readv setproctitle setproctitle_fast setsid shm_open strchrnul strsignal symlink syncfs sync_file_range uselocale wcstombs_l writev
+for ac_func in backtrace_symbols clock_gettime copyfile fdatasync getifaddrs getpeerucred inet_pton kqueue mbstowcs_l memset_s poll posix_fallocate ppoll pthread_is_threaded_np readlink readv setproctitle setproctitle_fast setsid strchrnul strsignal symlink syncfs sync_file_range uselocale wcstombs_l writev
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
diff --git a/configure.ac b/configure.ac
index 73242d76a6..7ec30a7486 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1810,7 +1810,6 @@ AC_CHECK_FUNCS(m4_normalize([
 	setproctitle
 	setproctitle_fast
 	setsid
-	shm_open
 	strchrnul
 	strsignal
 	symlink
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index 89b888eaa5..85fc95503a 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -55,7 +55,7 @@
 #include <signal.h>
 #include <time.h>
 
-#ifdef HAVE_SHM_OPEN
+#ifndef WIN32
 #include "sys/mman.h"
 #endif
 
@@ -849,7 +849,7 @@ set_null_conf(void)
 static const char *
 choose_dsm_implementation(void)
 {
-#if defined(HAVE_SHM_OPEN) && !defined(__sun__)
+#if !defined(WIN32) && !defined(__sun__)
 	int			ntries = 10;
 	pg_prng_state prng_state;
 
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index 8e9318904f..922756568e 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -480,9 +480,6 @@
 /* Define to 1 if you have the `setsid' function. */
 #undef HAVE_SETSID
 
-/* Define to 1 if you have the `shm_open' function. */
-#undef HAVE_SHM_OPEN
-
 /* Define to 1 if the system has the type `socklen_t'. */
 #undef HAVE_SOCKLEN_T
 
diff --git a/src/include/storage/dsm_impl.h b/src/include/storage/dsm_impl.h
index c51584dc6a..223d4d05bc 100644
--- a/src/include/storage/dsm_impl.h
+++ b/src/include/storage/dsm_impl.h
@@ -27,14 +27,9 @@
 #define USE_DSM_WINDOWS
 #define DEFAULT_DYNAMIC_SHARED_MEMORY_TYPE		DSM_IMPL_WINDOWS
 #else
-#ifdef HAVE_SHM_OPEN
 #define USE_DSM_POSIX
 #define DEFAULT_DYNAMIC_SHARED_MEMORY_TYPE		DSM_IMPL_POSIX
-#endif
 #define USE_DSM_SYSV
-#ifndef DEFAULT_DYNAMIC_SHARED_MEMORY_TYPE
-#define DEFAULT_DYNAMIC_SHARED_MEMORY_TYPE		DSM_IMPL_SYSV
-#endif
 #define USE_DSM_MMAP
 #endif
 
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index 1018b57f00..893feb6eaf 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -353,7 +353,6 @@ sub GenerateFiles
 		HAVE_SETPROCTITLE                        => undef,
 		HAVE_SETPROCTITLE_FAST                   => undef,
 		HAVE_SETSID                              => undef,
-		HAVE_SHM_OPEN                            => undef,
 		HAVE_SOCKLEN_T                           => 1,
 		HAVE_SPINLOCKS                           => 1,
 		HAVE_STDBOOL_H                           => 1,
-- 
2.30.2

