summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/corelib.pro9
-rw-r--r--src/corelib/doc/src/objectmodel/signalsandslots.qdoc3
-rw-r--r--src/corelib/global/qlogging.cpp2
-rw-r--r--src/corelib/global/qsystemdetection.h3
-rw-r--r--src/corelib/global/qt_windows.h20
-rw-r--r--src/corelib/io/qfilesystemiterator_win.cpp7
-rw-r--r--src/corelib/io/qprocess.h2
-rw-r--r--src/corelib/io/qprocess_win.cpp6
-rw-r--r--src/corelib/io/qsettings_win.cpp6
-rw-r--r--src/corelib/io/qtextstream.cpp19
-rw-r--r--src/corelib/json/qjson_p.h9
-rw-r--r--src/corelib/json/qjsonparser.cpp2
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp47
-rw-r--r--src/corelib/kernel/qcoreapplication.h2
-rw-r--r--src/corelib/kernel/qcoreapplication_p.h2
-rw-r--r--src/corelib/kernel/qcoreevent.h5
-rw-r--r--src/corelib/kernel/qobjectdefs.h15
-rw-r--r--src/corelib/mimetypes/qmimemagicrule.cpp3
-rw-r--r--src/corelib/mimetypes/qmimeprovider.cpp3
-rw-r--r--src/corelib/thread/qthread_win.cpp6
-rw-r--r--src/corelib/thread/thread.pri34
-rw-r--r--src/corelib/tools/qhash.cpp8
-rw-r--r--src/corelib/tools/qsimd.cpp22
-rw-r--r--src/corelib/tools/qsimd_p.h26
-rw-r--r--src/corelib/tools/qstring.cpp8
25 files changed, 163 insertions, 106 deletions
diff --git a/src/corelib/corelib.pro b/src/corelib/corelib.pro
index 78ea489ebc..362ac37a59 100644
--- a/src/corelib/corelib.pro
+++ b/src/corelib/corelib.pro
@@ -7,6 +7,7 @@ MODULE_CONFIG = moc resources
!isEmpty(QT_NAMESPACE): MODULE_DEFINES = QT_NAMESPACE=$$QT_NAMESPACE
CONFIG += $$MODULE_CONFIG
+DEFINES += $$MODULE_DEFINES
DEFINES += QT_NO_USING_NAMESPACE
win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x67000000
irix-cc*:QMAKE_CXXFLAGS += -no_prelink -ptused
@@ -29,7 +30,6 @@ ANDROID_PERMISSIONS = \
# variable and on FreeBSD, this variable is in the final executable itself
freebsd: QMAKE_LFLAGS_NOUNDEF =
-load(qt_module)
load(qfeatures)
include(animation/animation.pri)
@@ -58,8 +58,6 @@ mac|darwin {
LIBS_PRIVATE += -framework CoreFoundation
LIBS_PRIVATE += -framework Foundation
}
-win32:DEFINES-=QT_NO_CAST_TO_ASCII
-DEFINES += $$MODULE_DEFINES
QMAKE_LIBS += $$QMAKE_LIBS_CORE
@@ -76,6 +74,11 @@ qt_conf.variable = QT_CONFIG
QMAKE_PKGCONFIG_VARIABLES += host_bins qt_conf
+load(qt_module)
+
+# Override qt_module, so the symbols are actually included into the library.
+win32: DEFINES -= QT_NO_CAST_TO_ASCII
+
ctest_macros_file.input = $$PWD/Qt5CTestMacros.cmake
ctest_macros_file.output = $$DESTDIR/cmake/Qt5Core/Qt5CTestMacros.cmake
ctest_macros_file.CONFIG = verbatim
diff --git a/src/corelib/doc/src/objectmodel/signalsandslots.qdoc b/src/corelib/doc/src/objectmodel/signalsandslots.qdoc
index 6f183d3e71..216bd985db 100644
--- a/src/corelib/doc/src/objectmodel/signalsandslots.qdoc
+++ b/src/corelib/doc/src/objectmodel/signalsandslots.qdoc
@@ -251,7 +251,8 @@
This example illustrates that objects can work together without needing to
know any information about each other. To enable this, the objects only
need to be connected together, and this can be achieved with some simple
- QObject::connect() function calls, or with \c{uic}'s {automatic connections} feature.
+ QObject::connect() function calls, or with \c{uic}'s
+ \l{Automatic Connections}{automatic connections} feature.
\section1 A Real Example
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp
index 5e340dbd27..46cfe9e2b9 100644
--- a/src/corelib/global/qlogging.cpp
+++ b/src/corelib/global/qlogging.cpp
@@ -1191,7 +1191,7 @@ static void slog2_default_handler(QtMsgType msgType, const char *message)
buffer_config.buffer_set_name = __progname;
buffer_config.num_buffers = 1;
- buffer_config.verbosity_level = SLOG2_INFO;
+ buffer_config.verbosity_level = SLOG2_DEBUG1;
buffer_config.buffer_config[0].buffer_name = "default";
buffer_config.buffer_config[0].num_pages = 8;
diff --git a/src/corelib/global/qsystemdetection.h b/src/corelib/global/qsystemdetection.h
index 22f01fc70b..97f750a3a6 100644
--- a/src/corelib/global/qsystemdetection.h
+++ b/src/corelib/global/qsystemdetection.h
@@ -131,6 +131,9 @@
# if defined(WINCE) || defined(_WIN32_WCE)
# define Q_OS_WINCE
# elif defined(WINAPI_FAMILY)
+# ifndef WINAPI_FAMILY_PC_APP
+# define WINAPI_FAMILY_PC_APP WINAPI_FAMILY_APP
+# endif
# if defined(WINAPI_FAMILY_PHONE_APP) && WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP
# define Q_OS_WINPHONE
# define Q_OS_WINRT
diff --git a/src/corelib/global/qt_windows.h b/src/corelib/global/qt_windows.h
index f7337fe1b5..8ac3c2135d 100644
--- a/src/corelib/global/qt_windows.h
+++ b/src/corelib/global/qt_windows.h
@@ -45,22 +45,14 @@
#pragma qt_sync_stop_processing
#endif
-#if defined(Q_CC_BOR)
-// Borland's windows.h does not set these correctly, resulting in
-// unusable WinSDK standard dialogs
-#ifndef WINVER
-# define WINVER 0x0501
-#endif
-#ifndef _WIN32_WINNT
-# define _WIN32_WINNT 0x0501
-#endif
-#endif
-
#if defined(Q_CC_MINGW)
// mingw's windows.h does not set _WIN32_WINNT, resulting breaking compilation
-#ifndef WINVER
-# define WINVER 0x501
-#endif
+# ifndef WINVER
+# define WINVER 0x501
+# endif
+# ifndef _WIN32_WINNT
+# define _WIN32_WINNT 0x0501
+# endif
#endif
#ifndef NOMINMAX
diff --git a/src/corelib/io/qfilesystemiterator_win.cpp b/src/corelib/io/qfilesystemiterator_win.cpp
index 2caf87a7b4..ba195b2330 100644
--- a/src/corelib/io/qfilesystemiterator_win.cpp
+++ b/src/corelib/io/qfilesystemiterator_win.cpp
@@ -37,13 +37,6 @@
**
****************************************************************************/
-#if !defined(WINAPI_FAMILY)
-# if _WIN32_WINNT < 0x0500
-# undef _WIN32_WINNT
-# define _WIN32_WINNT 0x0500
-# endif // _WIN32_WINNT < 0x500
-#endif // !WINAPI_FAMILY
-
#include "qfilesystemiterator_p.h"
#include "qfilesystemengine_p.h"
#include "qplatformdefs.h"
diff --git a/src/corelib/io/qprocess.h b/src/corelib/io/qprocess.h
index fd835d18b1..4ce0503761 100644
--- a/src/corelib/io/qprocess.h
+++ b/src/corelib/io/qprocess.h
@@ -269,7 +269,7 @@ Q_SIGNALS:
void finished(int exitCode); // ### Qt 6: merge the two signals with a default value
void finished(int exitCode, QProcess::ExitStatus exitStatus);
#if QT_DEPRECATED_SINCE(5,6)
- QT_MOC_COMPAT void error(QProcess::ProcessError error);
+ void error(QProcess::ProcessError error);
#endif
void errorOccurred(QProcess::ProcessError error);
void stateChanged(QProcess::ProcessState state, QPrivateSignal);
diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp
index 611ce34550..ef787832a4 100644
--- a/src/corelib/io/qprocess_win.cpp
+++ b/src/corelib/io/qprocess_win.cpp
@@ -665,7 +665,8 @@ bool QProcessPrivate::waitForReadyRead(int msecs)
return false;
if (WaitForSingleObjectEx(pid->hProcess, 0, false) == WAIT_OBJECT_0) {
bool readyReadEmitted = drainOutputPipes();
- _q_processDied();
+ if (pid)
+ _q_processDied();
return readyReadEmitted;
}
@@ -770,7 +771,8 @@ bool QProcessPrivate::waitForFinished(int msecs)
if (WaitForSingleObject(pid->hProcess, timer.nextSleepTime()) == WAIT_OBJECT_0) {
drainOutputPipes();
- _q_processDied();
+ if (pid)
+ _q_processDied();
return true;
}
diff --git a/src/corelib/io/qsettings_win.cpp b/src/corelib/io/qsettings_win.cpp
index f74f52df89..05ed51e999 100644
--- a/src/corelib/io/qsettings_win.cpp
+++ b/src/corelib/io/qsettings_win.cpp
@@ -510,6 +510,12 @@ bool QWinSettingsPrivate::readKey(HKEY parentHandle, const QString &rSubKey, QVa
return false;
}
+ // workaround for rare cases where trailing '\0' are missing in registry
+ if (dataType == REG_SZ || dataType == REG_EXPAND_SZ)
+ dataSize += 2;
+ else if (dataType == REG_MULTI_SZ)
+ dataSize += 4;
+
// get the value
QByteArray data(dataSize, 0);
res = RegQueryValueEx(handle, reinterpret_cast<const wchar_t *>(rSubkeyName.utf16()), 0, 0,
diff --git a/src/corelib/io/qtextstream.cpp b/src/corelib/io/qtextstream.cpp
index bc4a5fa538..27b7570226 100644
--- a/src/corelib/io/qtextstream.cpp
+++ b/src/corelib/io/qtextstream.cpp
@@ -456,6 +456,10 @@ bool QTextStreamPrivate::fillReadBuffer(qint64 maxBytes)
bytesRead = device->read(buf, sizeof(buf));
}
+ // reset the Text flag.
+ if (textModeEnabled)
+ device->setTextModeEnabled(true);
+
if (bytesRead <= 0)
return false;
@@ -491,10 +495,6 @@ bool QTextStreamPrivate::fillReadBuffer(qint64 maxBytes)
readBuffer += QString::fromLatin1(buf, bytesRead);
#endif
- // reset the Text flag.
- if (textModeEnabled)
- device->setTextModeEnabled(true);
-
// remove all '\r\n' in the string.
if (readBuffer.size() > oldReadBufferSize && textModeEnabled) {
QChar CR = QLatin1Char('\r');
@@ -593,17 +593,18 @@ void QTextStreamPrivate::flushWriteBuffer()
qDebug("QTextStreamPrivate::flushWriteBuffer(), device->write(\"%s\") == %d",
qt_prettyDebug(data.constData(), qMin(data.size(),32), data.size()).constData(), int(bytesWritten));
#endif
- if (bytesWritten <= 0) {
- status = QTextStream::WriteFailed;
- return;
- }
#if defined (Q_OS_WIN)
- // replace the text flag
+ // reset the text flag
if (textModeEnabled)
device->setTextModeEnabled(true);
#endif
+ if (bytesWritten <= 0) {
+ status = QTextStream::WriteFailed;
+ return;
+ }
+
// flush the file
#ifndef QT_NO_QOBJECT
QFileDevice *file = qobject_cast<QFileDevice *>(device);
diff --git a/src/corelib/json/qjson_p.h b/src/corelib/json/qjson_p.h
index 4c628ff1fe..e5010c2da7 100644
--- a/src/corelib/json/qjson_p.h
+++ b/src/corelib/json/qjson_p.h
@@ -151,6 +151,13 @@ public:
return *this;
}
};
+} // namespace QJsonPrivate
+
+template <typename T>
+class QTypeInfo<QJsonPrivate::q_littleendian<T> >
+ : public QTypeInfoMerger<QJsonPrivate::q_littleendian<T>, T> {};
+
+namespace QJsonPrivate {
typedef q_littleendian<short> qle_short;
typedef q_littleendian<unsigned short> qle_ushort;
@@ -402,7 +409,7 @@ public:
// pack with itself, we'll discard the high part anyway
chunk = _mm_packus_epi16(chunk, chunk);
// unaligned 64-bit store
- *(quint64*)&l[i] = _mm_cvtsi128_si64(chunk);
+ qUnalignedStore(l + i, _mm_cvtsi128_si64(chunk));
i += 8;
}
# endif
diff --git a/src/corelib/json/qjsonparser.cpp b/src/corelib/json/qjsonparser.cpp
index 04bdb57d6b..2926adf10a 100644
--- a/src/corelib/json/qjsonparser.cpp
+++ b/src/corelib/json/qjsonparser.cpp
@@ -738,7 +738,7 @@ bool Parser::parseNumber(QJsonPrivate::Value *val, int baseOffset)
}
int pos = reserveSpace(sizeof(double));
- *(quint64 *)(data + pos) = qToLittleEndian(ui);
+ qToLittleEndian(ui, reinterpret_cast<uchar *>(data + pos));
if (current - baseOffset >= Value::MaxSize) {
lastError = QJsonParseError::DocumentTooLarge;
return false;
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 79a3254a39..6ccc7b729b 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -674,7 +674,7 @@ QCoreApplication::QCoreApplication(QCoreApplicationPrivate &p)
: QObject(p, 0)
#endif
{
- init();
+ d_func()->q_ptr = this;
// note: it is the subclasses' job to call
// QCoreApplicationPrivate::eventDispatcher->startingUp();
}
@@ -723,27 +723,26 @@ QCoreApplication::QCoreApplication(int &argc, char **argv
: QObject(*new QCoreApplicationPrivate(argc, argv, _internal))
#endif
{
- init();
+ d_func()->q_ptr = this;
+ d_func()->init();
#ifndef QT_NO_QOBJECT
QCoreApplicationPrivate::eventDispatcher->startingUp();
#endif
}
-// ### move to QCoreApplicationPrivate constructor?
-void QCoreApplication::init()
+void QCoreApplicationPrivate::init()
{
- d_ptr->q_ptr = this;
- Q_D(QCoreApplication);
+ Q_Q(QCoreApplication);
- QCoreApplicationPrivate::initLocale();
+ initLocale();
- Q_ASSERT_X(!self, "QCoreApplication", "there should be only one application object");
- QCoreApplication::self = this;
+ Q_ASSERT_X(!QCoreApplication::self, "QCoreApplication", "there should be only one application object");
+ QCoreApplication::self = q;
// Store app name (so it's still available after QCoreApplication is destroyed)
if (!coreappdata()->applicationNameSet)
- coreappdata()->application = d_func()->appName();
+ coreappdata()->application = appName();
QLoggingRegistry::instance()->init();
@@ -759,7 +758,7 @@ void QCoreApplication::init()
// anywhere in the list, we can just linearly scan the lists and find the items that
// have been removed. Once the original list is exhausted we know all the remaining
// items have been added.
- QStringList newPaths(libraryPaths());
+ QStringList newPaths(q->libraryPaths());
for (int i = manualPaths->length(), j = appPaths->length(); i > 0 || j > 0; qt_noop()) {
if (--j < 0) {
newPaths.prepend((*manualPaths)[--i]);
@@ -779,28 +778,28 @@ void QCoreApplication::init()
#ifndef QT_NO_QOBJECT
// use the event dispatcher created by the app programmer (if any)
- if (!QCoreApplicationPrivate::eventDispatcher)
- QCoreApplicationPrivate::eventDispatcher = d->threadData->eventDispatcher.load();
+ if (!eventDispatcher)
+ eventDispatcher = threadData->eventDispatcher.load();
// otherwise we create one
- if (!QCoreApplicationPrivate::eventDispatcher)
- d->createEventDispatcher();
- Q_ASSERT(QCoreApplicationPrivate::eventDispatcher != 0);
+ if (!eventDispatcher)
+ createEventDispatcher();
+ Q_ASSERT(eventDispatcher);
- if (!QCoreApplicationPrivate::eventDispatcher->parent()) {
- QCoreApplicationPrivate::eventDispatcher->moveToThread(d->threadData->thread);
- QCoreApplicationPrivate::eventDispatcher->setParent(this);
+ if (!eventDispatcher->parent()) {
+ eventDispatcher->moveToThread(threadData->thread);
+ eventDispatcher->setParent(q);
}
- d->threadData->eventDispatcher = QCoreApplicationPrivate::eventDispatcher;
- d->eventDispatcherReady();
+ threadData->eventDispatcher = eventDispatcher;
+ eventDispatcherReady();
#endif
#ifdef QT_EVAL
extern void qt_core_eval_init(QCoreApplicationPrivate::Type);
- qt_core_eval_init(d->application_type);
+ qt_core_eval_init(application_type);
#endif
- d->processCommandLineArguments();
+ processCommandLineArguments();
qt_call_pre_routines();
qt_startup_hook();
@@ -810,7 +809,7 @@ void QCoreApplication::init()
#endif
#ifndef QT_NO_QOBJECT
- QCoreApplicationPrivate::is_app_running = true; // No longer starting up.
+ is_app_running = true; // No longer starting up.
#endif
}
diff --git a/src/corelib/kernel/qcoreapplication.h b/src/corelib/kernel/qcoreapplication.h
index 3131265fd5..a22e1c4f9e 100644
--- a/src/corelib/kernel/qcoreapplication.h
+++ b/src/corelib/kernel/qcoreapplication.h
@@ -206,8 +206,6 @@ private:
static bool notifyInternal2(QObject *receiver, QEvent *);
#endif
- void init();
-
static QCoreApplication *self;
Q_DISABLE_COPY(QCoreApplication)
diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h
index 482429f073..445bae01b4 100644
--- a/src/corelib/kernel/qcoreapplication_p.h
+++ b/src/corelib/kernel/qcoreapplication_p.h
@@ -80,6 +80,8 @@ public:
QCoreApplicationPrivate(int &aargc, char **aargv, uint flags);
~QCoreApplicationPrivate();
+ void init();
+
QString appName() const;
#ifdef Q_OS_MAC
diff --git a/src/corelib/kernel/qcoreevent.h b/src/corelib/kernel/qcoreevent.h
index 95068e6a67..7e962f816e 100644
--- a/src/corelib/kernel/qcoreevent.h
+++ b/src/corelib/kernel/qcoreevent.h
@@ -325,6 +325,11 @@ private:
friend class QGraphicsView;
friend class QGraphicsScene;
friend class QGraphicsScenePrivate;
+ // from QtTest:
+ friend class QSpontaneKeyEvent;
+ // needs this:
+ Q_ALWAYS_INLINE
+ void setSpontaneous() { spont = true; }
};
class Q_CORE_EXPORT QTimerEvent : public QEvent
diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h
index 2a6e24533a..951668fe55 100644
--- a/src/corelib/kernel/qobjectdefs.h
+++ b/src/corelib/kernel/qobjectdefs.h
@@ -159,6 +159,12 @@ inline void qYouForgotTheQ_OBJECT_Macro(T1, T2) {}
# define Q_OBJECT_NO_OVERRIDE_WARNING
#endif
+#if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && Q_CC_GNU >= 600
+# define Q_OBJECT_NO_ATTRIBUTES_WARNING QT_WARNING_DISABLE_GCC("-Wattributes")
+#else
+# define Q_OBJECT_NO_ATTRIBUTES_WARNING
+#endif
+
/* qmake ignore Q_OBJECT */
#define Q_OBJECT \
public: \
@@ -169,10 +175,11 @@ public: \
virtual const QMetaObject *metaObject() const; \
virtual void *qt_metacast(const char *); \
virtual int qt_metacall(QMetaObject::Call, int, void **); \
- QT_WARNING_POP \
QT_TR_FUNCTIONS \
private: \
+ Q_OBJECT_NO_ATTRIBUTES_WARNING \
Q_DECL_HIDDEN_STATIC_METACALL static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); \
+ QT_WARNING_POP \
struct QPrivateSignal {};
/* qmake ignore Q_OBJECT */
@@ -186,7 +193,11 @@ public: \
void qt_check_for_QGADGET_macro(); \
typedef void QtGadgetHelper; \
private: \
- Q_DECL_HIDDEN_STATIC_METACALL static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **);
+ QT_WARNING_PUSH \
+ Q_OBJECT_NO_ATTRIBUTES_WARNING \
+ Q_DECL_HIDDEN_STATIC_METACALL static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); \
+ QT_WARNING_POP \
+ /*end*/
#endif // QT_NO_META_MACROS
#else // Q_MOC_RUN
diff --git a/src/corelib/mimetypes/qmimemagicrule.cpp b/src/corelib/mimetypes/qmimemagicrule.cpp
index a4ba93192c..0db3407b7b 100644
--- a/src/corelib/mimetypes/qmimemagicrule.cpp
+++ b/src/corelib/mimetypes/qmimemagicrule.cpp
@@ -48,6 +48,7 @@
#include <QtCore/QList>
#include <QtCore/QDebug>
#include <qendian.h>
+#include <private/qsimd_p.h> // for qUnalignedLoad
QT_BEGIN_NAMESPACE
@@ -163,7 +164,7 @@ bool QMimeMagicRule::matchNumber(const QByteArray &data) const
const char *p = data.constData() + m_startPos;
const char *e = data.constData() + qMin(data.size() - int(sizeof(T)), m_endPos + 1);
for ( ; p <= e; ++p) {
- if ((*reinterpret_cast<const T*>(p) & mask) == (value & mask))
+ if ((qUnalignedLoad<T>(p) & mask) == (value & mask))
return true;
}
diff --git a/src/corelib/mimetypes/qmimeprovider.cpp b/src/corelib/mimetypes/qmimeprovider.cpp
index 52b5327f54..c961c25c07 100644
--- a/src/corelib/mimetypes/qmimeprovider.cpp
+++ b/src/corelib/mimetypes/qmimeprovider.cpp
@@ -597,9 +597,8 @@ void QMimeBinaryProvider::loadMimeTypePrivate(QMimeTypePrivate &data)
const QStringRef name = xml.attributes().value(QLatin1String("type"));
if (name.isEmpty())
continue;
- if (name != data.name) {
+ if (name.compare(data.name, Qt::CaseInsensitive))
qWarning() << "Got name" << name << "in file" << file << "expected" << data.name;
- }
while (xml.readNextStartElement()) {
const QStringRef tag = xml.name();
diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp
index 635282d5c4..ef1799a021 100644
--- a/src/corelib/thread/qthread_win.cpp
+++ b/src/corelib/thread/qthread_win.cpp
@@ -37,12 +37,6 @@
**
****************************************************************************/
-//#define WINVER 0x0500
-#if !defined(WINAPI_FAMILY) && (_WIN32_WINNT < 0x0400)
-#define _WIN32_WINNT 0x0400
-#endif
-
-
#include "qthread.h"
#include "qthread_p.h"
#include "qthreadstorage.h"
diff --git a/src/corelib/thread/thread.pri b/src/corelib/thread/thread.pri
index 2cb00a6cf4..0a989cfcaf 100644
--- a/src/corelib/thread/thread.pri
+++ b/src/corelib/thread/thread.pri
@@ -43,24 +43,20 @@ SOURCES += thread/qatomic.cpp \
thread/qthreadpool.cpp \
thread/qthreadstorage.cpp
-unix:SOURCES += thread/qthread_unix.cpp \
- thread/qwaitcondition_unix.cpp
-
-win32:SOURCES += thread/qthread_win.cpp \
- thread/qwaitcondition_win.cpp
-
-integrity:SOURCES += thread/qthread_unix.cpp \
- thread/qwaitcondition_unix.cpp
-
-false {
- # files #included by others, but listed here so IDEs parsing this file know
- # they are part of QtCore. Usually, qmake can find out that certain files
- # are #included by others and thus remove from SOURCES, but it gets lost
- # with qmutex.cpp.
+win32 {
SOURCES += \
- thread/qmutex_linux.cpp \
- thread/qmutex_mac.cpp \
- thread/qmutex_unix.cpp \
- thread/qmutex_win.cpp
+ thread/qmutex_win.cpp \
+ thread/qthread_win.cpp \
+ thread/qwaitcondition_win.cpp
+} else {
+ darwin {
+ SOURCES += thread/qmutex_mac.cpp
+ } else: linux {
+ SOURCES += thread/qmutex_linux.cpp
+ } else {
+ SOURCES += thread/qmutex_unix.cpp
+ }
+ SOURCES += \
+ thread/qthread_unix.cpp \
+ thread/qwaitcondition_unix.cpp
}
-
diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp
index 1001f2a06c..8ab98bd509 100644
--- a/src/corelib/tools/qhash.cpp
+++ b/src/corelib/tools/qhash.cpp
@@ -113,24 +113,24 @@ static uint crc32(const Char *ptr, size_t len, uint h)
p += 8;
for ( ; p <= e; p += 8)
- h2 = _mm_crc32_u64(h2, *reinterpret_cast<const qlonglong *>(p - 8));
+ h2 = _mm_crc32_u64(h2, qUnalignedLoad<qlonglong>(p - 8));
h = h2;
p -= 8;
len = e - p;
if (len & 4) {
- h = _mm_crc32_u32(h, *reinterpret_cast<const uint *>(p));
+ h = _mm_crc32_u32(h, qUnalignedLoad<uint>(p));
p += 4;
}
# else
p += 4;
for ( ; p <= e; p += 4)
- h = _mm_crc32_u32(h, *reinterpret_cast<const uint *>(p - 4));
+ h = _mm_crc32_u32(h, qUnalignedLoad<uint>(p - 4));
p -= 4;
len = e - p;
# endif
if (len & 2) {
- h = _mm_crc32_u16(h, *reinterpret_cast<const ushort *>(p));
+ h = _mm_crc32_u16(h, qUnalignedLoad<ushort>(p));
p += 2;
}
if (sizeof(Char) == 1 && len & 1)
diff --git a/src/corelib/tools/qsimd.cpp b/src/corelib/tools/qsimd.cpp
index 5bce42fd5a..9037442d9d 100644
--- a/src/corelib/tools/qsimd.cpp
+++ b/src/corelib/tools/qsimd.cpp
@@ -747,4 +747,26 @@ void qDumpCPUFeatures()
puts("");
}
+/*!
+ \internal
+ \fn T qUnalignedLoad(const void *ptr)
+ \since 5.6.1
+
+ Loads a \c{T} from address \a ptr, which may be misaligned.
+
+ Use of this function avoid the undefined behavior that the C++ standard
+ otherwise attributes to unaligned loads.
+*/
+
+/*!
+ \internal
+ \fn void qUnalignedStore(void *ptr, T t)
+ \since 5.6.1
+
+ Stores \a t to address \a ptr, which may be misaligned.
+
+ Use of this function avoid the undefined behavior that the C++ standard
+ otherwise attributes to unaligned stores.
+*/
+
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h
index 02439a2a9c..1a795a670d 100644
--- a/src/corelib/tools/qsimd_p.h
+++ b/src/corelib/tools/qsimd_p.h
@@ -521,6 +521,32 @@ unsigned _bit_scan_forward(unsigned val)
#define ALIGNMENT_PROLOGUE_16BYTES(ptr, i, length) \
for (; i < static_cast<int>(qMin(static_cast<quintptr>(length), ((4 - ((reinterpret_cast<quintptr>(ptr) >> 2) & 0x3)) & 0x3))); ++i)
+template <typename T>
+Q_ALWAYS_INLINE
+T qUnalignedLoad(const void *ptr) Q_DECL_NOTHROW
+{
+ T result;
+#if QT_HAS_BUILTIN(__builtin_memcpy)
+ __builtin_memcpy
+#else
+ memcpy
+#endif
+ /*memcpy*/(&result, ptr, sizeof result);
+ return result;
+}
+
+template <typename T>
+Q_ALWAYS_INLINE
+void qUnalignedStore(void *ptr, T t) Q_DECL_NOTHROW
+{
+#if QT_HAS_BUILTIN(__builtin_memcpy)
+ __builtin_memcpy
+#else
+ memcpy
+#endif
+ /*memcpy*/(ptr, &t, sizeof t);
+}
+
QT_END_NAMESPACE
#endif // QSIMD_P_H
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 943d8efe1d..c7cd1a7751 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -584,7 +584,7 @@ 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(*(const long long *)(c + offset));
+ __m128i chunk = _mm_cvtsi64_si128(qUnalignedLoad<long long>(c + offset));
__m128i secondHalf = _mm_unpacklo_epi8(chunk, nullmask);
__m128i ucdata = _mm_loadu_si128((const __m128i*)(uc + offset));
@@ -6177,11 +6177,7 @@ QString QString::vasprintf(const char *cformat, va_list ap)
}
case 'p': {
void *arg = va_arg(ap, void*);
-#ifdef Q_OS_WIN64
- quint64 i = reinterpret_cast<quint64>(arg);
-#else
- quint64 i = reinterpret_cast<unsigned long>(arg);
-#endif
+ const quint64 i = reinterpret_cast<quintptr>(arg);
flags |= QLocaleData::Alternate;
subst = QLocaleData::c()->unsLongLongToString(i, precision, 16, width, flags);
++c;