Skip to content

Commit 077bf2f

Browse files
committed
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 <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
1 parent 75357ab commit 077bf2f

File tree

11 files changed

+23
-61
lines changed

11 files changed

+23
-61
lines changed

config/c-library.m4

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -76,20 +76,6 @@ AC_DEFUN([PGAC_UNION_SEMUN],
7676
#endif])])# PGAC_UNION_SEMUN
7777

7878

79-
# PGAC_STRUCT_SOCKADDR_UN
80-
# -----------------------
81-
# If `struct sockaddr_un' exists, define HAVE_STRUCT_SOCKADDR_UN.
82-
# If it is missing then one could define it.
83-
# (Requires test for <sys/un.h>!)
84-
AC_DEFUN([PGAC_STRUCT_SOCKADDR_UN],
85-
[AC_CHECK_TYPES([struct sockaddr_un], [], [],
86-
[#include <sys/types.h>
87-
#ifdef HAVE_SYS_UN_H
88-
#include <sys/un.h>
89-
#endif
90-
])])# PGAC_STRUCT_SOCKADDR_UN
91-
92-
9379
# PGAC_STRUCT_SOCKADDR_STORAGE
9480
# ----------------------------
9581
# If `struct sockaddr_storage' exists, define HAVE_STRUCT_SOCKADDR_STORAGE.

configure

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13874,7 +13874,7 @@ $as_echo "#define HAVE_STDBOOL_H 1" >>confdefs.h
1387413874
fi
1387513875

1387613876

13877-
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
13877+
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
1387813878
do :
1387913879
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
1388013880
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
@@ -15117,21 +15117,6 @@ cat >>confdefs.h <<_ACEOF
1511715117
_ACEOF
1511815118

1511915119

15120-
fi
15121-
15122-
ac_fn_c_check_type "$LINENO" "struct sockaddr_un" "ac_cv_type_struct_sockaddr_un" "#include <sys/types.h>
15123-
#ifdef HAVE_SYS_UN_H
15124-
#include <sys/un.h>
15125-
#endif
15126-
15127-
"
15128-
if test "x$ac_cv_type_struct_sockaddr_un" = xyes; then :
15129-
15130-
cat >>confdefs.h <<_ACEOF
15131-
#define HAVE_STRUCT_SOCKADDR_UN 1
15132-
_ACEOF
15133-
15134-
1513515120
fi
1513615121

1513715122
ac_fn_c_check_type "$LINENO" "struct sockaddr_storage" "ac_cv_type_struct_sockaddr_storage" "#include <sys/types.h>

configure.ac

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,7 +1467,6 @@ AC_CHECK_HEADERS(m4_normalize([
14671467
sys/signalfd.h
14681468
sys/sockio.h
14691469
sys/ucred.h
1470-
sys/un.h
14711470
termios.h
14721471
ucred.h
14731472
]))
@@ -1625,7 +1624,6 @@ PGAC_C_COMPUTED_GOTO
16251624
PGAC_STRUCT_TIMEZONE
16261625
PGAC_UNION_SEMUN
16271626
AC_CHECK_TYPES(socklen_t, [], [], [#include <sys/socket.h>])
1628-
PGAC_STRUCT_SOCKADDR_UN
16291627
PGAC_STRUCT_SOCKADDR_STORAGE
16301628
PGAC_STRUCT_SOCKADDR_STORAGE_MEMBERS
16311629
PGAC_STRUCT_ADDRINFO

src/include/c.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,10 +1113,6 @@ extern void ExceptionalCondition(const char *conditionName,
11131113
* ----------------------------------------------------------------
11141114
*/
11151115

1116-
#ifdef HAVE_STRUCT_SOCKADDR_UN
1117-
#define HAVE_UNIX_SOCKETS 1
1118-
#endif
1119-
11201116
/*
11211117
* Invert the sign of a qsort-style comparison result, ie, exchange negative
11221118
* and positive integer values, being careful not to get the wrong answer

src/include/libpq/pqcomm.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@
1717
#define PQCOMM_H
1818

1919
#include <sys/socket.h>
20-
#include <netdb.h>
21-
#ifdef HAVE_SYS_UN_H
2220
#include <sys/un.h>
23-
#endif
21+
#include <netdb.h>
2422
#include <netinet/in.h>
2523

2624
#ifdef HAVE_STRUCT_SOCKADDR_STORAGE

src/include/pg_config.h.in

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -478,9 +478,6 @@
478478
/* Define to 1 if `__ss_len' is a member of `struct sockaddr_storage'. */
479479
#undef HAVE_STRUCT_SOCKADDR_STORAGE___SS_LEN
480480

481-
/* Define to 1 if the system has the type `struct sockaddr_un'. */
482-
#undef HAVE_STRUCT_SOCKADDR_UN
483-
484481
/* Define to 1 if `tm_zone' is a member of `struct tm'. */
485482
#undef HAVE_STRUCT_TM_TM_ZONE
486483

@@ -538,9 +535,6 @@
538535
/* Define to 1 if you have the <sys/ucred.h> header file. */
539536
#undef HAVE_SYS_UCRED_H
540537

541-
/* Define to 1 if you have the <sys/un.h> header file. */
542-
#undef HAVE_SYS_UN_H
543-
544538
/* Define to 1 if you have the <termios.h> header file. */
545539
#undef HAVE_TERMIOS_H
546540

src/include/port.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,4 +503,7 @@ extern bool wait_result_is_any_signal(int exit_status, bool include_command_not_
503503
#define HAVE_SYMLINK 1
504504
#endif
505505

506+
/* Interfaces that we assume that all systems have. */
507+
#define HAVE_UNIX_SOCKETS 1
508+
506509
#endif /* PG_PORT_H */

src/include/port/win32.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,3 @@
5555
#ifdef _MSC_VER
5656
#define PGDLLEXPORT __declspec (dllexport)
5757
#endif
58-
59-
/*
60-
* Windows headers don't define this structure, but you can define it yourself
61-
* to use the functionality.
62-
*/
63-
struct sockaddr_un
64-
{
65-
unsigned short sun_family;
66-
char sun_path[108];
67-
};
68-
#define HAVE_STRUCT_SOCKADDR_UN 1

src/include/port/win32/sys/un.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* src/include/port/win32/sys/un.h
3+
*/
4+
#ifndef WIN32_SYS_UN_H
5+
#define WIN32_SYS_UN_H
6+
7+
/*
8+
* Windows defines this structure in <afunix.h>, but not all tool chains have
9+
* the header yet, so we define it here for now.
10+
*/
11+
struct sockaddr_un
12+
{
13+
unsigned short sun_family;
14+
char sun_path[108];
15+
};
16+
17+
#endif

src/port/getpeereid.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@
1616

1717
#include <sys/param.h>
1818
#include <sys/socket.h>
19-
#include <unistd.h>
20-
#ifdef HAVE_SYS_UN_H
2119
#include <sys/un.h>
22-
#endif
20+
#include <unistd.h>
2321
#ifdef HAVE_UCRED_H
2422
#include <ucred.h>
2523
#endif

src/tools/msvc/Solution.pm

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,6 @@ sub GenerateFiles
355355
HAVE_STRUCT_SOCKADDR_STORAGE_SS_LEN => undef,
356356
HAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY => undef,
357357
HAVE_STRUCT_SOCKADDR_STORAGE___SS_LEN => undef,
358-
HAVE_STRUCT_SOCKADDR_UN => undef,
359358
HAVE_STRUCT_TM_TM_ZONE => undef,
360359
HAVE_SYNC_FILE_RANGE => undef,
361360
HAVE_SYNCFS => undef,
@@ -375,7 +374,6 @@ sub GenerateFiles
375374
HAVE_SYS_STAT_H => 1,
376375
HAVE_SYS_TYPES_H => 1,
377376
HAVE_SYS_UCRED_H => undef,
378-
HAVE_SYS_UN_H => undef,
379377
HAVE_TERMIOS_H => undef,
380378
HAVE_TYPEOF => undef,
381379
HAVE_UCRED_H => undef,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy