Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qcore_unix_p.h File Reference

(0a4ddd8126f2092414038ee80b3462a070973327)

#include "qplatformdefs.h"
#include <QtCore/private/qglobal_p.h>
#include "qbytearray.h"
#include "qdeadlinetimer.h"
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <sys/select.h>
#include <sys/time.h>
#include <chrono>
#include <sys/wait.h>
#include <errno.h>
#include <fcntl.h>
#include <poll.h>
Include dependency graph for qcore_unix_p.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

union  qt_semun

Macros

#define QT_EINTR_LOOP(var, cmd)
#define QT_OPEN   qt_safe_open
#define QT_READ   qt_safe_read
#define QT_WRITE   qt_safe_write
#define QT_CLOSE   qt_safe_close
#define _POSIX_MONOTONIC_CLOCK   -1

Functions

QT_BEGIN_NAMESPACE Q_DECLARE_TYPEINFO (pollfd, Q_PRIMITIVE_TYPE)
timespec durationToTimespec (std::chrono::nanoseconds timeout) noexcept
template<typename Duration>
Duration timespecToChrono (timespec ts) noexcept
constexpr timespec & normalizedTimespec (timespec &t)
timeval timespecToTimeval (timespec ts)
template<clockid_t ClockId = QSteadyClockClockId>
timespec deadlineToAbstime (QDeadlineTimer deadline)
Q_CORE_EXPORT void qt_ignore_sigpipe () noexcept
static int qt_safe_open (const char *pathname, int flags, mode_t mode=0777)
static int qt_safe_pipe (int pipefd[2], int flags=0)
static int qt_safe_dup (int oldfd, int atleast=0, int flags=FD_CLOEXEC)
static int qt_safe_dup2 (int oldfd, int newfd, int flags=FD_CLOEXEC)
static qint64 qt_safe_read (int fd, void *data, qint64 maxlen)
static qint64 qt_safe_write (int fd, const void *data, qint64 len)
static qint64 qt_safe_write_nosignal (int fd, const void *data, qint64 len)
static int qt_safe_close (int fd)
QByteArray qt_readlink (const char *path)
bool qt_haveLinuxProcfs ()
Q_CORE_EXPORT int qt_safe_poll (struct pollfd *fds, nfds_t nfds, QDeadlineTimer deadline)
static struct pollfd qt_make_pollfd (int fd, short events)

Variables

static constexpr clockid_t QSteadyClockClockId
static constexpr clockid_t QWaitConditionClockId
static constexpr auto OneSecAsNsecs = std::chrono::nanoseconds(std::chrono::seconds{ 1 }).count()

Macro Definition Documentation

◆ _POSIX_MONOTONIC_CLOCK

#define _POSIX_MONOTONIC_CLOCK   -1

Definition at line 337 of file qcore_unix_p.h.

◆ QT_CLOSE

#define QT_CLOSE   qt_safe_close

Definition at line 302 of file qcore_unix_p.h.

◆ QT_EINTR_LOOP

#define QT_EINTR_LOOP ( var,
cmd )
Value:
do { \
var = cmd; \
} while (var == -1 && errno == EINTR)

Definition at line 60 of file qcore_unix_p.h.

◆ QT_OPEN

#define QT_OPEN   qt_safe_open

Definition at line 199 of file qcore_unix_p.h.

◆ QT_READ

#define QT_READ   qt_safe_read

Definition at line 278 of file qcore_unix_p.h.

◆ QT_WRITE

#define QT_WRITE   qt_safe_write

Definition at line 287 of file qcore_unix_p.h.

Function Documentation

◆ deadlineToAbstime()

template<clockid_t ClockId = QSteadyClockClockId>
timespec deadlineToAbstime ( QDeadlineTimer deadline)
inline

Definition at line 150 of file qcore_unix_p.h.

◆ durationToTimespec()

timespec durationToTimespec ( std::chrono::nanoseconds timeout)
inlinenoexcept

Definition at line 109 of file qcore_unix_p.h.

◆ normalizedTimespec()

