<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 <tgl@sss.pgh.pa.us>
Reviewed-by: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/CA%2BhUKG%2BL_3brvh%3D8e0BW_VfX9h7MtwgN%3DnFHP5o7X2oZucY9dg%40mail.gmail.com
index 35fdc63afee85c0d7e55b9eb854362a8ba3b7fb5..76552ac6ed4d44042f004ccec0613bff29455329 100644 (file)
#endif])])# PGAC_UNION_SEMUN
-# PGAC_STRUCT_SOCKADDR_UN
-# -----------------------
-# If `struct sockaddr_un' exists, define HAVE_STRUCT_SOCKADDR_UN.
-# If it is missing then one could define it.
-# (Requires test for <sys/un.h>!)
-AC_DEFUN([PGAC_STRUCT_SOCKADDR_UN],
-[AC_CHECK_TYPES([struct sockaddr_un], [], [],
-[#include <sys/types.h>
-#ifdef HAVE_SYS_UN_H
-#include <sys/un.h>
-#endif
-])])# PGAC_STRUCT_SOCKADDR_UN
-
-
# PGAC_STRUCT_SOCKADDR_STORAGE
# ----------------------------
# If `struct sockaddr_storage' exists, define HAVE_STRUCT_SOCKADDR_STORAGE.
index ef5334a12d43796ea17957bb03ddb85b844dead0..b0bc818af8c15bfc4e3885f3db30b4626e639058 100755 (executable)
fi
-for ac_header in atomic.h copyfile.h execinfo.h getopt.h ifaddrs.h langinfo.h mbarrier.h net/if.h netinet/tcp.h sys/epoll.h sys/event.h sys/ipc.h sys/personality.h sys/prctl.h sys/procctl.h sys/resource.h sys/select.h sys/sem.h sys/shm.h sys/signalfd.h sys/sockio.h sys/ucred.h sys/un.h termios.h ucred.h
+for ac_header in atomic.h copyfile.h execinfo.h getopt.h ifaddrs.h langinfo.h mbarrier.h net/if.h netinet/tcp.h sys/epoll.h sys/event.h sys/ipc.h sys/personality.h sys/prctl.h sys/procctl.h sys/resource.h sys/select.h sys/sem.h sys/shm.h sys/signalfd.h sys/sockio.h sys/ucred.h termios.h ucred.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
_ACEOF
-fi
-
-ac_fn_c_check_type "$LINENO" "struct sockaddr_un" "ac_cv_type_struct_sockaddr_un" "#include <sys/types.h>
-#ifdef HAVE_SYS_UN_H
-#include <sys/un.h>
-#endif
-
-"
-if test "x$ac_cv_type_struct_sockaddr_un" = xyes; then :
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_STRUCT_SOCKADDR_UN 1
-_ACEOF
-
-
fi
ac_fn_c_check_type "$LINENO" "struct sockaddr_storage" "ac_cv_type_struct_sockaddr_storage" "#include <sys/types.h>
index c1b75e0f344b72bcff8669baa4bfafb8d8353fee..666ad7dbcba8873bd137911bb98afb57e5829e84 100644 (file)
sys/signalfd.h
sys/sockio.h
sys/ucred.h
- sys/un.h
termios.h
ucred.h
]))
PGAC_STRUCT_TIMEZONE
PGAC_UNION_SEMUN
AC_CHECK_TYPES(socklen_t, [], [], [#include <sys/socket.h>])
-PGAC_STRUCT_SOCKADDR_UN
PGAC_STRUCT_SOCKADDR_STORAGE
PGAC_STRUCT_SOCKADDR_STORAGE_MEMBERS
PGAC_STRUCT_ADDRINFO
index de9ec04d494ca3065b8cbc1f6161c5cb0539a4aa..65e91a6b899c0b064810f5d7467cc3121bb7681e 100644 (file)
@@ -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
index b418283d5ffb30d5b9be5c1f9ab9132cbfb15321..3bcc06b2d61a6d14da0f303832c35db0b7ad77e5 100644 (file)
#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
index ed6185343e295c709fabbe46215765b8f90748f6..b6c73ccd71939ad73553eedfe01a345167340389 100644 (file)
/* 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
/* 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
index cec41eae713232fe0069da2c765e7cdad0d20f47..80dcfb7dfee387c096391ff038c9ed4f31a54397 100644 (file)
@@ -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 */
index 5f3b17a50086b267e040f9b849843e9686ffc817..67755aadc403bd015c3cb6f22eaa423e3485c88d 100644 (file)
#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
new file mode 100644
(file)
index 0000000..
4fc13a2
--- /dev/null
+/*
+ * 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
index 56ae141040268b3386086ce945149b39fd190425..0bb07782baca4cc3048207063ed8932fcc3db2a4 100644 (file)
#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
index 741998a1037157623b185dbfe6cf0922dc6636f1..ed437ce084d200f516d5e407f0103d054200b3d7 100644 (file)
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,
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,