NetBSD: use paccept() where accept4() is used

Where accept4() is used, NetBSD offers paccept() as a replacement function.
Modify check for using accept4() and use paccept() on NetBSD.

See http://netbsd.gw.com/cgi-bin/man-cgi?paccept++NetBSD-current
and http://reviews.llvm.org/D12485

Change-Id: I9b3ecba5f3afad6c357d3f7b8f89589bf313e273
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Ralf Nolden 2016-06-27 10:34:19 +02:00
parent 1a96295755
commit b3b2f502e9
2 changed files with 8 additions and 0 deletions

View File

@ -44,6 +44,10 @@ int main()
(void) pipe2(pipes, O_CLOEXEC | O_NONBLOCK);
(void) fcntl(0, F_DUPFD_CLOEXEC, 0);
(void) dup3(0, 3, O_CLOEXEC);
#if defined(__NetBSD__)
(void) paccept(0, 0, 0, NULL, SOCK_CLOEXEC | SOCK_NONBLOCK);
#else
(void) accept4(0, 0, 0, SOCK_CLOEXEC | SOCK_NONBLOCK);
#endif
return 0;
}

View File

@ -109,7 +109,11 @@ static inline int qt_safe_accept(int s, struct sockaddr *addr, QT_SOCKLEN_T *add
int sockflags = SOCK_CLOEXEC;
if (flags & O_NONBLOCK)
sockflags |= SOCK_NONBLOCK;
# if defined(Q_OS_NETBSD)
fd = ::paccept(s, addr, static_cast<QT_SOCKLEN_T *>(addrlen), NULL, sockflags);
# else
fd = ::accept4(s, addr, static_cast<QT_SOCKLEN_T *>(addrlen), sockflags);
# endif
return fd;
#else
fd = ::accept(s, addr, static_cast<QT_SOCKLEN_T *>(addrlen));