summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/tools')
-rw-r--r--src/corelib/tools/qbytearray.cpp8
-rw-r--r--src/corelib/tools/qcollator.cpp2
-rw-r--r--src/corelib/tools/qpair.qdoc5
-rw-r--r--src/corelib/tools/qsimd.cpp18
-rw-r--r--src/corelib/tools/qsimd_p.h3
-rw-r--r--src/corelib/tools/qstring.cpp30
-rw-r--r--src/corelib/tools/qtimezoneprivate_tz.cpp19
7 files changed, 50 insertions, 35 deletions
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp
index 0434cebc15..447e84b3d4 100644
--- a/src/corelib/tools/qbytearray.cpp
+++ b/src/corelib/tools/qbytearray.cpp
@@ -511,7 +511,7 @@ QByteArray qCompress(const uchar* data, int nbytes, int compressionLevel)
int res;
do {
bazip.resize(len + 4);
- res = ::compress2((uchar*)bazip.data()+4, &len, (uchar*)data, nbytes, compressionLevel);
+ res = ::compress2((uchar*)bazip.data()+4, &len, data, nbytes, compressionLevel);
switch (res) {
case Z_OK:
@@ -602,7 +602,7 @@ QByteArray qUncompress(const uchar* data, int nbytes)
d->size = 0; // Shut up valgrind "uninitialized variable" warning
int res = ::uncompress((uchar*)d->data(), &len,
- (uchar*)data+4, nbytes-4);
+ data+4, nbytes-4);
switch (res) {
case Z_OK:
@@ -2186,9 +2186,9 @@ QByteArray &QByteArray::replace(const char *before, int bsize, const char *after
}
if (a != after)
- ::free((char *)a);
+ ::free(const_cast<char *>(a));
if (b != before)
- ::free((char *)b);
+ ::free(const_cast<char *>(b));
return *this;
diff --git a/src/corelib/tools/qcollator.cpp b/src/corelib/tools/qcollator.cpp
index 615b7a4e3e..59f8f66869 100644
--- a/src/corelib/tools/qcollator.cpp
+++ b/src/corelib/tools/qcollator.cpp
@@ -87,7 +87,7 @@ QCollator::QCollator(const QCollator &other)
}
/*!
- Destructor for QCollator.
+ Destroys the collator.
*/
QCollator::~QCollator()
{
diff --git a/src/corelib/tools/qpair.qdoc b/src/corelib/tools/qpair.qdoc
index 2a421a1bbf..7cba7480f0 100644
--- a/src/corelib/tools/qpair.qdoc
+++ b/src/corelib/tools/qpair.qdoc
@@ -109,7 +109,7 @@
\endcode
Swap overloads are found in namespace \c std as well as via
- argument-dependent lookup (ADL) in \c{T}'s namespace.
+ argument-dependent lookup (ADL) in the namespace of \c{T} .
*/
/*!
@@ -136,8 +136,7 @@
\fn QPair::QPair(QPair<TT1, TT2> &&p)
\since 5.2
- Move-constructs a QPair instance, making it point to the same object that
- \a p was pointing to.
+ Move-constructs a QPair instance, making it point to the same object that \a p was pointing to.
*/
/*!
diff --git a/src/corelib/tools/qsimd.cpp b/src/corelib/tools/qsimd.cpp
index d572dd209c..e7917ffdac 100644
--- a/src/corelib/tools/qsimd.cpp
+++ b/src/corelib/tools/qsimd.cpp
@@ -36,6 +36,10 @@
#include <QByteArray>
#include <stdio.h>
+#ifdef Q_OS_LINUX
+# include "../testlib/3rdparty/valgrind_p.h"
+#endif
+
#if defined(Q_OS_WIN)
# if defined(Q_OS_WINCE)
# include <qt_windows.h>
@@ -256,8 +260,12 @@ static inline uint detectProcessorFeatures()
uint features = 0;
int cpuidLevel = maxBasicCpuidSupported();
+#if Q_PROCESSOR_X86 < 5
if (cpuidLevel < 1)
return 0;
+#else
+ Q_ASSERT(cpuidLevel >= 1);
+#endif
uint cpuid01ECX = 0, cpuid01EDX = 0;
cpuidFeatures01(cpuid01ECX, cpuid01EDX);
@@ -497,8 +505,7 @@ static const int features_indices[] = {
static const int features_count = (sizeof features_indices - 1) / (sizeof features_indices[0]);
// record what CPU features were enabled by default in this Qt build
-// don't define for HLE, since the HLE prefix can be run on older CPUs
-static const uint minFeature = qCompilerCpuFeatures & ~HLE;
+static const uint minFeature = qCompilerCpuFeatures;
#ifdef Q_OS_WIN
#if defined(Q_CC_GNU)
@@ -554,7 +561,12 @@ void qDetectCpuFeatures()
}
}
- if (minFeature != 0 && (f & minFeature) != minFeature) {
+#ifdef RUNNING_ON_VALGRIND
+ bool runningOnValgrind = RUNNING_ON_VALGRIND;
+#else
+ bool runningOnValgrind = false;
+#endif
+ if (!runningOnValgrind && (minFeature != 0 && (f & minFeature) != minFeature)) {
uint missing = minFeature & ~f;
fprintf(stderr, "Incompatible processor. This Qt build requires the following features:\n ");
for (int i = 0; i < features_count; ++i) {
diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h
index 1f5e743b7f..dd93b4fd26 100644
--- a/src/corelib/tools/qsimd_p.h
+++ b/src/corelib/tools/qsimd_p.h
@@ -265,9 +265,6 @@ static const uint qCompilerCpuFeatures = 0
#if defined __RTM__
| RTM
#endif
-#if defined __HLE__
- | HLE
-#endif
#if defined __AVX2__
| AVX2
#endif
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 345114d907..8bb8953dde 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -215,7 +215,7 @@ void qt_from_latin1(ushort *dst, const char *str, size_t size)
// we're going to read str[offset..offset+15] (16 bytes)
for ( ; str + offset + 15 < e; offset += 16) {
- const __m128i chunk = _mm_loadu_si128((__m128i*)(str + offset)); // load
+ const __m128i chunk = _mm_loadu_si128((const __m128i*)(str + offset)); // load
#ifdef __AVX2__
// zero extend to an YMM register
const __m256i extended = _mm256_cvtepu8_epi16(chunk);
@@ -316,10 +316,10 @@ static void qt_to_latin1(uchar *dst, const ushort *src, int length)
// we're going to write to dst[offset..offset+15] (16 bytes)
for ( ; dst + offset + 15 < e; offset += 16) {
- __m128i chunk1 = _mm_loadu_si128((__m128i*)(src + offset)); // load
+ __m128i chunk1 = _mm_loadu_si128((const __m128i*)(src + offset)); // load
chunk1 = mergeQuestionMarks(chunk1);
- __m128i chunk2 = _mm_loadu_si128((__m128i*)(src + offset + 8)); // load
+ __m128i chunk2 = _mm_loadu_si128((const __m128i*)(src + offset + 8)); // load
chunk2 = mergeQuestionMarks(chunk2);
// pack the two vector to 16 x 8bits elements
@@ -458,8 +458,8 @@ static int ucstrncmp(const QChar *a, const QChar *b, int l)
// we're going to read ptr[0..15] (16 bytes)
for ( ; ptr + 15 < reinterpret_cast<const char *>(a); ptr += 16) {
- __m128i a_data = _mm_loadu_si128((__m128i*)ptr);
- __m128i b_data = _mm_loadu_si128((__m128i*)(ptr + distance));
+ __m128i a_data = _mm_loadu_si128((const __m128i*)ptr);
+ __m128i b_data = _mm_loadu_si128((const __m128i*)(ptr + distance));
__m128i result = _mm_cmpeq_epi16(a_data, b_data);
uint mask = ~_mm_movemask_epi8(result);
if (ushort(mask)) {
@@ -541,14 +541,14 @@ static int ucstrncmp(const QChar *a, const uchar *c, int l)
for ( ; uc + offset + 15 < e; offset += 16) {
// similar to fromLatin1_helper:
// load 16 bytes of Latin 1 data
- __m128i chunk = _mm_loadu_si128((__m128i*)(c + offset));
+ __m128i chunk = _mm_loadu_si128((const __m128i*)(c + offset));
# ifdef __AVX2__
// expand Latin 1 data via zero extension
__m256i ldata = _mm256_cvtepu8_epi16(chunk);
// load UTF-16 data and compare
- __m256i ucdata = _mm256_loadu_si256((__m256i*)(uc + offset));
+ __m256i ucdata = _mm256_loadu_si256((const __m256i*)(uc + offset));
__m256i result = _mm256_cmpeq_epi16(ldata, ucdata);
uint mask = ~_mm256_movemask_epi8(result);
@@ -558,8 +558,8 @@ static int ucstrncmp(const QChar *a, const uchar *c, int l)
__m128i secondHalf = _mm_unpackhi_epi8(chunk, nullmask);
// load UTF-16 data and compare
- __m128i ucdata1 = _mm_loadu_si128((__m128i*)(uc + offset));
- __m128i ucdata2 = _mm_loadu_si128((__m128i*)(uc + offset + 8));
+ __m128i ucdata1 = _mm_loadu_si128((const __m128i*)(uc + offset));
+ __m128i ucdata2 = _mm_loadu_si128((const __m128i*)(uc + offset + 8));
__m128i result1 = _mm_cmpeq_epi16(firstHalf, ucdata1);
__m128i result2 = _mm_cmpeq_epi16(secondHalf, ucdata2);
@@ -577,10 +577,10 @@ static int ucstrncmp(const QChar *a, const uchar *c, int l)
// we'll read uc[offset..offset+7] (16 bytes) and c[offset..offset+7] (8 bytes)
if (uc + offset + 7 < e) {
// same, but we're using an 8-byte load
- __m128i chunk = _mm_cvtsi64_si128(*(long long *)(c + offset));
+ __m128i chunk = _mm_cvtsi64_si128(*(const long long *)(c + offset));
__m128i secondHalf = _mm_unpacklo_epi8(chunk, nullmask);
- __m128i ucdata = _mm_loadu_si128((__m128i*)(uc + offset));
+ __m128i ucdata = _mm_loadu_si128((const __m128i*)(uc + offset));
__m128i result = _mm_cmpeq_epi16(secondHalf, ucdata);
uint mask = ~_mm_movemask_epi8(result);
if (ushort(mask)) {
@@ -672,7 +672,7 @@ static int findChar(const QChar *str, int len, QChar ch, int from,
// we're going to read n[0..7] (16 bytes)
for (const ushort *next = n + 8; next <= e; n = next, next += 8) {
- __m128i data = _mm_loadu_si128((__m128i*)n);
+ __m128i data = _mm_loadu_si128((const __m128i*)n);
__m128i result = _mm_cmpeq_epi16(data, mch);
uint mask = _mm_movemask_epi8(result);
if (ushort(mask)) {
@@ -2744,7 +2744,7 @@ bool operator<(const QString &s1, const QString &s2)
*/
bool QString::operator<(QLatin1String other) const
{
- const uchar *c = (uchar *) other.latin1();
+ const uchar *c = (const uchar *) other.latin1();
if (!c || *c == 0)
return false;
@@ -2849,7 +2849,7 @@ bool QString::operator<(QLatin1String other) const
*/
bool QString::operator>(QLatin1String other) const
{
- const uchar *c = (uchar *) other.latin1();
+ const uchar *c = (const uchar *) other.latin1();
if (!c || *c == '\0')
return !isEmpty();
@@ -5392,7 +5392,7 @@ int QString::compare_helper(const QChar *data1, int length1, QLatin1String s2,
{
const ushort *uc = reinterpret_cast<const ushort *>(data1);
const ushort *uce = uc + length1;
- const uchar *c = (uchar *)s2.latin1();
+ const uchar *c = (const uchar *)s2.latin1();
if (!c)
return length1;
diff --git a/src/corelib/tools/qtimezoneprivate_tz.cpp b/src/corelib/tools/qtimezoneprivate_tz.cpp
index 7c5e5bd2cf..90ce8e3b68 100644
--- a/src/corelib/tools/qtimezoneprivate_tz.cpp
+++ b/src/corelib/tools/qtimezoneprivate_tz.cpp
@@ -389,12 +389,19 @@ static int parsePosixOffset(const QByteArray &timeRule)
// Format "[+|-]hh[:mm[:ss]]"
QList<QByteArray> parts = timeRule.split(':');
int count = parts.count();
- if (count == 3)
- return (parts.at(0).toInt() * -60 * 60) + (parts.at(1).toInt() * 60) + parts.at(2).toInt();
- else if (count == 2)
- return (parts.at(0).toInt() * -60 * 60) + (parts.at(1).toInt() * 60);
- else if (count == 1)
- return (parts.at(0).toInt() * -60 * 60);
+ if (count == 3) {
+ int hour = parts.at(0).toInt();
+ int sign = hour >= 0 ? -1 : 1;
+ return sign * ((qAbs(hour) * 60 * 60) + (parts.at(1).toInt() * 60) + parts.at(2).toInt());
+ } else if (count == 2) {
+ int hour = parts.at(0).toInt();
+ int sign = hour >= 0 ? -1 : 1;
+ return sign * ((qAbs(hour) * 60 * 60) + (parts.at(1).toInt() * 60));
+ } else if (count == 1) {
+ int hour = parts.at(0).toInt();
+ int sign = hour >= 0 ? -1 : 1;
+ return sign * (qAbs(hour) * 60 * 60);
+ }
return 0;
}