summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Munro2022-08-13 11:26:43 +0000
committerThomas Munro2022-08-13 12:09:47 +0000
commit077bf2f2750076675ae7195c58bec9a62d62fd34 (patch)
treea88bb57bc8f2f9b1e86d3e0bab096aed493489ab /src
parent75357ab94034c6f2e65d146632691072756365c5 (diff)
Remove configure probes for sys/un.h and struct sockaddr_un.
<sys/un.h> is in SUSv3 and every targeted Unix has it. Some Windows tool chains may still lack the approximately equivalent header <afunix.h>, so we already defined struct sockaddr_un ourselves on that OS for now. To harmonize things a bit, move our definition into a new header src/include/port/win32/sys/un.h. HAVE_UNIX_SOCKETS is now defined unconditionally. We migh remove that in a separate commit, pending discussion. Reviewed-by: Tom Lane <[email protected]> Reviewed-by: Peter Eisentraut <[email protected]> Reviewed-by: Andres Freund <[email protected]> Discussion: https://postgr.es/m/CA%2BhUKG%2BL_3brvh%3D8e0BW_VfX9h7MtwgN%3DnFHP5o7X2oZucY9dg%40mail.gmail.com
Diffstat (limited to 'src')
-rw-r--r--src/include/c.h4
-rw-r--r--src/include/libpq/pqcomm.h4
-rw-r--r--src/include/pg_config.h.in6
-rw-r--r--src/include/port.h3
-rw-r--r--src/include/port/win32.h11
-rw-r--r--src/include/port/win32/sys/un.h17
-rw-r--r--src/port/getpeereid.c4
-rw-r--r--src/tools/msvc/Solution.pm2
8 files changed, 22 insertions, 29 deletions
diff --git a/src/include/c.h b/src/include/c.h
index de9ec04d494..65e91a6b899 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -1113,10 +1113,6 @@ extern void ExceptionalCondition(const char *conditionName,
* ----------------------------------------------------------------
*/
-#ifdef HAVE_STRUCT_SOCKADDR_UN
-#define HAVE_UNIX_SOCKETS 1
-#endif
-
/*
* Invert the sign of a qsort-style comparison result, ie, exchange negative
* and positive integer values, being careful not to get the wrong answer
diff --git a/src/include/libpq/pqcomm.h b/src/include/libpq/pqcomm.h
index b418283d5ff..3bcc06b2d61 100644
--- a/src/include/libpq/pqcomm.h
+++ b/src/include/libpq/pqcomm.h
@@ -17,10 +17,8 @@
#define PQCOMM_H
#include <sys/socket.h>
-#include <netdb.h>
-#ifdef HAVE_SYS_UN_H
#include <sys/un.h>
-#endif
+#include <netdb.h>
#include <netinet/in.h>
#ifdef HAVE_STRUCT_SOCKADDR_STORAGE
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index ed6185343e2..b6c73ccd719 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -478,9 +478,6 @@
/* Define to 1 if `__ss_len' is a member of `struct sockaddr_storage'. */
#undef HAVE_STRUCT_SOCKADDR_STORAGE___SS_LEN
-/* Define to 1 if the system has the type `struct sockaddr_un'. */
-#undef HAVE_STRUCT_SOCKADDR_UN
-
/* Define to 1 if `tm_zone' is a member of `struct tm'. */
#undef HAVE_STRUCT_TM_TM_ZONE
@@ -538,9 +535,6 @@
/* Define to 1 if you have the <sys/ucred.h> header file. */
#undef HAVE_SYS_UCRED_H
-/* Define to 1 if you have the <sys/un.h> header file. */
-#undef HAVE_SYS_UN_H
-
/* Define to 1 if you have the <termios.h> header file. */
#undef HAVE_TERMIOS_H
diff --git a/src/include/port.h b/src/include/port.h
index cec41eae713..80dcfb7dfee 100644
--- a/src/include/port.h
+++ b/src/include/port.h
@@ -503,4 +503,7 @@ extern bool wait_result_is_any_signal(int exit_status, bool include_command_not_
#define HAVE_SYMLINK 1
#endif
+/* Interfaces that we assume that all systems have. */
+#define HAVE_UNIX_SOCKETS 1
+
#endif /* PG_PORT_H */
diff --git a/src/include/port/win32.h b/src/include/port/win32.h
index 5f3b17a5008..67755aadc40 100644
--- a/src/include/port/win32.h
+++ b/src/include/port/win32.h
@@ -55,14 +55,3 @@
#ifdef _MSC_VER
#define PGDLLEXPORT __declspec (dllexport)
#endif
-
-/*
- * Windows headers don't define this structure, but you can define it yourself
- * to use the functionality.
- */
-struct sockaddr_un
-{
- unsigned short sun_family;
- char sun_path[108];
-};
-#define HAVE_STRUCT_SOCKADDR_UN 1
diff --git a/src/include/port/win32/sys/un.h b/src/include/port/win32/sys/un.h
new file mode 100644
index 00000000000..4fc13a23fd1
--- /dev/null
+++ b/src/include/port/win32/sys/un.h
@@ -0,0 +1,17 @@
+/*
+ * src/include/port/win32/sys/un.h
+ */
+#ifndef WIN32_SYS_UN_H
+#define WIN32_SYS_UN_H
+
+/*
+ * Windows defines this structure in <afunix.h>, but not all tool chains have
+ * the header yet, so we define it here for now.
+ */
+struct sockaddr_un
+{
+ unsigned short sun_family;
+ char sun_path[108];
+};
+
+#endif
diff --git a/src/port/getpeereid.c b/src/port/getpeereid.c
index 56ae1410402..0bb07782bac 100644
--- a/src/port/getpeereid.c
+++ b/src/port/getpeereid.c
@@ -16,10 +16,8 @@
#include <sys/param.h>
#include <sys/socket.h>
-#include <unistd.h>
-#ifdef HAVE_SYS_UN_H
#include <sys/un.h>
-#endif
+#include <unistd.h>
#ifdef HAVE_UCRED_H
#include <ucred.h>
#endif
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index 741998a1037..ed437ce084d 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -355,7 +355,6 @@ sub GenerateFiles
HAVE_STRUCT_SOCKADDR_STORAGE_SS_LEN => undef,
HAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY => undef,
HAVE_STRUCT_SOCKADDR_STORAGE___SS_LEN => undef,
- HAVE_STRUCT_SOCKADDR_UN => undef,
HAVE_STRUCT_TM_TM_ZONE => undef,
HAVE_SYNC_FILE_RANGE => undef,
HAVE_SYNCFS => undef,
@@ -375,7 +374,6 @@ sub GenerateFiles
HAVE_SYS_STAT_H => 1,
HAVE_SYS_TYPES_H => 1,
HAVE_SYS_UCRED_H => undef,
- HAVE_SYS_UN_H => undef,
HAVE_TERMIOS_H => undef,
HAVE_TYPEOF => undef,
HAVE_UCRED_H => undef,