require Linux v2.6.27+ and glibc v2.9+

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2020-10-08 12:55:46 +03:00
parent 2e12f99c29
commit 4e1f996d64
5 changed files with 17 additions and 31 deletions

View file

@ -149,11 +149,7 @@
#define QT_OPENDIR ::opendir
#define QT_CLOSEDIR ::closedir
#if defined(__GLIBC__) && (__GLIBC__ < 2)
#define QT_SOCKLEN_T int
#else
#define QT_SOCKLEN_T socklen_t
#endif
#define QT_SOCKET_CONNECT ::connect
#define QT_SOCKET_BIND ::bind

View file

@ -84,7 +84,7 @@ static inline QByteArray openModeToFopenMode(QIODevice::OpenMode flags, const QF
mode += '+';
}
#if defined(__GLIBC__) && (__GLIBC__ * 0x100 + __GLIBC_MINOR__) >= 0x0207
#if defined(__GLIBC__)
// must be glibc >= 2.7
mode += 'e';
#endif

View file

@ -149,16 +149,12 @@ static inline int qt_safe_pipe(int pipefd[2], int flags = 0)
Q_ASSERT((flags & ~O_NONBLOCK) == 0);
#endif
int ret;
#if defined(Q_OS_LINUX) && defined(O_CLOEXEC)
// use pipe2
// since Linux 2.6.24 and glibc 2.9
flags |= O_CLOEXEC;
ret = ::pipe2(pipefd, flags); // pipe2 is Linux-specific and is documented not to return EINTR
if (ret == 0 || errno != ENOSYS)
return ret;
#endif
ret = ::pipe(pipefd);
return ::pipe2(pipefd, flags);
#else
int ret = ::pipe(pipefd);
if (ret == -1)
return -1;
@ -172,25 +168,21 @@ static inline int qt_safe_pipe(int pipefd[2], int flags = 0)
}
return 0;
#endif
}
// don't call dup or fcntl(F_DUPFD)
static inline int qt_safe_dup(int oldfd)
{
int ret;
#ifdef F_DUPFD_CLOEXEC
// use this fcntl
ret = ::fcntl(oldfd, F_DUPFD_CLOEXEC, 0);
if (ret != -1 || errno != EINVAL)
return ret;
#endif
// use F_DUPFD
ret = ::fcntl(oldfd, F_DUPFD, 0);
// since Linux 2.6.24
return ::fcntl(oldfd, F_DUPFD_CLOEXEC, 0);
#else
int ret = ::fcntl(oldfd, F_DUPFD, 0);
if (ret != -1)
::fcntl(ret, F_SETFD, FD_CLOEXEC);
return ret;
#endif
}
// don't call dup2

View file

@ -282,7 +282,7 @@ QT_BEGIN_INCLUDE_NAMESPACE
QT_END_INCLUDE_NAMESPACE
# endif
# if defined(Q_OS_LINUX) && defined(__GLIBC__) && __GLIBC__ - 0 >= 2 && __GLIBC_MINOR__ - 0 >= 1
# if defined(Q_OS_LINUX) && defined(__GLIBC__)
# include <netpacket/packet.h>
static QList<QNetworkInterfacePrivate *> createInterfaces(ifaddrs *rawList)

View file

@ -62,17 +62,14 @@ static inline int qt_safe_socket(int domain, int type, int protocol, int flags =
{
Q_ASSERT((flags & ~O_NONBLOCK) == 0);
int fd;
#if defined(SOCK_CLOEXEC) && defined(SOCK_NONBLOCK)
// since Linux 2.6.27
int newtype = type | SOCK_CLOEXEC;
if (flags & O_NONBLOCK)
newtype |= SOCK_NONBLOCK;
fd = ::socket(domain, newtype, protocol);
if (fd != -1 || errno != EINVAL)
return fd;
#endif
fd = ::socket(domain, type, protocol);
return ::socket(domain, newtype, protocol);
#else
int fd = ::socket(domain, type, protocol);
if (fd == -1)
return -1;
@ -83,6 +80,7 @@ static inline int qt_safe_socket(int domain, int type, int protocol, int flags =
::fcntl(fd, F_SETFL, ::fcntl(fd, F_GETFL) | O_NONBLOCK);
return fd;
#endif
}
// Tru64 redefines accept -> _accept with _XOPEN_SOURCE_EXTENDED