Commit 27507991 authored by Ondřej Surý's avatar Ondřej Surý

Assume socklen_t is always available on all supported platforms (except on...

Assume socklen_t is always available on all supported platforms (except on Windows where it is typedefed to int32_t)
parent 7e25330b
......@@ -17,9 +17,6 @@
***/
@TOP@
/* Define to the length type used by the socket API (socklen_t, size_t, int). */
#undef ISC_SOCKADDR_LEN_T
/* Define if threads need PTHREAD_SCOPE_SYSTEM */
#undef NEED_PTHREAD_SCOPE_SYSTEM
......
......@@ -175,7 +175,7 @@ main(int argc, char **argv) {
int s;
int n = -1;
int v6only = -1;
ISC_SOCKADDR_LEN_T len = sizeof(v6only);
socklen_t len = sizeof(v6only);
s = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
if (s >= 0) {
......
......@@ -17,9 +17,6 @@
*** it does not get installed.
***/
/* Define to the length type used by the socket API (socklen_t, size_t, int). */
#undef ISC_SOCKADDR_LEN_T
/* Define if threads need PTHREAD_SCOPE_SYSTEM */
#undef NEED_PTHREAD_SCOPE_SYSTEM
......
......@@ -759,7 +759,6 @@ GEOIPLINKOBJS
GEOIPLINKSRCS
ISC_PLATFORM_NORETURN_POST
ISC_PLATFORM_NORETURN_PRE
ISC_SOCKADDR_LEN_T
expanded_sysconfdir
PYTHON_INSTALL_LIB
PYTHON_INSTALL_DIR
......@@ -13732,43 +13731,6 @@ fi
ac_fn_c_check_type "$LINENO" "socklen_t" "ac_cv_type_socklen_t" "
#include <sys/types.h>
#include <sys/socket.h>
"
if test "x$ac_cv_type_socklen_t" = xyes; then :
$as_echo "#define ISC_SOCKADDR_LEN_T socklen_t" >>confdefs.h
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <sys/types.h>
#include <sys/socket.h>
int getsockname(int, struct sockaddr *, size_t *);
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
$as_echo "#define ISC_SOCKADDR_LEN_T size_t" >>confdefs.h
else
$as_echo "#define ISC_SOCKADDR_LEN_T int" >>confdefs.h
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5
$as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; }
if ${ac_cv_header_time+:} false; then :
......
......@@ -477,23 +477,6 @@ AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_TYPE_UINTPTR_T
AC_CHECK_TYPE(socklen_t,
[AC_DEFINE(ISC_SOCKADDR_LEN_T, socklen_t)],
[
AC_TRY_COMPILE(
[
#include <sys/types.h>
#include <sys/socket.h>
int getsockname(int, struct sockaddr *, size_t *);
],[],
[AC_DEFINE(ISC_SOCKADDR_LEN_T, size_t)],
[AC_DEFINE(ISC_SOCKADDR_LEN_T, int)])
],
[
#include <sys/types.h>
#include <sys/socket.h>
])
AC_SUBST(ISC_SOCKADDR_LEN_T)
AC_HEADER_TIME
#
......
......@@ -36,8 +36,8 @@
#include <isc/string.h>
#include <isc/util.h>
#ifndef ISC_SOCKADDR_LEN_T
#define ISC_SOCKADDR_LEN_T unsigned int
#ifndef socklen_t
#define socklen_t unsigned int
#endif
/*%
......@@ -366,24 +366,24 @@ isc_net_probe_ipv6pktinfo(void) {
#if ISC_CMSG_IP_TOS || defined(IPV6_TCLASS)
static inline ISC_SOCKADDR_LEN_T
cmsg_len(ISC_SOCKADDR_LEN_T len) {
static inline socklen_t
cmsg_len(socklen_t len) {
#ifdef CMSG_LEN
return (CMSG_LEN(len));
#else
ISC_SOCKADDR_LEN_T hdrlen;
socklen_t hdrlen;
/*
* Cast NULL so that any pointer arithmetic performed by CMSG_DATA
* is correct.
*/
hdrlen = (ISC_SOCKADDR_LEN_T)CMSG_DATA(((struct cmsghdr *)NULL));
hdrlen = (socklen_t)CMSG_DATA(((struct cmsghdr *)NULL));
return (hdrlen + len);
#endif
}
static inline ISC_SOCKADDR_LEN_T
cmsg_space(ISC_SOCKADDR_LEN_T len) {
static inline socklen_t
cmsg_space(socklen_t len) {
#ifdef CMSG_SPACE
return (CMSG_SPACE(len));
#else
......@@ -448,7 +448,7 @@ static bool
cmsgsend(int s, int level, int type, struct addrinfo *res) {
char strbuf[ISC_STRERRORSIZE];
struct sockaddr_storage ss;
ISC_SOCKADDR_LEN_T len = sizeof(ss);
socklen_t len = sizeof(ss);
struct msghdr msg;
union {
struct cmsghdr h;
......
......@@ -207,8 +207,8 @@ typedef enum { poll_idle, poll_active, poll_checking } pollstate_t;
* Some systems define the socket length argument as an int, some as size_t,
* some as socklen_t. This is here so it can be easily changed if needed.
*/
#ifndef ISC_SOCKADDR_LEN_T
#define ISC_SOCKADDR_LEN_T unsigned int
#ifndef socklen_t
#define socklen_t unsigned int
#endif
/*%
......@@ -1195,24 +1195,24 @@ make_nonblock(int fd) {
* Note that cmsg_space() could run slow on OSes that do not have
* CMSG_SPACE.
*/
static inline ISC_SOCKADDR_LEN_T
cmsg_len(ISC_SOCKADDR_LEN_T len) {
static inline socklen_t
cmsg_len(socklen_t len) {
#ifdef CMSG_LEN
return (CMSG_LEN(len));
#else
ISC_SOCKADDR_LEN_T hdrlen;
socklen_t hdrlen;
/*
* Cast NULL so that any pointer arithmetic performed by CMSG_DATA
* is correct.
*/
hdrlen = (ISC_SOCKADDR_LEN_T)CMSG_DATA(((struct cmsghdr *)NULL));
hdrlen = (socklen_t)CMSG_DATA(((struct cmsghdr *)NULL));
return (hdrlen + len);
#endif
}
static inline ISC_SOCKADDR_LEN_T
cmsg_space(ISC_SOCKADDR_LEN_T len) {
static inline socklen_t
cmsg_space(socklen_t len) {
#ifdef CMSG_SPACE
return (CMSG_SPACE(len));
#else
......@@ -2274,7 +2274,7 @@ static void
set_rcvbuf(void) {
int fd;
int max = rcvbuf, min;
ISC_SOCKADDR_LEN_T len;
socklen_t len;
fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (fd == -1) {
......@@ -2328,7 +2328,7 @@ static void
set_sndbuf(void) {
int fd;
int max = sndbuf, min;
ISC_SOCKADDR_LEN_T len;
socklen_t len;
fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
#if defined(ISC_PLATFORM_HAVEIPV6)
......@@ -2463,7 +2463,7 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock,
int on = 1;
#endif
#if defined(SO_RCVBUF) || defined(SO_SNDBUF)
ISC_SOCKADDR_LEN_T optlen;
socklen_t optlen;
int size = 0;
#endif
......@@ -3412,7 +3412,7 @@ internal_accept(isc_task_t *me, isc_event_t *ev) {
isc__socketmgr_t *manager;
isc_socket_newconnev_t *dev;
isc_task_t *task;
ISC_SOCKADDR_LEN_T addrlen;
socklen_t addrlen;
int fd;
isc_result_t result = ISC_R_SUCCESS;
char strbuf[ISC_STRERRORSIZE];
......@@ -5812,7 +5812,7 @@ internal_connect(isc_task_t *me, isc_event_t *ev) {
isc_socket_connev_t *dev;
int cc;
isc_result_t result;
ISC_SOCKADDR_LEN_T optlen;
socklen_t optlen;
char strbuf[ISC_STRERRORSIZE];
char peerbuf[ISC_SOCKADDR_FORMATSIZE];
......@@ -5948,7 +5948,7 @@ isc__socket_getpeername(isc_socket_t *sock0, isc_sockaddr_t *addressp) {
isc_result_t
isc__socket_getsockname(isc_socket_t *sock0, isc_sockaddr_t *addressp) {
isc__socket_t *sock = (isc__socket_t *)sock0;
ISC_SOCKADDR_LEN_T len;
socklen_t len;
isc_result_t result;
char strbuf[ISC_STRERRORSIZE];
......@@ -6304,7 +6304,7 @@ isc_socketmgr_renderxml(isc_socketmgr_t *mgr0, xmlTextWriterPtr writer) {
isc__socket_t *sock = NULL;
char peerbuf[ISC_SOCKADDR_FORMATSIZE];
isc_sockaddr_t addr;
ISC_SOCKADDR_LEN_T len;
socklen_t len;
int xmlrc;
LOCK(&mgr->lock);
......@@ -6416,7 +6416,7 @@ isc_socketmgr_renderjson(isc_socketmgr_t *mgr0, json_object *stats) {
isc__socket_t *sock = NULL;
char peerbuf[ISC_SOCKADDR_FORMATSIZE];
isc_sockaddr_t addr;
ISC_SOCKADDR_LEN_T len;
socklen_t len;
json_object *obj, *array = json_object_new_array();
CHECKMEM(array);
......
......@@ -34,6 +34,10 @@
#ifndef strtoull
#define strtoull _strtoui64
#endif
#include <stdint.h>
typedef uint32_t socklen_t;
#endif
/***
......
......@@ -112,14 +112,6 @@ static void consistent(isc_socket_t *sock);
#define SIO_UDP_CONNRESET _WSAIOW(IOC_VENDOR,12)
#endif
/*
* Some systems define the socket length argument as an int, some as size_t,
* some as socklen_t. This is here so it can be easily changed if needed.
*/
#ifndef ISC_SOCKADDR_LEN_T
#define ISC_SOCKADDR_LEN_T unsigned int
#endif
/*
* Define what the possible "soft" errors can be. These are non-fatal returns
* of various network related functions, like recv() and so on.
......@@ -1649,7 +1641,7 @@ socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
int on = 1;
#endif
#if defined(SO_RCVBUF)
ISC_SOCKADDR_LEN_T optlen;
socklen_t optlen;
int size;
#endif
int socket_errno;
......@@ -3655,7 +3647,7 @@ isc__socket_getpeername(isc_socket_t *sock, isc_sockaddr_t *addressp) {
isc_result_t
isc__socket_getsockname(isc_socket_t *sock, isc_sockaddr_t *addressp) {
ISC_SOCKADDR_LEN_T len;
socklen_t len;
isc_result_t result;
char strbuf[ISC_STRERRORSIZE];
......@@ -4007,7 +3999,7 @@ isc_socketmgr_renderxml(isc_socketmgr_t *mgr, xmlTextWriterPtr writer)
isc_socket_t *sock = NULL;
char peerbuf[ISC_SOCKADDR_FORMATSIZE];
isc_sockaddr_t addr;
ISC_SOCKADDR_LEN_T len;
socklen_t len;
int xmlrc;
LOCK(&mgr->lock);
......@@ -4118,7 +4110,7 @@ isc_socketmgr_renderjson(isc_socketmgr_t *mgr, json_object *stats) {
isc_socket_t *sock = NULL;
char peerbuf[ISC_SOCKADDR_FORMATSIZE];
isc_sockaddr_t addr;
ISC_SOCKADDR_LEN_T len;
socklen_t len;
json_object *obj, *array = json_object_new_array();
CHECKMEM(array);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment