From 7393bb0af4c98cabef3138e4db60692e70d4c444 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 19 Dec 2014 00:18:07 +0100 Subject: MSVC: Restore 'public' accessibility of QMetaType member functions They were made 'private' as a side effect of a change enabling support of template friends for MSVC. However, accessibility is part of the MSVC's name mangling and thus BC was broken. [ChangeLog][Important Behavior Changes] Restored binary compatibility with Qt 5.3.2 on Windows when using MSVC 2012 or MSVC 2013. This means that Qt 5.4.1 is no longer binary compatible with Qt 5.4.0 when using either of those compilers. Change-Id: I18679aa15821a7365606dc80fdc8411641573820 Reviewed-by: Lars Knoll --- src/corelib/kernel/qmetatype.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index af38589903..7a45e21253 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -640,7 +640,7 @@ private: static bool registerDebugStreamOperatorFunction(const QtPrivate::AbstractDebugStreamFunction *f, int type); #endif -#ifndef Q_NO_TEMPLATE_FRIENDS +#if !defined(Q_NO_TEMPLATE_FRIENDS) && !defined(Q_CC_MSVC) #ifndef Q_QDOC template friend bool qRegisterSequentialConverter(); -- cgit v1.2.3 From 80d0075588aa94e011a394967fb21d8bb0c84781 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 16 Dec 2014 16:22:10 -0800 Subject: Fix QThread::idealThreadCount on Unix if sysconf or sysctl fails The BSD4 code (including OS X) calls sysctl and if that fails, it sets cores to -1. Similarly, the generic Unix code calls sysconf() and assigns the returned value to cores, but sysconf can return -1 on failure. Change-Id: I9e521d366e9c42f36c2ba20a37e7a74539ddb8f4 Reviewed-by: Oswald Buddenhagen --- src/corelib/thread/qthread_unix.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp index 5df50311ef..9a14503584 100644 --- a/src/corelib/thread/qthread_unix.cpp +++ b/src/corelib/thread/qthread_unix.cpp @@ -450,7 +450,8 @@ int QThread::idealThreadCount() Q_DECL_NOTHROW // the rest: Linux, Solaris, AIX, Tru64 cores = (int)sysconf(_SC_NPROCESSORS_ONLN); #endif - + if (cores == -1) + return 1; return cores; } -- cgit v1.2.3 From c70658d301e274c3aaa1fb6cebe2a5e56db12779 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 16 Dec 2014 14:24:55 -0800 Subject: Make sure we don't try to ask QByteArray to allocate too much QFile::readAll could be asked to read a file that is over 1 GB in size and thus cause an assertion: ASSERT failure in qAllocMore: "Requested size is too large!", ... The idea behind the existing code was correct, but the value was wrong. It prevented overflow of the integer size request, but didn't prevent overflowing the storage size. Change-Id: I072e6e419f47b639454f3fd96deb0f88d03e960c Reviewed-by: Martin Smith --- src/corelib/io/qiodevice.cpp | 2 +- src/corelib/tools/qbytearray.cpp | 11 ++++++++++- src/corelib/tools/qbytearray.h | 3 +++ 3 files changed, 14 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index 0709a93bad..72ec6ff403 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -1025,7 +1025,7 @@ QByteArray QIODevice::readAll() } else { // Read it all in one go. // If resize fails, don't read anything. - if (readBytes + theSize - d->pos > INT_MAX) + if (quint64(readBytes + theSize - d->pos) > QByteArray::MaxSize) return QByteArray(); result.resize(int(readBytes + theSize - d->pos)); readBytes += read(result.data() + readBytes, result.size() - readBytes); diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp index 6ac442d27b..d8b2efbef3 100644 --- a/src/corelib/tools/qbytearray.cpp +++ b/src/corelib/tools/qbytearray.cpp @@ -63,7 +63,7 @@ int qFindByteArray( int qAllocMore(int alloc, int extra) Q_DECL_NOTHROW { Q_ASSERT(alloc >= 0 && extra >= 0); - Q_ASSERT_X(alloc < (1 << 30) - extra, "qAllocMore", "Requested size is too large!"); + Q_ASSERT_X(uint(alloc) < QByteArray::MaxSize, "qAllocMore", "Requested size is too large!"); unsigned nalloc = qNextPowerOfTwo(alloc + extra); @@ -776,6 +776,15 @@ static inline char qToLower(char c) \sa QString, QBitArray */ +/*! + \variable QByteArray::MaxSize + \internal + \since 5.4 + + The maximum size of a QByteArray, in bytes. Also applies to a the maximum + storage size of QString and QVector, though not the number of elements. +*/ + /*! \enum QByteArray::Base64Option \since 5.2 diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h index f13b1c16cd..3bcc7b1f2a 100644 --- a/src/corelib/tools/qbytearray.h +++ b/src/corelib/tools/qbytearray.h @@ -173,6 +173,9 @@ private: typedef QTypedArrayData Data; public: + // undocumented: + static const quint64 MaxSize = (1 << 30) - sizeof(Data); + enum Base64Option { Base64Encoding = 0, Base64UrlEncoding = 1, -- cgit v1.2.3 From a31b75b766b87d0210ed174f587aee33ad639f9b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 3 Dec 2014 14:11:47 -0800 Subject: Use the GCC and Clang __builtin_bswap intrinsics in qbswap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Glibc will use the intrinsics for 32- and 64-bit, but didn't for 16-bit (probably because GCC didn't document it until version 4.8), so this commit will make us access the intrinsics directly the intrisincs for all type sizes. Additionally, this will get us access to the compiler intrisics even without Glibc, such as when building against uclibc or Bionic. Another benefit is that both Clang and ICC will use the MOVBE instruction on Atom and Haswell architectures. Change-Id: I39d1891f479887d719d69ebe4ac92ac9bfeda8af Reviewed-by: Jędrzej Nowacki --- src/corelib/global/qendian.h | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qendian.h b/src/corelib/global/qendian.h index 136581167c..7c643f7592 100644 --- a/src/corelib/global/qendian.h +++ b/src/corelib/global/qendian.h @@ -40,10 +40,6 @@ #include #include -#ifdef __GLIBC__ -#include -#endif - QT_BEGIN_NAMESPACE @@ -276,18 +272,16 @@ template <> inline qint8 qFromBigEndian(const uchar *src) */ template T qbswap(T source); -#ifdef __GLIBC__ +// GCC 4.3 implemented all the intrinsics, but the 16-bit one only got implemented in 4.8; +// Clang 2.6 implemented the 32- and 64-bit but waited until 3.2 to implement the 16-bit one +#if (defined(Q_CC_GNU) && Q_CC_GNU >= 403) || (defined(Q_CC_CLANG) && Q_CC_CLANG >= 206) template <> inline quint64 qbswap(quint64 source) { - return bswap_64(source); + return __builtin_bswap64(source); } template <> inline quint32 qbswap(quint32 source) { - return bswap_32(source); -} -template <> inline quint16 qbswap(quint16 source) -{ - return bswap_16(source); + return __builtin_bswap32(source); } #else template <> inline quint64 qbswap(quint64 source) @@ -311,14 +305,20 @@ template <> inline quint32 qbswap(quint32 source) | ((source & 0x00ff0000) >> 8) | ((source & 0xff000000) >> 24); } - +#endif // GCC & Clang intrinsics +#if (defined(Q_CC_GNU) && Q_CC_GNU >= 408) || (defined(Q_CC_CLANG) && Q_CC_CLANG >= 302) +template <> inline quint16 qbswap(quint16 source) +{ + return __builtin_bswap16(source); +} +#else template <> inline quint16 qbswap(quint16 source) { return quint16( 0 | ((source & 0x00ff) << 8) | ((source & 0xff00) >> 8) ); } -#endif // __GLIBC__ +#endif // GCC & Clang intrinsics // signed specializations template <> inline qint64 qbswap(qint64 source) -- cgit v1.2.3 From d1d3c36e876464a9bae42565f086ded268ab5118 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 17 Dec 2014 20:24:04 -0800 Subject: Simplify use of __has_include in qlogging.cpp Easier to just #define it to 0 Change-Id: Ife99fdca6564077762fa67c6d7a5becaf48655d8 Reviewed-by: Olivier Goffart --- src/corelib/global/qlogging.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 0271573445..50d35a6d84 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -72,20 +72,17 @@ # include "private/qcore_unix_p.h" #endif -#if !defined QT_NO_REGULAREXPRESSION && !defined(QT_BOOTSTRAPPED) -#ifdef __has_include -#if __has_include() && __has_include() -#define QLOGGING_HAVE_BACKTRACE -#endif -#elif defined(__GLIBCXX__) && defined(__GLIBC__) // (because older version of gcc don't have __has_include) -#define QLOGGING_HAVE_BACKTRACE +#ifndef __has_include +# define __has_include(x) 0 #endif -#ifdef QLOGGING_HAVE_BACKTRACE -#include -#include -#include -#endif +#if !defined QT_NO_REGULAREXPRESSION && !defined(QT_BOOTSTRAPPED) +# if (defined(__GLIBC__) && defined(__GLIBCXX__)) || (__has_include() && __has_include()) +# define QLOGGING_HAVE_BACKTRACE +# include +# include +# include +# endif #endif #include -- cgit v1.2.3 From c63bb90ac7224927b56197d80252c79d01ff3b6f Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Mon, 22 Dec 2014 16:34:54 +0100 Subject: Fix typo in Qt5CoreMacros.cmake According to the documentation, the argument is called COPYONLY instead of COPY_ONLY. Fixes warning and ensures it works properly. Change-Id: I643f5ea808aaaf94c3ee666ec39485e84ed38df1 Reviewed-by: Vishesh Handa Reviewed-by: Milian Wolff --- src/corelib/Qt5CoreMacros.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/Qt5CoreMacros.cmake b/src/corelib/Qt5CoreMacros.cmake index 88710bc55e..9c81754302 100644 --- a/src/corelib/Qt5CoreMacros.cmake +++ b/src/corelib/Qt5CoreMacros.cmake @@ -221,7 +221,7 @@ function(QT5_ADD_RESOURCES outfiles ) # let's make a configured file and add it as a dependency so cmake is run # again when dependencies need to be recomputed. qt5_make_output_file("${infile}" "" "qrc.depends" out_depends) - configure_file("${infile}" "${out_depends}" COPY_ONLY) + configure_file("${infile}" "${out_depends}" COPYONLY) else() # The .qrc file does not exist (yet). Let's add a dependency and hope # that it will be generated later -- cgit v1.2.3 From 13972476ad2c3178fe89f2d96f398de10394c6f6 Mon Sep 17 00:00:00 2001 From: Dmitry Shachnev Date: Mon, 22 Dec 2014 13:44:45 +0300 Subject: qstorageinfo_unix.cpp: Fix build on BSD and other unices MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Include statvfs.h on all non-Linux and non-Solaris systems. * Fix type of stat_buf structure on BSD. Change-Id: I6336503082fafd7f6108cf95c079bdd329d2ea0f Reviewed-by: Gabriel de Dietrich Reviewed-by: Lisandro Damián Nicanor Pérez Meyer Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Shawn Rutledge --- src/corelib/io/qstorageinfo_unix.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp index e82737c51c..857464f578 100644 --- a/src/corelib/io/qstorageinfo_unix.cpp +++ b/src/corelib/io/qstorageinfo_unix.cpp @@ -52,17 +52,18 @@ #if defined(Q_OS_BSD4) # include +# include #elif defined(Q_OS_ANDROID) # include # include # include -#elif defined(Q_OS_QNX) -# include #elif defined(Q_OS_LINUX) # include # include #elif defined(Q_OS_SOLARIS) # include +#else +# include #endif #if defined(Q_OS_BSD4) @@ -118,7 +119,7 @@ public: inline QByteArray device() const; private: #if defined(Q_OS_BSD4) - statfs *stat_buf; + struct statfs *stat_buf; int entryCount; int currentIndex; #elif defined(Q_OS_SOLARIS) -- cgit v1.2.3 From dec81ad2dac347ae380f405eb2a58d0a4d0abad4 Mon Sep 17 00:00:00 2001 From: Roger Maclean Date: Tue, 9 Dec 2014 11:44:50 -0500 Subject: QNX: Revert the change to give higher precision timers. The previous change (SHA 82c2118c) to provide better than 1ms accuracy for timers on QNX is not safe. According to the docs, ClockCycles is not guaranteed to return consistent information if called from different CPUs. While this can be addressed by locking the thread to a single CPU, you wouldn't want to do that here. On some systems (e.g. BB10) the behavior is extremely bad since ClockCycles only has 32 bits of precision. This results in overflows in the calculations making short timers run very slowly (16ms timers were around 1s). Also ClockCycles wraps in under three minutes causing even more problems. I've talked to the kernel developers and there is currently nothing that will give you better than 1ms accuracy. An individual program could use ClockCycles to calculate more accurate times if they want. It's not clear to me what benefit one would get with increased accuracy. Unless I've missed something, these times are only used to calculate timeouts for calls such as select. These timeouts will themselves have the same resolution as clock_gettime provides so the increased accuracy would appear to be for naught. Change-Id: Ia38b154ca41949becbd0b8558a9ff4ddd5e01a43 Reviewed-by: Thiago Macieira Reviewed-by: Bernd Weimer Reviewed-by: Oswald Buddenhagen Reviewed-by: Rafael Roquetto --- src/corelib/tools/qelapsedtimer_unix.cpp | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qelapsedtimer_unix.cpp b/src/corelib/tools/qelapsedtimer_unix.cpp index 9dd5df0266..d29447fa03 100644 --- a/src/corelib/tools/qelapsedtimer_unix.cpp +++ b/src/corelib/tools/qelapsedtimer_unix.cpp @@ -37,10 +37,6 @@ #include "qelapsedtimer.h" #if defined(Q_OS_VXWORKS) #include "qfunctions_vxworks.h" -#elif defined(Q_OS_QNX) -#include -#include -#include #else #include #include @@ -88,18 +84,7 @@ QT_BEGIN_NAMESPACE * see http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_getres.html */ -#if defined(Q_OS_QNX) -static inline void qt_clock_gettime(clockid_t clock, struct timespec *ts) -{ - // The standard POSIX clock calls only have 1ms accuracy on QNX. To get - // higher accuracy, this platform-specific function must be used instead - quint64 cycles_per_sec = SYSPAGE_ENTRY(qtime)->cycles_per_sec; - quint64 cycles = ClockCycles(); - ts->tv_sec = cycles / cycles_per_sec; - quint64 mod = cycles % cycles_per_sec; - ts->tv_nsec = mod * Q_INT64_C(1000000000) / cycles_per_sec; -} -#elif !defined(CLOCK_REALTIME) +#if !defined(CLOCK_REALTIME) # define CLOCK_REALTIME 0 static inline void qt_clock_gettime(int, struct timespec *ts) { -- cgit v1.2.3