5#include <QtCore/private/qglobal_p.h>
6#include <QtCore/qbasicatomic.h>
12# include <sys/syscall.h>
18#include <mach/mach_time.h>
26 Q_CONSTINIT
static QBasicAtomicInt atom = Q_BASIC_ATOMIC_INITIALIZER(0);
27 if (!atom.loadRelaxed()) {
31 struct sigaction noaction = {};
32 noaction.sa_handler = SIG_IGN;
33 ::sigaction(SIGPIPE, &noaction,
nullptr);
42# define PATH_MAX 1024
*1024
47 ssize_t len = ::readlink(path, buf.data(), buf.size());
48 while (len == buf.size()) {
56 buf.resize(buf.size() * 2);
57 len = ::readlink(path, buf.data(), buf.size());
67#if defined(Q_PROCESSOR_X86_32) && defined(__GLIBC__
)
68# if !__GLIBC_PREREQ(2
, 22
)
74int qt_open64(
const char *pathname,
int flags, mode_t mode)
76 return syscall(SYS_open, pathname, flags | O_LARGEFILE, mode);
81#ifndef QT_BOOTSTRAPPED
83#if QT_CONFIG(poll_pollts)
90 using namespace std::chrono;
93 auto ms = ceil<milliseconds>(timespecToChrono<nanoseconds>(*ts));
94 return int(ms.count());
98int qt_poll(
struct pollfd *fds, nfds_t nfds,
const struct timespec *timeout_ts);
100static inline int qt_ppoll(
struct pollfd *fds, nfds_t nfds,
const struct timespec *timeout_ts)
102#if QT_CONFIG(poll_ppoll) || QT_CONFIG(poll_pollts)
103 return ::ppoll(fds, nfds, timeout_ts,
nullptr);
104#elif QT_CONFIG(poll_poll)
105 return ::poll(fds, nfds, timespecToMillisecs(timeout_ts));
106#elif QT_CONFIG(poll_select)
107 return qt_poll(fds, nfds, timeout_ts);
115
116
117
118
119
120
121int qt_safe_poll(
struct pollfd *fds, nfds_t nfds, QDeadlineTimer deadline)
123 if (deadline.isForever()) {
130 using namespace std::chrono;
131 nanoseconds remaining = deadline.remainingTimeAsDuration();
134 timespec ts = durationToTimespec(remaining);
136 if (ret != -1 || errno != EINTR)
138 remaining = deadline.remainingTimeAsDuration();
139 }
while (remaining > 0ns);
int qt_safe_poll(struct pollfd *fds, nfds_t nfds, QDeadlineTimer deadline)
int qt_poll(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout_ts)
static int timespecToMillisecs(const struct timespec *ts)
QT_BEGIN_NAMESPACE void qt_ignore_sigpipe() noexcept
static int qt_ppoll(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout_ts)
QByteArray qt_readlink(const char *path)
#define QT_EINTR_LOOP(var, cmd)