Rename EINTR_LOOP -> QT_EINTR_LOOP
This non-namespaced macro was defined in a header, and while that header is private, we shouldn't define non-namespaced macros in our headers. The macro also clashed with one of the same name defined in forkfd.c, which broke unity-builds including the forkfd_qt.cpp TU. This rename fixes that, too, so we can now remove forkfd_qt.cpp from NO_UNITY_BUILD_SOURCES. Pick-to: 6.5 Change-Id: Ic4bb4e4d7a632ca87905e48913db788a7c202314 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit f96a17225f088a5790655c01eaab9578c81a19f2) Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
parent
52cc586a65
commit
2923a29b59
@ -956,8 +956,6 @@ qt_internal_extend_target(Core CONDITION QT_FEATURE_process AND UNIX
|
||||
SOURCES
|
||||
../3rdparty/forkfd/forkfd.h
|
||||
io/forkfd_qt.cpp
|
||||
NO_UNITY_BUILD_SOURCES
|
||||
io/forkfd_qt.cpp # EINTR_LOOP macro clashes
|
||||
INCLUDE_DIRECTORIES
|
||||
../3rdparty/forkfd
|
||||
)
|
||||
|
@ -165,7 +165,7 @@ void QKqueueFileSystemWatcherEngine::readFromKqueue()
|
||||
int r;
|
||||
struct kevent kev;
|
||||
struct timespec ts = { 0, 0 }; // 0 ts, because we want to poll
|
||||
EINTR_LOOP(r, kevent(kqfd, 0, 0, &kev, 1, &ts));
|
||||
QT_EINTR_LOOP(r, kevent(kqfd, 0, 0, &kev, 1, &ts));
|
||||
if (r < 0) {
|
||||
perror("QKqueueFileSystemWatcherEngine: error during kevent wait");
|
||||
return;
|
||||
|
@ -160,9 +160,9 @@ bool QFSFileEnginePrivate::nativeSyncToDisk()
|
||||
Q_Q(QFSFileEngine);
|
||||
int ret;
|
||||
#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
|
||||
EINTR_LOOP(ret, fdatasync(nativeHandle()));
|
||||
QT_EINTR_LOOP(ret, fdatasync(nativeHandle()));
|
||||
#else
|
||||
EINTR_LOOP(ret, fsync(nativeHandle()));
|
||||
QT_EINTR_LOOP(ret, fsync(nativeHandle()));
|
||||
#endif
|
||||
if (ret != 0)
|
||||
q->setError(QFile::WriteError, qt_error_string(errno));
|
||||
|
@ -1107,7 +1107,7 @@ void QProcessPrivate::waitForDeadChild()
|
||||
forkfd_info info = {}; // Silence -Wmaybe-uninitialized; Thiago says forkfd_wait cannot fail here
|
||||
// (QTBUG-119081)
|
||||
int ret;
|
||||
EINTR_LOOP(ret, forkfd_wait(forkfd, &info, nullptr));
|
||||
QT_EINTR_LOOP(ret, forkfd_wait(forkfd, &info, nullptr));
|
||||
|
||||
exitCode = info.status;
|
||||
exitStatus = info.code == CLD_EXITED ? QProcess::NormalExit : QProcess::CrashExit;
|
||||
@ -1115,7 +1115,7 @@ void QProcessPrivate::waitForDeadChild()
|
||||
delete stateNotifier;
|
||||
stateNotifier = nullptr;
|
||||
|
||||
EINTR_LOOP(ret, forkfd_close(forkfd));
|
||||
QT_EINTR_LOOP(ret, forkfd_close(forkfd));
|
||||
forkfd = -1; // Child is dead, don't try to kill it anymore
|
||||
|
||||
#if defined QPROCESS_DEBUG
|
||||
|
@ -804,7 +804,7 @@ void QStorageInfoPrivate::retrieveVolumeInfo()
|
||||
{
|
||||
QT_STATFSBUF statfs_buf;
|
||||
int result;
|
||||
EINTR_LOOP(result, QT_STATFS(QFile::encodeName(rootPath).constData(), &statfs_buf));
|
||||
QT_EINTR_LOOP(result, QT_STATFS(QFile::encodeName(rootPath).constData(), &statfs_buf));
|
||||
if (result == 0) {
|
||||
valid = true;
|
||||
ready = true;
|
||||
|
@ -67,7 +67,7 @@ bool QSharedMemoryPosix::create(QSharedMemoryPrivate *self, qsizetype size)
|
||||
const QByteArray shmName = QFile::encodeName(self->nativeKey.nativeKey());
|
||||
|
||||
int fd;
|
||||
EINTR_LOOP(fd, ::shm_open(shmName.constData(), O_RDWR | O_CREAT | O_EXCL | O_CLOEXEC, 0600));
|
||||
QT_EINTR_LOOP(fd, ::shm_open(shmName.constData(), O_RDWR | O_CREAT | O_EXCL | O_CLOEXEC, 0600));
|
||||
if (fd == -1) {
|
||||
const int errorNumber = errno;
|
||||
const auto function = "QSharedMemory::attach (shm_open)"_L1;
|
||||
@ -84,7 +84,7 @@ bool QSharedMemoryPosix::create(QSharedMemoryPrivate *self, qsizetype size)
|
||||
|
||||
// the size may only be set once
|
||||
int ret;
|
||||
EINTR_LOOP(ret, QT_FTRUNCATE(fd, size));
|
||||
QT_EINTR_LOOP(ret, QT_FTRUNCATE(fd, size));
|
||||
if (ret == -1) {
|
||||
self->setUnixErrorString("QSharedMemory::create (ftruncate)"_L1);
|
||||
qt_safe_close(fd);
|
||||
@ -103,7 +103,7 @@ bool QSharedMemoryPosix::attach(QSharedMemoryPrivate *self, QSharedMemory::Acces
|
||||
const int oflag = (mode == QSharedMemory::ReadOnly ? O_RDONLY : O_RDWR);
|
||||
const mode_t omode = (mode == QSharedMemory::ReadOnly ? 0400 : 0600);
|
||||
|
||||
EINTR_LOOP(hand, ::shm_open(shmName.constData(), oflag | O_CLOEXEC, omode));
|
||||
QT_EINTR_LOOP(hand, ::shm_open(shmName.constData(), oflag | O_CLOEXEC, omode));
|
||||
if (hand == -1) {
|
||||
const int errorNumber = errno;
|
||||
const auto function = "QSharedMemory::attach (shm_open)"_L1;
|
||||
|
@ -20,9 +20,9 @@
|
||||
#ifdef Q_OS_UNIX
|
||||
# include "private/qcore_unix_p.h"
|
||||
#else
|
||||
#define EINTR_LOOP_VAL(var, val, cmd) \
|
||||
# define QT_EINTR_LOOP_VAL(var, val, cmd) \
|
||||
(void)var; var = cmd
|
||||
#define EINTR_LOOP(var, cmd) EINTR_LOOP_VAL(var, -1, cmd)
|
||||
# define QT_EINTR_LOOP(var, cmd) QT_EINTR_LOOP_VAL(var, -1, cmd)
|
||||
#endif
|
||||
|
||||
// OpenBSD 4.2 doesn't define EIDRM, see BUGS section:
|
||||
@ -133,7 +133,7 @@ bool QSystemSemaphorePosix::modifySemaphore(QSystemSemaphorePrivate *self, int c
|
||||
// rollback changes to preserve the SysV semaphore behavior
|
||||
for ( ; cnt < count; ++cnt) {
|
||||
int res;
|
||||
EINTR_LOOP(res, ::sem_wait(semaphore));
|
||||
QT_EINTR_LOOP(res, ::sem_wait(semaphore));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -141,7 +141,7 @@ bool QSystemSemaphorePosix::modifySemaphore(QSystemSemaphorePrivate *self, int c
|
||||
} while (cnt > 0);
|
||||
} else {
|
||||
int res;
|
||||
EINTR_LOOP(res, ::sem_wait(semaphore));
|
||||
QT_EINTR_LOOP(res, ::sem_wait(semaphore));
|
||||
if (res == -1) {
|
||||
// If the semaphore was removed be nice and create it and then modifySemaphore again
|
||||
if (errno == EINVAL || errno == EIDRM) {
|
||||
|
@ -174,7 +174,7 @@ bool QSystemSemaphoreSystemV::modifySemaphore(QSystemSemaphorePrivate *self, int
|
||||
operation.sem_flg = SEM_UNDO;
|
||||
|
||||
int res;
|
||||
EINTR_LOOP(res, semop(semaphore, &operation, 1));
|
||||
QT_EINTR_LOOP(res, semop(semaphore, &operation, 1));
|
||||
if (-1 == res) {
|
||||
// If the semaphore was removed be nice and create it and then modifySemaphore again
|
||||
if (errno == EINVAL || errno == EIDRM) {
|
||||
|
@ -146,7 +146,7 @@ int qt_safe_poll(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout
|
||||
if (!timeout_ts) {
|
||||
// no timeout -> block forever
|
||||
int ret;
|
||||
EINTR_LOOP(ret, qt_ppoll(fds, nfds, nullptr));
|
||||
QT_EINTR_LOOP(ret, qt_ppoll(fds, nfds, nullptr));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@
|
||||
|
||||
struct sockaddr;
|
||||
|
||||
#define EINTR_LOOP(var, cmd) \
|
||||
#define QT_EINTR_LOOP(var, cmd) \
|
||||
do { \
|
||||
var = cmd; \
|
||||
} while (var == -1 && errno == EINTR)
|
||||
@ -216,7 +216,7 @@ static inline int qt_safe_open(const char *pathname, int flags, mode_t mode = 07
|
||||
flags |= O_CLOEXEC;
|
||||
#endif
|
||||
int fd;
|
||||
EINTR_LOOP(fd, QT_OPEN(pathname, flags, mode));
|
||||
QT_EINTR_LOOP(fd, QT_OPEN(pathname, flags, mode));
|
||||
|
||||
#ifndef O_CLOEXEC
|
||||
if (fd != -1)
|
||||
@ -288,10 +288,10 @@ static inline int qt_safe_dup2(int oldfd, int newfd, int flags = FD_CLOEXEC)
|
||||
int ret;
|
||||
#ifdef QT_THREADSAFE_CLOEXEC
|
||||
// use dup3
|
||||
EINTR_LOOP(ret, ::dup3(oldfd, newfd, flags ? O_CLOEXEC : 0));
|
||||
QT_EINTR_LOOP(ret, ::dup3(oldfd, newfd, flags ? O_CLOEXEC : 0));
|
||||
return ret;
|
||||
#else
|
||||
EINTR_LOOP(ret, ::dup2(oldfd, newfd));
|
||||
QT_EINTR_LOOP(ret, ::dup2(oldfd, newfd));
|
||||
if (ret == -1)
|
||||
return -1;
|
||||
|
||||
@ -304,7 +304,7 @@ static inline int qt_safe_dup2(int oldfd, int newfd, int flags = FD_CLOEXEC)
|
||||
static inline qint64 qt_safe_read(int fd, void *data, qint64 maxlen)
|
||||
{
|
||||
qint64 ret = 0;
|
||||
EINTR_LOOP(ret, QT_READ(fd, data, maxlen));
|
||||
QT_EINTR_LOOP(ret, QT_READ(fd, data, maxlen));
|
||||
return ret;
|
||||
}
|
||||
#undef QT_READ
|
||||
@ -313,7 +313,7 @@ static inline qint64 qt_safe_read(int fd, void *data, qint64 maxlen)
|
||||
static inline qint64 qt_safe_write(int fd, const void *data, qint64 len)
|
||||
{
|
||||
qint64 ret = 0;
|
||||
EINTR_LOOP(ret, QT_WRITE(fd, data, len));
|
||||
QT_EINTR_LOOP(ret, QT_WRITE(fd, data, len));
|
||||
return ret;
|
||||
}
|
||||
#undef QT_WRITE
|
||||
@ -328,7 +328,7 @@ static inline qint64 qt_safe_write_nosignal(int fd, const void *data, qint64 len
|
||||
static inline int qt_safe_close(int fd)
|
||||
{
|
||||
int ret;
|
||||
EINTR_LOOP(ret, QT_CLOSE(fd));
|
||||
QT_EINTR_LOOP(ret, QT_CLOSE(fd));
|
||||
return ret;
|
||||
}
|
||||
#undef QT_CLOSE
|
||||
@ -340,28 +340,28 @@ static inline int qt_safe_execve(const char *filename, char *const argv[],
|
||||
char *const envp[])
|
||||
{
|
||||
int ret;
|
||||
EINTR_LOOP(ret, ::execve(filename, argv, envp));
|
||||
QT_EINTR_LOOP(ret, ::execve(filename, argv, envp));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline int qt_safe_execv(const char *path, char *const argv[])
|
||||
{
|
||||
int ret;
|
||||
EINTR_LOOP(ret, ::execv(path, argv));
|
||||
QT_EINTR_LOOP(ret, ::execv(path, argv));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline int qt_safe_execvp(const char *file, char *const argv[])
|
||||
{
|
||||
int ret;
|
||||
EINTR_LOOP(ret, ::execvp(file, argv));
|
||||
QT_EINTR_LOOP(ret, ::execvp(file, argv));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline pid_t qt_safe_waitpid(pid_t pid, int *status, int options)
|
||||
{
|
||||
int ret;
|
||||
EINTR_LOOP(ret, ::waitpid(pid, status, options));
|
||||
QT_EINTR_LOOP(ret, ::waitpid(pid, status, options));
|
||||
return ret;
|
||||
}
|
||||
#endif // QT_CONFIG(process)
|
||||
|
@ -142,7 +142,7 @@ void QThreadPipe::wakeUp()
|
||||
// eventfd
|
||||
eventfd_t value = 1;
|
||||
int ret;
|
||||
EINTR_LOOP(ret, eventfd_write(fds[0], value));
|
||||
QT_EINTR_LOOP(ret, eventfd_write(fds[0], value));
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -54,7 +54,7 @@ static inline void qt_poll_examine_ready_read(struct pollfd &pfd)
|
||||
int res;
|
||||
char data;
|
||||
|
||||
EINTR_LOOP(res, ::recv(pfd.fd, &data, sizeof(data), MSG_PEEK));
|
||||
QT_EINTR_LOOP(res, ::recv(pfd.fd, &data, sizeof(data), MSG_PEEK));
|
||||
const int error = (res < 0) ? errno : 0;
|
||||
|
||||
if (res == 0) {
|
||||
@ -109,7 +109,7 @@ static inline bool qt_poll_is_bad_fd(int fd)
|
||||
#endif
|
||||
|
||||
int ret;
|
||||
EINTR_LOOP(ret, fcntl(fd, F_GETFD));
|
||||
QT_EINTR_LOOP(ret, fcntl(fd, F_GETFD));
|
||||
return (ret == -1 && errno == EBADF);
|
||||
}
|
||||
|
||||
|
@ -502,7 +502,7 @@ static void qt_nanosleep(timespec amount)
|
||||
// nanosleep is POSIX.1-1993
|
||||
|
||||
int r;
|
||||
EINTR_LOOP(r, nanosleep(&amount, &amount));
|
||||
QT_EINTR_LOOP(r, nanosleep(&amount, &amount));
|
||||
}
|
||||
|
||||
void QThread::sleep(unsigned long secs)
|
||||
|
@ -806,7 +806,7 @@ bool QNativeSocketEnginePrivate::nativeHasPendingDatagrams() const
|
||||
// Peek 1 bytes into the next message.
|
||||
ssize_t readBytes;
|
||||
char c;
|
||||
EINTR_LOOP(readBytes, ::recv(socketDescriptor, &c, 1, MSG_PEEK));
|
||||
QT_EINTR_LOOP(readBytes, ::recv(socketDescriptor, &c, 1, MSG_PEEK));
|
||||
|
||||
// If there's no error, or if our buffer was too small, there must be a
|
||||
// pending datagram.
|
||||
@ -825,7 +825,7 @@ qint64 QNativeSocketEnginePrivate::nativePendingDatagramSize() const
|
||||
#ifdef Q_OS_LINUX
|
||||
// Linux can return the actual datagram size if we use MSG_TRUNC
|
||||
char c;
|
||||
EINTR_LOOP(recvResult, ::recv(socketDescriptor, &c, 1, MSG_PEEK | MSG_TRUNC));
|
||||
QT_EINTR_LOOP(recvResult, ::recv(socketDescriptor, &c, 1, MSG_PEEK | MSG_TRUNC));
|
||||
#elif defined(SO_NREAD)
|
||||
// macOS can return the actual datagram size if we use SO_NREAD
|
||||
int value;
|
||||
|
@ -108,7 +108,7 @@ static inline int qt_safe_connect(int sockfd, const struct sockaddr *addr, QT_SO
|
||||
{
|
||||
int ret;
|
||||
// Solaris e.g. expects a non-const 2nd parameter
|
||||
EINTR_LOOP(ret, QT_SOCKET_CONNECT(sockfd, const_cast<struct sockaddr *>(addr), addrlen));
|
||||
QT_EINTR_LOOP(ret, QT_SOCKET_CONNECT(sockfd, const_cast<struct sockaddr *>(addr), addrlen));
|
||||
return ret;
|
||||
}
|
||||
#undef QT_SOCKET_CONNECT
|
||||
@ -144,7 +144,7 @@ static inline int qt_safe_sendmsg(int sockfd, const struct msghdr *msg, int flag
|
||||
#endif
|
||||
|
||||
int ret;
|
||||
EINTR_LOOP(ret, ::sendmsg(sockfd, msg, flags));
|
||||
QT_EINTR_LOOP(ret, ::sendmsg(sockfd, msg, flags));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -152,7 +152,7 @@ static inline int qt_safe_recvmsg(int sockfd, struct msghdr *msg, int flags)
|
||||
{
|
||||
int ret;
|
||||
|
||||
EINTR_LOOP(ret, ::recvmsg(sockfd, msg, flags));
|
||||
QT_EINTR_LOOP(ret, ::recvmsg(sockfd, msg, flags));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -408,7 +408,7 @@ static void generateStackTrace()
|
||||
writeToStderr("Failed to start debugger.\n");
|
||||
} else {
|
||||
int ret;
|
||||
EINTR_LOOP(ret, waitpid(pid, nullptr, 0));
|
||||
QT_EINTR_LOOP(ret, waitpid(pid, nullptr, 0));
|
||||
}
|
||||
|
||||
writeToStderr("=== End of stack trace ===\n");
|
||||
|
Loading…
x
Reference in New Issue
Block a user