timespec & normalizedTimespec ( timespec & t)
inlineconstexpr

Definition at line 128 of file qcore_unix_p.h.

◆ Q_DECLARE_TYPEINFO()

QT_BEGIN_NAMESPACE Q_DECLARE_TYPEINFO ( pollfd ,
Q_PRIMITIVE_TYPE  )

◆ qt_haveLinuxProcfs()

bool qt_haveLinuxProcfs ( )
inline

Definition at line 343 of file qcore_unix_p.h.

◆ qt_ignore_sigpipe()

Q_CORE_EXPORT void qt_ignore_sigpipe ( )
noexcept

Definition at line 24 of file qcore_unix.cpp.

◆ qt_make_pollfd()

struct pollfd qt_make_pollfd ( int fd,
short events )
inlinestatic

Definition at line 359 of file qcore_unix_p.h.

◆ qt_readlink()

QByteArray qt_readlink ( const char * path)

Definition at line 39 of file qcore_unix.cpp.

◆ qt_safe_close()

int qt_safe_close ( int fd)
inlinestatic

Definition at line 295 of file qcore_unix_p.h.

◆ qt_safe_dup()

int qt_safe_dup ( int oldfd,
int atleast = 0,
int flags = FD_CLOEXEC )
inlinestatic

Definition at line 230 of file qcore_unix_p.h.

◆ qt_safe_dup2()

int qt_safe_dup2 ( int oldfd,
int newfd,
int flags = FD_CLOEXEC )
inlinestatic

Definition at line 251 of file qcore_unix_p.h.

◆ qt_safe_open()

int qt_safe_open ( const char * pathname,
int flags,
mode_t mode = 0777 )
inlinestatic

Definition at line 183 of file qcore_unix_p.h.

◆ qt_safe_pipe()

int qt_safe_pipe ( int pipefd[2],
int flags = 0 )
inlinestatic

Definition at line 203 of file qcore_unix_p.h.

◆ qt_safe_poll()

Q_CORE_EXPORT int qt_safe_poll ( struct pollfd * fds,
nfds_t nfds,
QDeadlineTimer deadline )

Behaves as close to POSIX poll(2) as practical but may be implemented using select(2) where necessary. In that case, returns -1 and sets errno to EINVAL if passed any descriptor greater than or equal to FD_SETSIZE.

Definition at line 122 of file qcore_unix.cpp.

References qt_ppoll().

Here is the call graph for this function:

◆ qt_safe_read()

qint64 qt_safe_read ( int fd,
void * data,
qint64 maxlen )
inlinestatic

Definition at line 271 of file qcore_unix_p.h.

◆ qt_safe_write()

qint64 qt_safe_write ( int fd,
const void * data,
qint64 len )
inlinestatic

Definition at line 280 of file qcore_unix_p.h.

◆ qt_safe_write_nosignal()

qint64 qt_safe_write_nosignal ( int fd,
const void * data,
qint64 len )
inlinestatic

Definition at line 289 of file qcore_unix_p.h.

◆ timespecToChrono()

template<typename Duration>
Duration timespecToChrono ( timespec ts)
inlinenoexcept

Definition at line 121 of file qcore_unix_p.h.

◆ timespecToTimeval()

timeval timespecToTimeval ( timespec ts)
inline

Definition at line 141 of file qcore_unix_p.h.

Referenced by qt_poll().

Here is the caller graph for this function:

Variable Documentation

◆ OneSecAsNsecs

auto OneSecAsNsecs = std::chrono::nanoseconds(std::chrono::seconds{ 1 }).count()
staticconstexpr

Definition at line 107 of file qcore_unix_p.h.

◆ QSteadyClockClockId

clockid_t QSteadyClockClockId
inlinestaticconstexpr
Initial value:
=
CLOCK_REALTIME

Definition at line 69 of file qcore_unix_p.h.

◆ QWaitConditionClockId

clockid_t QWaitConditionClockId
inlinestaticconstexpr
Initial value:
=
CLOCK_REALTIME

Definition at line 92 of file qcore_unix_p.h.