-
-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathglobal.h
More file actions
70 lines (55 loc) · 1.22 KB
/
global.h
File metadata and controls
70 lines (55 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#pragma once
#include <QtCore>
#include <QString>
#include <QByteArray>
#ifndef Q_OS_WIN
#include <unistd.h>
#include <poll.h>
#endif
namespace cpi {
#if QT_VERSION < 0x060000
const auto SkipEmptyParts = QString::SkipEmptyParts;
#else
const auto SkipEmptyParts = Qt::SkipEmptyParts;
const auto flush = Qt::flush;
const auto endl = Qt::endl;
#endif
}
extern std::unique_ptr<QSettings> conf;
extern QStringList cppsArgs;
extern QString aoutName();
extern std::atomic_bool gQuitRequested;
extern void resetTerminalMode();
extern void setTerminalMode(bool enableEcho);
extern QByteArray readStdInput();
#ifndef Q_OS_WIN
extern void Sleep(int msecs);
template <class F>
auto eintr_loop(F&& f)
{
decltype(f()) ret;
do {
errno = 0;
ret = f();
} while (ret < 0 && errno == EINTR);
return ret;
}
inline int eread(int fd, void *buf, size_t len)
{
return eintr_loop([&] {
return ::read(fd, buf, len);
});
}
inline int ewrite(int fd, const void *buf, size_t len)
{
return eintr_loop([&] {
return ::write(fd, buf, len);
});
}
inline int epoll(struct pollfd *fds, nfds_t nfds, int timeout)
{
return eintr_loop([&] {
return ::poll(fds, nfds, timeout);
});
}
#endif