Whitespace cleanup in corelib/global
Change-Id: I087d7d949cfd43e48e8a008621a4eeaa9d104ceb Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
33617c03a4
commit
ff776a3059
@ -45,8 +45,7 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
namespace QContainerTraits
|
namespace QContainerTraits {
|
||||||
{
|
|
||||||
|
|
||||||
template<typename C>
|
template<typename C>
|
||||||
using value_type = typename C::value_type;
|
using value_type = typename C::value_type;
|
||||||
|
@ -815,7 +815,7 @@ size_t simdSwapLoop(const uchar *src, size_t bytes, uchar *dst) noexcept
|
|||||||
size_t i = sseSwapLoop(src, bytes, dst, shuffleMaskPtr);
|
size_t i = sseSwapLoop(src, bytes, dst, shuffleMaskPtr);
|
||||||
|
|
||||||
// epilogue
|
// epilogue
|
||||||
for (size_t _i = 0 ; i < bytes && _i < sizeof(__m128i); i += sizeof(T), _i += sizeof(T))
|
for (size_t _i = 0; i < bytes && _i < sizeof(__m128i); i += sizeof(T), _i += sizeof(T))
|
||||||
qbswap(qFromUnaligned<T>(src + i), dst + i);
|
qbswap(qFromUnaligned<T>(src + i), dst + i);
|
||||||
|
|
||||||
// return the total, so the bswapLoop below does nothing
|
// return the total, so the bswapLoop below does nothing
|
||||||
@ -886,12 +886,13 @@ void *bswapLoop(const uchar *src, size_t n, uchar *dst) noexcept
|
|||||||
|
|
||||||
size_t i = simdSwapLoop<T>(src, n, dst);
|
size_t i = simdSwapLoop<T>(src, n, dst);
|
||||||
|
|
||||||
for ( ; i < n; i += sizeof(T))
|
for (; i < n; i += sizeof(T))
|
||||||
qbswap(qFromUnaligned<T>(src + i), dst + i);
|
qbswap(qFromUnaligned<T>(src + i), dst + i);
|
||||||
return dst + i;
|
return dst + i;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <> void *qbswap<2>(const void *source, qsizetype n, void *dest) noexcept
|
template<>
|
||||||
|
void *qbswap<2>(const void *source, qsizetype n, void *dest) noexcept
|
||||||
{
|
{
|
||||||
const uchar *src = reinterpret_cast<const uchar *>(source);
|
const uchar *src = reinterpret_cast<const uchar *>(source);
|
||||||
uchar *dst = reinterpret_cast<uchar *>(dest);
|
uchar *dst = reinterpret_cast<uchar *>(dest);
|
||||||
@ -899,7 +900,8 @@ template <> void *qbswap<2>(const void *source, qsizetype n, void *dest) noexcep
|
|||||||
return bswapLoop<quint16>(src, n << 1, dst);
|
return bswapLoop<quint16>(src, n << 1, dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <> void *qbswap<4>(const void *source, qsizetype n, void *dest) noexcept
|
template<>
|
||||||
|
void *qbswap<4>(const void *source, qsizetype n, void *dest) noexcept
|
||||||
{
|
{
|
||||||
const uchar *src = reinterpret_cast<const uchar *>(source);
|
const uchar *src = reinterpret_cast<const uchar *>(source);
|
||||||
uchar *dst = reinterpret_cast<uchar *>(dest);
|
uchar *dst = reinterpret_cast<uchar *>(dest);
|
||||||
@ -907,7 +909,8 @@ template <> void *qbswap<4>(const void *source, qsizetype n, void *dest) noexcep
|
|||||||
return bswapLoop<quint32>(src, n << 2, dst);
|
return bswapLoop<quint32>(src, n << 2, dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <> void *qbswap<8>(const void *source, qsizetype n, void *dest) noexcept
|
template<>
|
||||||
|
void *qbswap<8>(const void *source, qsizetype n, void *dest) noexcept
|
||||||
{
|
{
|
||||||
const uchar *src = reinterpret_cast<const uchar *>(source);
|
const uchar *src = reinterpret_cast<const uchar *>(source);
|
||||||
uchar *dst = reinterpret_cast<uchar *>(dest);
|
uchar *dst = reinterpret_cast<uchar *>(dest);
|
||||||
|
@ -73,12 +73,12 @@ public:
|
|||||||
// FIXME: val is public until qtdeclarative is fixed to not access it directly.
|
// FIXME: val is public until qtdeclarative is fixed to not access it directly.
|
||||||
UT val;
|
UT val;
|
||||||
|
|
||||||
QSpecialIntegerBitfield &operator =(T t)
|
QSpecialIntegerBitfield &operator=(T t)
|
||||||
{
|
{
|
||||||
UT i = S::fromSpecial(val);
|
UT i = S::fromSpecial(val);
|
||||||
i &= ~mask();
|
i &= ~mask();
|
||||||
i |= (UT(t) << pos) & mask();
|
i |= (UT(t) << pos) & mask();
|
||||||
val = S::toSpecial(i);
|
val = S::toSpecial(i);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
operator T() const
|
operator T() const
|
||||||
@ -93,32 +93,26 @@ public:
|
|||||||
return (S::fromSpecial(val) & mask()) >> pos;
|
return (S::fromSpecial(val) & mask()) >> pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator !() const { return !(val & S::toSpecial(mask())); }
|
bool operator!() const { return !(val & S::toSpecial(mask())); }
|
||||||
bool operator ==(QSpecialIntegerBitfield<S, pos, width> i) const
|
bool operator==(QSpecialIntegerBitfield<S, pos, width> i) const
|
||||||
{ return ((val ^ i.val) & S::toSpecial(mask())) == 0; }
|
{
|
||||||
bool operator !=(QSpecialIntegerBitfield<S, pos, width> i) const
|
return ((val ^ i.val) & S::toSpecial(mask())) == 0;
|
||||||
{ return ((val ^ i.val) & S::toSpecial(mask())) != 0; }
|
}
|
||||||
|
bool operator!=(QSpecialIntegerBitfield<S, pos, width> i) const
|
||||||
|
{
|
||||||
|
return ((val ^ i.val) & S::toSpecial(mask())) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
QSpecialIntegerBitfield &operator +=(T i)
|
QSpecialIntegerBitfield &operator+=(T i) { return (*this = (T(*this) + i)); }
|
||||||
{ return (*this = (T(*this) + i)); }
|
QSpecialIntegerBitfield &operator-=(T i) { return (*this = (T(*this) - i)); }
|
||||||
QSpecialIntegerBitfield &operator -=(T i)
|
QSpecialIntegerBitfield &operator*=(T i) { return (*this = (T(*this) * i)); }
|
||||||
{ return (*this = (T(*this) - i)); }
|
QSpecialIntegerBitfield &operator/=(T i) { return (*this = (T(*this) / i)); }
|
||||||
QSpecialIntegerBitfield &operator *=(T i)
|
QSpecialIntegerBitfield &operator%=(T i) { return (*this = (T(*this) % i)); }
|
||||||
{ return (*this = (T(*this) * i)); }
|
QSpecialIntegerBitfield &operator|=(T i) { return (*this = (T(*this) | i)); }
|
||||||
QSpecialIntegerBitfield &operator /=(T i)
|
QSpecialIntegerBitfield &operator&=(T i) { return (*this = (T(*this) & i)); }
|
||||||
{ return (*this = (T(*this) / i)); }
|
QSpecialIntegerBitfield &operator^=(T i) { return (*this = (T(*this) ^ i)); }
|
||||||
QSpecialIntegerBitfield &operator %=(T i)
|
QSpecialIntegerBitfield &operator>>=(T i) { return (*this = (T(*this) >> i)); }
|
||||||
{ return (*this = (T(*this) % i)); }
|
QSpecialIntegerBitfield &operator<<=(T i) { return (*this = (T(*this) << i)); }
|
||||||
QSpecialIntegerBitfield &operator |=(T i)
|
|
||||||
{ return (*this = (T(*this) | i)); }
|
|
||||||
QSpecialIntegerBitfield &operator &=(T i)
|
|
||||||
{ return (*this = (T(*this) & i)); }
|
|
||||||
QSpecialIntegerBitfield &operator ^=(T i)
|
|
||||||
{ return (*this = (T(*this) ^ i)); }
|
|
||||||
QSpecialIntegerBitfield &operator >>=(T i)
|
|
||||||
{ return (*this = (T(*this) >> i)); }
|
|
||||||
QSpecialIntegerBitfield &operator <<=(T i)
|
|
||||||
{ return (*this = (T(*this) << i)); }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T, int pos, int width>
|
template<typename T, int pos, int width>
|
||||||
@ -136,7 +130,6 @@ using qint32_be_bitfield = QBEIntegerBitfield<int, pos, width>;
|
|||||||
template<int pos, int width>
|
template<int pos, int width>
|
||||||
using quint32_be_bitfield = QBEIntegerBitfield<uint, pos, width>;
|
using quint32_be_bitfield = QBEIntegerBitfield<uint, pos, width>;
|
||||||
|
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
#endif // QENDIAN_P_H
|
#endif // QENDIAN_P_H
|
||||||
|
@ -89,8 +89,8 @@ template<typename Enum>
|
|||||||
class QFlags
|
class QFlags
|
||||||
{
|
{
|
||||||
static_assert((sizeof(Enum) <= sizeof(int)),
|
static_assert((sizeof(Enum) <= sizeof(int)),
|
||||||
"QFlags uses an int as storage, so an enum with underlying "
|
"QFlags uses an int as storage, so an enum with underlying "
|
||||||
"long long will overflow.");
|
"long long will overflow.");
|
||||||
static_assert((std::is_enum<Enum>::value), "QFlags is only usable on enumeration types.");
|
static_assert((std::is_enum<Enum>::value), "QFlags is only usable on enumeration types.");
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -1963,7 +1963,7 @@ QWindowsSockInit::QWindowsSockInit()
|
|||||||
WSAData wsadata;
|
WSAData wsadata;
|
||||||
|
|
||||||
// IPv6 requires Winsock v2.0 or better.
|
// IPv6 requires Winsock v2.0 or better.
|
||||||
if (WSAStartup(MAKEWORD(2,0), &wsadata) != 0) {
|
if (WSAStartup(MAKEWORD(2, 0), &wsadata) != 0) {
|
||||||
qWarning("QTcpSocketAPI: WinSock v2.0 initialization failed.");
|
qWarning("QTcpSocketAPI: WinSock v2.0 initialization failed.");
|
||||||
} else {
|
} else {
|
||||||
version = 0x20;
|
version = 0x20;
|
||||||
@ -2095,7 +2095,7 @@ static bool readEtcFile(QUnixOSVersion &v, const char *filename,
|
|||||||
const char *end = buffer.constEnd();
|
const char *end = buffer.constEnd();
|
||||||
const char *eol;
|
const char *eol;
|
||||||
QByteArray line;
|
QByteArray line;
|
||||||
for ( ; ptr != end; ptr = eol + 1) {
|
for (; ptr != end; ptr = eol + 1) {
|
||||||
// find the end of the line after ptr
|
// find the end of the line after ptr
|
||||||
eol = static_cast<const char *>(memchr(ptr, '\n', end - ptr));
|
eol = static_cast<const char *>(memchr(ptr, '\n', end - ptr));
|
||||||
if (!eol)
|
if (!eol)
|
||||||
@ -3135,17 +3135,17 @@ void qt_assert_x(const char *where, const char *what, const char *file, int line
|
|||||||
Q_CORE_EXPORT Q_DECL_CONST_FUNCTION unsigned int qt_int_sqrt(unsigned int n)
|
Q_CORE_EXPORT Q_DECL_CONST_FUNCTION unsigned int qt_int_sqrt(unsigned int n)
|
||||||
{
|
{
|
||||||
// n must be in the range 0...UINT_MAX/2-1
|
// n must be in the range 0...UINT_MAX/2-1
|
||||||
if (n >= (UINT_MAX>>2)) {
|
if (n >= (UINT_MAX >> 2)) {
|
||||||
unsigned int r = 2 * qt_int_sqrt(n / 4);
|
unsigned int r = 2 * qt_int_sqrt(n / 4);
|
||||||
unsigned int r2 = r + 1;
|
unsigned int r2 = r + 1;
|
||||||
return (n >= r2 * r2) ? r2 : r;
|
return (n >= r2 * r2) ? r2 : r;
|
||||||
}
|
}
|
||||||
uint h, p= 0, q= 1, r= n;
|
uint h, p = 0, q = 1, r = n;
|
||||||
while (q <= n)
|
while (q <= n)
|
||||||
q <<= 2;
|
q <<= 2;
|
||||||
while (q != 1) {
|
while (q != 1) {
|
||||||
q >>= 2;
|
q >>= 2;
|
||||||
h= p + q;
|
h = p + q;
|
||||||
p >>= 1;
|
p >>= 1;
|
||||||
if (r >= h) {
|
if (r >= h) {
|
||||||
p += q;
|
p += q;
|
||||||
@ -3229,7 +3229,6 @@ QByteArray qgetenv(const char *varName)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn QString qEnvironmentVariable(const char *varName, const QString &defaultValue)
|
\fn QString qEnvironmentVariable(const char *varName, const QString &defaultValue)
|
||||||
\fn QString qEnvironmentVariable(const char *varName)
|
\fn QString qEnvironmentVariable(const char *varName)
|
||||||
@ -3459,7 +3458,7 @@ bool qEnvironmentVariableIsSet(const char *varName) noexcept
|
|||||||
|
|
||||||
\sa qgetenv(), qEnvironmentVariable()
|
\sa qgetenv(), qEnvironmentVariable()
|
||||||
*/
|
*/
|
||||||
bool qputenv(const char *varName, const QByteArray& value)
|
bool qputenv(const char *varName, const QByteArray &value)
|
||||||
{
|
{
|
||||||
const auto locker = qt_scoped_lock(environmentMutex);
|
const auto locker = qt_scoped_lock(environmentMutex);
|
||||||
#if defined(Q_CC_MSVC)
|
#if defined(Q_CC_MSVC)
|
||||||
@ -3471,7 +3470,7 @@ bool qputenv(const char *varName, const QByteArray& value)
|
|||||||
QByteArray buffer(varName);
|
QByteArray buffer(varName);
|
||||||
buffer += '=';
|
buffer += '=';
|
||||||
buffer += value;
|
buffer += value;
|
||||||
char* envVar = qstrdup(buffer.constData());
|
char *envVar = qstrdup(buffer.constData());
|
||||||
int result = putenv(envVar);
|
int result = putenv(envVar);
|
||||||
if (result != 0) // error. we have to delete the string.
|
if (result != 0) // error. we have to delete the string.
|
||||||
delete[] envVar;
|
delete[] envVar;
|
||||||
@ -4024,7 +4023,8 @@ bool qunsetenv(const char *varName)
|
|||||||
with meaningful parameter names in their signatures.
|
with meaningful parameter names in their signatures.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct QInternal_CallBackTable {
|
struct QInternal_CallBackTable
|
||||||
|
{
|
||||||
QList<QList<qInternalCallback>> callbacks;
|
QList<QList<qInternalCallback>> callbacks;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -4046,7 +4046,7 @@ bool QInternal::unregisterCallback(Callback cb, qInternalCallback callback)
|
|||||||
if (unsigned(cb) < unsigned(QInternal::LastCallback)) {
|
if (unsigned(cb) < unsigned(QInternal::LastCallback)) {
|
||||||
if (global_callback_table.exists()) {
|
if (global_callback_table.exists()) {
|
||||||
QInternal_CallBackTable *cbt = global_callback_table();
|
QInternal_CallBackTable *cbt = global_callback_table();
|
||||||
return (bool) cbt->callbacks[cb].removeAll(callback);
|
return cbt->callbacks[cb].removeAll(callback) > 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -4063,7 +4063,7 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters)
|
|||||||
if (cbt && cb < cbt->callbacks.size()) {
|
if (cbt && cb < cbt->callbacks.size()) {
|
||||||
QList<qInternalCallback> callbacks = cbt->callbacks[cb];
|
QList<qInternalCallback> callbacks = cbt->callbacks[cb];
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
for (int i=0; i<callbacks.size(); ++i)
|
for (int i = 0; i < callbacks.size(); ++i)
|
||||||
ret |= (callbacks.at(i))(parameters);
|
ret |= (callbacks.at(i))(parameters);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -553,8 +553,8 @@ template <> struct QIntegerForSize<16> { __extension__ typedef unsigned __int
|
|||||||
template <class T> struct QIntegerForSizeof: QIntegerForSize<sizeof(T)> { };
|
template <class T> struct QIntegerForSizeof: QIntegerForSize<sizeof(T)> { };
|
||||||
typedef QIntegerForSize<Q_PROCESSOR_WORDSIZE>::Signed qregisterint;
|
typedef QIntegerForSize<Q_PROCESSOR_WORDSIZE>::Signed qregisterint;
|
||||||
typedef QIntegerForSize<Q_PROCESSOR_WORDSIZE>::Unsigned qregisteruint;
|
typedef QIntegerForSize<Q_PROCESSOR_WORDSIZE>::Unsigned qregisteruint;
|
||||||
typedef QIntegerForSizeof<void*>::Unsigned quintptr;
|
typedef QIntegerForSizeof<void *>::Unsigned quintptr;
|
||||||
typedef QIntegerForSizeof<void*>::Signed qptrdiff;
|
typedef QIntegerForSizeof<void *>::Signed qptrdiff;
|
||||||
typedef qptrdiff qintptr;
|
typedef qptrdiff qintptr;
|
||||||
using qsizetype = QIntegerForSizeof<std::size_t>::Signed;
|
using qsizetype = QIntegerForSizeof<std::size_t>::Signed;
|
||||||
|
|
||||||
|
@ -132,17 +132,29 @@ struct QGlobalStatic
|
|||||||
|
|
||||||
bool isDestroyed() const { return guard.loadRelaxed() <= QtGlobalStatic::Destroyed; }
|
bool isDestroyed() const { return guard.loadRelaxed() <= QtGlobalStatic::Destroyed; }
|
||||||
bool exists() const { return guard.loadRelaxed() == QtGlobalStatic::Initialized; }
|
bool exists() const { return guard.loadRelaxed() == QtGlobalStatic::Initialized; }
|
||||||
operator Type *() { if (isDestroyed()) return nullptr; return innerFunction(); }
|
operator Type *()
|
||||||
Type *operator()() { if (isDestroyed()) return nullptr; return innerFunction(); }
|
{
|
||||||
|
if (isDestroyed())
|
||||||
|
return nullptr;
|
||||||
|
return innerFunction();
|
||||||
|
}
|
||||||
|
Type *operator()()
|
||||||
|
{
|
||||||
|
if (isDestroyed())
|
||||||
|
return nullptr;
|
||||||
|
return innerFunction();
|
||||||
|
}
|
||||||
Type *operator->()
|
Type *operator->()
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(!isDestroyed(), "Q_GLOBAL_STATIC", "The global static was used after being destroyed");
|
Q_ASSERT_X(!isDestroyed(), "Q_GLOBAL_STATIC",
|
||||||
return innerFunction();
|
"The global static was used after being destroyed");
|
||||||
|
return innerFunction();
|
||||||
}
|
}
|
||||||
Type &operator*()
|
Type &operator*()
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(!isDestroyed(), "Q_GLOBAL_STATIC", "The global static was used after being destroyed");
|
Q_ASSERT_X(!isDestroyed(), "Q_GLOBAL_STATIC",
|
||||||
return *innerFunction();
|
"The global static was used after being destroyed");
|
||||||
|
return *innerFunction();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE
|
|||||||
class Q_CORE_EXPORT QLibraryInfo
|
class Q_CORE_EXPORT QLibraryInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static const char * build() noexcept;
|
static const char *build() noexcept;
|
||||||
|
|
||||||
static bool isDebugBuild();
|
static bool isDebugBuild();
|
||||||
|
|
||||||
@ -57,8 +57,7 @@ public:
|
|||||||
static QVersionNumber version() noexcept Q_DECL_CONST_FUNCTION;
|
static QVersionNumber version() noexcept Q_DECL_CONST_FUNCTION;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
enum LibraryPath
|
enum LibraryPath {
|
||||||
{
|
|
||||||
PrefixPath = 0,
|
PrefixPath = 0,
|
||||||
DocumentationPath,
|
DocumentationPath,
|
||||||
HeadersPath,
|
HeadersPath,
|
||||||
|
@ -1069,8 +1069,8 @@ static const char emptyTokenC[] = "";
|
|||||||
|
|
||||||
static const char defaultPattern[] = "%{if-category}%{category}: %{endif}%{message}";
|
static const char defaultPattern[] = "%{if-category}%{category}: %{endif}%{message}";
|
||||||
|
|
||||||
|
struct QMessagePattern
|
||||||
struct QMessagePattern {
|
{
|
||||||
QMessagePattern();
|
QMessagePattern();
|
||||||
~QMessagePattern();
|
~QMessagePattern();
|
||||||
|
|
||||||
@ -1078,13 +1078,14 @@ struct QMessagePattern {
|
|||||||
|
|
||||||
// 0 terminated arrays of literal tokens / literal or placeholder tokens
|
// 0 terminated arrays of literal tokens / literal or placeholder tokens
|
||||||
std::unique_ptr<std::unique_ptr<const char[]>[]> literals;
|
std::unique_ptr<std::unique_ptr<const char[]>[]> literals;
|
||||||
std::unique_ptr<const char*[]> tokens;
|
std::unique_ptr<const char *[]> tokens;
|
||||||
QList<QString> timeArgs; // timeFormats in sequence of %{time
|
QList<QString> timeArgs; // timeFormats in sequence of %{time
|
||||||
#ifndef QT_BOOTSTRAPPED
|
#ifndef QT_BOOTSTRAPPED
|
||||||
QElapsedTimer timer;
|
QElapsedTimer timer;
|
||||||
#endif
|
#endif
|
||||||
#ifdef QLOGGING_HAVE_BACKTRACE
|
#ifdef QLOGGING_HAVE_BACKTRACE
|
||||||
struct BacktraceParams {
|
struct BacktraceParams
|
||||||
|
{
|
||||||
QString backtraceSeparator;
|
QString backtraceSeparator;
|
||||||
int backtraceDepth;
|
int backtraceDepth;
|
||||||
};
|
};
|
||||||
@ -1115,8 +1116,7 @@ QMessagePattern::QMessagePattern()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QMessagePattern::~QMessagePattern()
|
QMessagePattern::~QMessagePattern() = default;
|
||||||
= default;
|
|
||||||
|
|
||||||
void QMessagePattern::setPattern(const QString &pattern)
|
void QMessagePattern::setPattern(const QString &pattern)
|
||||||
{
|
{
|
||||||
@ -1158,7 +1158,7 @@ void QMessagePattern::setPattern(const QString &pattern)
|
|||||||
|
|
||||||
// tokenizer
|
// tokenizer
|
||||||
std::vector<std::unique_ptr<const char[]>> literalsVar;
|
std::vector<std::unique_ptr<const char[]>> literalsVar;
|
||||||
tokens.reset(new const char*[lexemes.size() + 1]);
|
tokens.reset(new const char *[lexemes.size() + 1]);
|
||||||
tokens[lexemes.size()] = nullptr;
|
tokens[lexemes.size()] = nullptr;
|
||||||
|
|
||||||
bool nestedIfError = false;
|
bool nestedIfError = false;
|
||||||
@ -1290,7 +1290,7 @@ static QStringList backtraceFramesForLogMessage(int frameCount)
|
|||||||
// This code is protected by QMessagePattern::mutex so it is thread safe on all compilers
|
// This code is protected by QMessagePattern::mutex so it is thread safe on all compilers
|
||||||
static const QRegularExpression rx(QStringLiteral("^(?:[^(]*/)?([^(/]+)\\(([^+]*)(?:[\\+[a-f0-9x]*)?\\) \\[[a-f0-9x]*\\]$"));
|
static const QRegularExpression rx(QStringLiteral("^(?:[^(]*/)?([^(/]+)\\(([^+]*)(?:[\\+[a-f0-9x]*)?\\) \\[[a-f0-9x]*\\]$"));
|
||||||
|
|
||||||
QVarLengthArray<void*, 32> buffer(8 + frameCount);
|
QVarLengthArray<void *, 32> buffer(8 + frameCount);
|
||||||
int n = backtrace(buffer.data(), buffer.size());
|
int n = backtrace(buffer.data(), buffer.size());
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
int numberPrinted = 0;
|
int numberPrinted = 0;
|
||||||
@ -1642,11 +1642,21 @@ static bool android_default_message_handler(QtMsgType type,
|
|||||||
|
|
||||||
android_LogPriority priority = ANDROID_LOG_DEBUG;
|
android_LogPriority priority = ANDROID_LOG_DEBUG;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case QtDebugMsg: priority = ANDROID_LOG_DEBUG; break;
|
case QtDebugMsg:
|
||||||
case QtInfoMsg: priority = ANDROID_LOG_INFO; break;
|
priority = ANDROID_LOG_DEBUG;
|
||||||
case QtWarningMsg: priority = ANDROID_LOG_WARN; break;
|
break;
|
||||||
case QtCriticalMsg: priority = ANDROID_LOG_ERROR; break;
|
case QtInfoMsg:
|
||||||
case QtFatalMsg: priority = ANDROID_LOG_FATAL; break;
|
priority = ANDROID_LOG_INFO;
|
||||||
|
break;
|
||||||
|
case QtWarningMsg:
|
||||||
|
priority = ANDROID_LOG_WARN;
|
||||||
|
break;
|
||||||
|
case QtCriticalMsg:
|
||||||
|
priority = ANDROID_LOG_ERROR;
|
||||||
|
break;
|
||||||
|
case QtFatalMsg:
|
||||||
|
priority = ANDROID_LOG_FATAL;
|
||||||
|
break;
|
||||||
};
|
};
|
||||||
|
|
||||||
__android_log_print(priority, qPrintable(QCoreApplication::applicationName()), "%s\n", qPrintable(formattedMessage));
|
__android_log_print(priority, qPrintable(QCoreApplication::applicationName()), "%s\n", qPrintable(formattedMessage));
|
||||||
@ -1666,8 +1676,8 @@ static void win_outputDebugString_helper(QStringView message)
|
|||||||
OutputDebugString(reinterpret_cast<const wchar_t *>(message.utf16()));
|
OutputDebugString(reinterpret_cast<const wchar_t *>(message.utf16()));
|
||||||
} else {
|
} else {
|
||||||
wchar_t *messagePart = new wchar_t[maxOutputStringLength + 1];
|
wchar_t *messagePart = new wchar_t[maxOutputStringLength + 1];
|
||||||
for (int i = 0; i < message.length(); i += maxOutputStringLength ) {
|
for (int i = 0; i < message.length(); i += maxOutputStringLength) {
|
||||||
const int length = std::min(message.length() - i, maxOutputStringLength );
|
const int length = std::min(message.length() - i, maxOutputStringLength);
|
||||||
const int len = message.mid(i, length).toWCharArray(messagePart);
|
const int len = message.mid(i, length).toWCharArray(messagePart);
|
||||||
Q_ASSERT(len == length);
|
Q_ASSERT(len == length);
|
||||||
messagePart[len] = 0;
|
messagePart[len] = 0;
|
||||||
|
@ -57,7 +57,14 @@ QT_BEGIN_NAMESPACE
|
|||||||
class QDebug;
|
class QDebug;
|
||||||
class QNoDebug;
|
class QNoDebug;
|
||||||
|
|
||||||
enum QtMsgType { QtDebugMsg, QtWarningMsg, QtCriticalMsg, QtFatalMsg, QtInfoMsg, QtSystemMsg = QtCriticalMsg };
|
enum QtMsgType {
|
||||||
|
QtDebugMsg,
|
||||||
|
QtWarningMsg,
|
||||||
|
QtCriticalMsg,
|
||||||
|
QtFatalMsg,
|
||||||
|
QtInfoMsg,
|
||||||
|
QtSystemMsg = QtCriticalMsg
|
||||||
|
};
|
||||||
|
|
||||||
class QMessageLogContext
|
class QMessageLogContext
|
||||||
{
|
{
|
||||||
|
@ -58,9 +58,9 @@ void *qReallocAligned(void *oldptr, size_t newsize, size_t oldsize, size_t align
|
|||||||
{
|
{
|
||||||
// fake an aligned allocation
|
// fake an aligned allocation
|
||||||
void *actualptr = oldptr ? static_cast<void **>(oldptr)[-1] : nullptr;
|
void *actualptr = oldptr ? static_cast<void **>(oldptr)[-1] : nullptr;
|
||||||
if (alignment <= sizeof(void*)) {
|
if (alignment <= sizeof(void *)) {
|
||||||
// special, fast case
|
// special, fast case
|
||||||
void **newptr = static_cast<void **>(realloc(actualptr, newsize + sizeof(void*)));
|
void **newptr = static_cast<void **>(realloc(actualptr, newsize + sizeof(void *)));
|
||||||
if (!newptr)
|
if (!newptr)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
if (newptr == actualptr) {
|
if (newptr == actualptr) {
|
||||||
@ -112,4 +112,3 @@ void qFreeAligned(void *ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ Q_DECL_CONST_FUNCTION static inline int fpclassify(float f) { return std::fpclas
|
|||||||
constexpr Q_DECL_CONST_FUNCTION static inline double qt_inf() noexcept
|
constexpr Q_DECL_CONST_FUNCTION static inline double qt_inf() noexcept
|
||||||
{
|
{
|
||||||
static_assert(std::numeric_limits<double>::has_infinity,
|
static_assert(std::numeric_limits<double>::has_infinity,
|
||||||
"platform has no definition for infinity for type double");
|
"platform has no definition for infinity for type double");
|
||||||
return std::numeric_limits<double>::infinity();
|
return std::numeric_limits<double>::infinity();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ constexpr Q_DECL_CONST_FUNCTION static inline double qt_inf() noexcept
|
|||||||
constexpr Q_DECL_CONST_FUNCTION static inline double qt_snan() noexcept
|
constexpr Q_DECL_CONST_FUNCTION static inline double qt_snan() noexcept
|
||||||
{
|
{
|
||||||
static_assert(std::numeric_limits<double>::has_signaling_NaN,
|
static_assert(std::numeric_limits<double>::has_signaling_NaN,
|
||||||
"platform has no definition for signaling NaN for type double");
|
"platform has no definition for signaling NaN for type double");
|
||||||
return std::numeric_limits<double>::signaling_NaN();
|
return std::numeric_limits<double>::signaling_NaN();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -147,7 +147,7 @@ constexpr Q_DECL_CONST_FUNCTION static inline double qt_snan() noexcept
|
|||||||
constexpr Q_DECL_CONST_FUNCTION static inline double qt_qnan() noexcept
|
constexpr Q_DECL_CONST_FUNCTION static inline double qt_qnan() noexcept
|
||||||
{
|
{
|
||||||
static_assert(std::numeric_limits<double>::has_quiet_NaN,
|
static_assert(std::numeric_limits<double>::has_quiet_NaN,
|
||||||
"platform has no definition for quiet NaN for type double");
|
"platform has no definition for quiet NaN for type double");
|
||||||
return std::numeric_limits<double>::quiet_NaN();
|
return std::numeric_limits<double>::quiet_NaN();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,7 +203,8 @@ namespace {
|
|||||||
This function works for v containing infinities, but not NaN. It's the
|
This function works for v containing infinities, but not NaN. It's the
|
||||||
caller's responsibility to exclude that possibility before calling it.
|
caller's responsibility to exclude that possibility before calling it.
|
||||||
*/
|
*/
|
||||||
template <typename T> static inline bool convertDoubleTo(double v, T *value, bool allow_precision_upgrade = true)
|
template<typename T>
|
||||||
|
static inline bool convertDoubleTo(double v, T *value, bool allow_precision_upgrade = true)
|
||||||
{
|
{
|
||||||
static_assert(std::numeric_limits<T>::is_integer);
|
static_assert(std::numeric_limits<T>::is_integer);
|
||||||
|
|
||||||
|
@ -181,7 +181,8 @@ struct QRandomGenerator::SystemGenerator
|
|||||||
|
|
||||||
// For std::mersenne_twister_engine implementations that use something
|
// For std::mersenne_twister_engine implementations that use something
|
||||||
// other than quint32 (unsigned int) to fill their buffers.
|
// other than quint32 (unsigned int) to fill their buffers.
|
||||||
template <typename T> void generate(T *begin, T *end)
|
template<typename T>
|
||||||
|
void generate(T *begin, T *end)
|
||||||
{
|
{
|
||||||
static_assert(sizeof(T) >= sizeof(quint32));
|
static_assert(sizeof(T) >= sizeof(quint32));
|
||||||
if (sizeof(T) == sizeof(quint32)) {
|
if (sizeof(T) == sizeof(quint32)) {
|
||||||
@ -414,7 +415,8 @@ struct QRandomGenerator::SystemAndGlobalGenerators
|
|||||||
new (&rng->storage.engine()) RandomEngine(self()->sys);
|
new (&rng->storage.engine()) RandomEngine(self()->sys);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct PRNGLocker {
|
struct PRNGLocker
|
||||||
|
{
|
||||||
const bool locked;
|
const bool locked;
|
||||||
PRNGLocker(const QRandomGenerator *that)
|
PRNGLocker(const QRandomGenerator *that)
|
||||||
: locked(that == globalNoInit())
|
: locked(that == globalNoInit())
|
||||||
|
@ -76,13 +76,12 @@ Q_CORE_EXPORT QBasicAtomicInteger<uint> qt_randomdevice_control = Q_BASIC_ATOMIC
|
|||||||
#elif defined(QT_BUILD_INTERNAL)
|
#elif defined(QT_BUILD_INTERNAL)
|
||||||
extern Q_CORE_EXPORT QBasicAtomicInteger<uint> qt_randomdevice_control;
|
extern Q_CORE_EXPORT QBasicAtomicInteger<uint> qt_randomdevice_control;
|
||||||
#else
|
#else
|
||||||
static const struct {
|
static const struct
|
||||||
|
{
|
||||||
uint loadAcquire() const { return 0; }
|
uint loadAcquire() const { return 0; }
|
||||||
} qt_randomdevice_control;
|
} qt_randomdevice_control;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
#endif // QRANDOM_P_H
|
#endif // QRANDOM_P_H
|
||||||
|
@ -428,38 +428,46 @@ static quint64 detectProcessorFeatures()
|
|||||||
// QSimpleBuffer, which has the bare minimum needed to use memory
|
// QSimpleBuffer, which has the bare minimum needed to use memory
|
||||||
// dynamically and read lines from /proc/cpuinfo of arbitrary sizes.
|
// dynamically and read lines from /proc/cpuinfo of arbitrary sizes.
|
||||||
//
|
//
|
||||||
struct QSimpleBuffer {
|
struct QSimpleBuffer
|
||||||
|
{
|
||||||
static const int chunk_size = 256;
|
static const int chunk_size = 256;
|
||||||
char *data;
|
char *data;
|
||||||
unsigned alloc;
|
unsigned alloc;
|
||||||
unsigned size;
|
unsigned size;
|
||||||
|
|
||||||
QSimpleBuffer(): data(0), alloc(0), size(0) {}
|
QSimpleBuffer() : data(nullptr), alloc(0), size(0) { }
|
||||||
~QSimpleBuffer() { ::free(data); }
|
~QSimpleBuffer() { ::free(data); }
|
||||||
|
|
||||||
void resize(unsigned newsize) {
|
void resize(unsigned newsize)
|
||||||
|
{
|
||||||
if (newsize > alloc) {
|
if (newsize > alloc) {
|
||||||
unsigned newalloc = chunk_size * ((newsize / chunk_size) + 1);
|
unsigned newalloc = chunk_size * ((newsize / chunk_size) + 1);
|
||||||
if (newalloc < newsize) newalloc = newsize;
|
if (newalloc < newsize)
|
||||||
|
newalloc = newsize;
|
||||||
if (newalloc != alloc) {
|
if (newalloc != alloc) {
|
||||||
data = static_cast<char*>(::realloc(data, newalloc));
|
data = static_cast<char *>(::realloc(data, newalloc));
|
||||||
alloc = newalloc;
|
alloc = newalloc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
size = newsize;
|
size = newsize;
|
||||||
}
|
}
|
||||||
void append(const QSimpleBuffer &other, unsigned appendsize) {
|
void append(const QSimpleBuffer &other, unsigned appendsize)
|
||||||
|
{
|
||||||
unsigned oldsize = size;
|
unsigned oldsize = size;
|
||||||
resize(oldsize + appendsize);
|
resize(oldsize + appendsize);
|
||||||
::memcpy(data + oldsize, other.data, appendsize);
|
::memcpy(data + oldsize, other.data, appendsize);
|
||||||
}
|
}
|
||||||
void popleft(unsigned amount) {
|
void popleft(unsigned amount)
|
||||||
if (amount >= size) return resize(0);
|
{
|
||||||
|
if (amount >= size)
|
||||||
|
return resize(0);
|
||||||
size -= amount;
|
size -= amount;
|
||||||
::memmove(data, data + amount, size);
|
::memmove(data, data + amount, size);
|
||||||
}
|
}
|
||||||
char* cString() {
|
char *cString()
|
||||||
if (!alloc) resize(1);
|
{
|
||||||
|
if (!alloc)
|
||||||
|
resize(1);
|
||||||
return (data[size] = '\0', data);
|
return (data[size] = '\0', data);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -473,7 +481,7 @@ struct QSimpleBuffer {
|
|||||||
static void bufReadLine(int fd, QSimpleBuffer &line, QSimpleBuffer &buffer)
|
static void bufReadLine(int fd, QSimpleBuffer &line, QSimpleBuffer &buffer)
|
||||||
{
|
{
|
||||||
for (;;) {
|
for (;;) {
|
||||||
char *newline = static_cast<char*>(::memchr(buffer.data, '\n', buffer.size));
|
char *newline = static_cast<char *>(::memchr(buffer.data, '\n', buffer.size));
|
||||||
if (newline) {
|
if (newline) {
|
||||||
unsigned piece_size = newline - buffer.data + 1;
|
unsigned piece_size = newline - buffer.data + 1;
|
||||||
line.append(buffer, piece_size);
|
line.append(buffer, piece_size);
|
||||||
@ -486,9 +494,12 @@ static void bufReadLine(int fd, QSimpleBuffer &line, QSimpleBuffer &buffer)
|
|||||||
buffer.resize(buffer.size + QSimpleBuffer::chunk_size);
|
buffer.resize(buffer.size + QSimpleBuffer::chunk_size);
|
||||||
buffer.size = oldsize;
|
buffer.size = oldsize;
|
||||||
}
|
}
|
||||||
ssize_t read_bytes = ::qt_safe_read(fd, buffer.data + buffer.size, QSimpleBuffer::chunk_size);
|
ssize_t read_bytes =
|
||||||
if (read_bytes > 0) buffer.size += read_bytes;
|
::qt_safe_read(fd, buffer.data + buffer.size, QSimpleBuffer::chunk_size);
|
||||||
else return;
|
if (read_bytes > 0)
|
||||||
|
buffer.size += read_bytes;
|
||||||
|
else
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -509,7 +520,7 @@ static bool procCpuinfoContains(const char *prefix, const char *string)
|
|||||||
do {
|
do {
|
||||||
line.resize(0);
|
line.resize(0);
|
||||||
bufReadLine(cpuinfo_fd, line, buffer);
|
bufReadLine(cpuinfo_fd, line, buffer);
|
||||||
char *colon = static_cast<char*>(::memchr(line.data, ':', line.size));
|
char *colon = static_cast<char *>(::memchr(line.data, ':', line.size));
|
||||||
if (colon && line.size > prefix_len + string_len) {
|
if (colon && line.size > prefix_len + string_len) {
|
||||||
if (!::strncmp(prefix, line.data, prefix_len)) {
|
if (!::strncmp(prefix, line.data, prefix_len)) {
|
||||||
// prefix matches, next character must be ':' or space
|
// prefix matches, next character must be ':' or space
|
||||||
@ -657,10 +668,10 @@ static QT_FUNCTION_TARGET(RDSEED) unsigned *qt_random_rdseed(unsigned *ptr, unsi
|
|||||||
// If the independent bit generator used by RDSEED is out of entropy, it
|
// If the independent bit generator used by RDSEED is out of entropy, it
|
||||||
// may take time to replenish.
|
// may take time to replenish.
|
||||||
// https://software.intel.com/en-us/articles/intel-digital-random-number-generator-drng-software-implementation-guide
|
// https://software.intel.com/en-us/articles/intel-digital-random-number-generator-drng-software-implementation-guide
|
||||||
while (ptr + sizeof(randuint)/sizeof(*ptr) <= end) {
|
while (ptr + sizeof(randuint) / sizeof(*ptr) <= end) {
|
||||||
if (_rdseedXX_step(reinterpret_cast<randuint *>(ptr)) == 0)
|
if (_rdseedXX_step(reinterpret_cast<randuint *>(ptr)) == 0)
|
||||||
goto out;
|
goto out;
|
||||||
ptr += sizeof(randuint)/sizeof(*ptr);
|
ptr += sizeof(randuint) / sizeof(*ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sizeof(*ptr) != sizeof(randuint) && ptr != end) {
|
if (sizeof(*ptr) != sizeof(randuint) && ptr != end) {
|
||||||
|
@ -50,7 +50,8 @@ QT_BEGIN_NAMESPACE
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
class QString;
|
class QString;
|
||||||
class Q_CORE_EXPORT QSysInfo {
|
class Q_CORE_EXPORT QSysInfo
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
enum Sizes {
|
enum Sizes {
|
||||||
WordSize = (sizeof(void *)<<3)
|
WordSize = (sizeof(void *)<<3)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user