summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2020-06-11 11:35:19 +0200
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2020-06-19 19:38:23 +0200
commit3e1d03b1eaf6a5e842bed4ae4f9bb8cca05e5b31 (patch)
tree74dd3478dce3bc96121238300fc0bbc6ef97fc3e /src/corelib/thread
parent5b686e208ffc68f9f660d36c468280d50a40e3ad (diff)
Port Q_STATIC_ASSERT(_X) to static_assert
There is no reason for keep using our macro now that we have C++17. The macro itself is left in for the moment being, as well as its detection logic, because it's needed for C code (not everything supports C11 yet). A few more cleanups will arrive in the next few patches. Note that this is a mere search/replace; some places were using double braces to work around the presence of commas in a macro, no attempt has been done to fix those. tst_qglobal had just some minor changes to keep testing the macro. Change-Id: I1c1c397d9f3e63db3338842bf350c9069ea57639 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/thread')
-rw-r--r--src/corelib/thread/qatomic.cpp26
-rw-r--r--src/corelib/thread/qatomic_msvc.h4
-rw-r--r--src/corelib/thread/qbasicatomic.h4
-rw-r--r--src/corelib/thread/qthread.h2
-rw-r--r--src/corelib/thread/qthread_unix.cpp2
-rw-r--r--src/corelib/thread/qwaitcondition_unix.cpp2
6 files changed, 20 insertions, 20 deletions
diff --git a/src/corelib/thread/qatomic.cpp b/src/corelib/thread/qatomic.cpp
index 5c3ad9412f..d302da72eb 100644
--- a/src/corelib/thread/qatomic.cpp
+++ b/src/corelib/thread/qatomic.cpp
@@ -1750,33 +1750,33 @@
QT_BEGIN_NAMESPACE
// The following specializations must always be defined
-Q_STATIC_ASSERT(sizeof(QAtomicInteger<unsigned>));
-Q_STATIC_ASSERT(sizeof(QAtomicInteger<long>));
-Q_STATIC_ASSERT(sizeof(QAtomicInteger<unsigned long>));
-Q_STATIC_ASSERT(sizeof(QAtomicInteger<quintptr>));
-Q_STATIC_ASSERT(sizeof(QAtomicInteger<qptrdiff>));
+static_assert(sizeof(QAtomicInteger<unsigned>));
+static_assert(sizeof(QAtomicInteger<long>));
+static_assert(sizeof(QAtomicInteger<unsigned long>));
+static_assert(sizeof(QAtomicInteger<quintptr>));
+static_assert(sizeof(QAtomicInteger<qptrdiff>));
#ifdef Q_COMPILER_UNICODE_STRINGS
-Q_STATIC_ASSERT(sizeof(QAtomicInteger<char32_t>));
+static_assert(sizeof(QAtomicInteger<char32_t>));
#endif
#ifdef Q_ATOMIC_INT16_IS_SUPPORTED
-Q_STATIC_ASSERT(sizeof(QAtomicInteger<short>));
-Q_STATIC_ASSERT(sizeof(QAtomicInteger<unsigned short>));
+static_assert(sizeof(QAtomicInteger<short>));
+static_assert(sizeof(QAtomicInteger<unsigned short>));
# if WCHAR_MAX < 0x10000
-Q_STATIC_ASSERT(sizeof(QAtomicInteger<wchar_t>));
+static_assert(sizeof(QAtomicInteger<wchar_t>));
# endif
# ifdef Q_COMPILER_UNICODE_STRINGS
-Q_STATIC_ASSERT(sizeof(QAtomicInteger<char16_t>));
+static_assert(sizeof(QAtomicInteger<char16_t>));
# endif
#endif
#ifdef Q_ATOMIC_INT64_IS_SUPPORTED
-Q_STATIC_ASSERT(sizeof(QAtomicInteger<qint64>));
-Q_STATIC_ASSERT(sizeof(QAtomicInteger<quint64>));
+static_assert(sizeof(QAtomicInteger<qint64>));
+static_assert(sizeof(QAtomicInteger<quint64>));
#endif
#if WCHAR_MAX == INT_MAX
-Q_STATIC_ASSERT(sizeof(QAtomicInteger<wchar_t>));
+static_assert(sizeof(QAtomicInteger<wchar_t>));
#endif
QT_END_NAMESPACE
diff --git a/src/corelib/thread/qatomic_msvc.h b/src/corelib/thread/qatomic_msvc.h
index 67b5224cd7..54b12f5bb2 100644
--- a/src/corelib/thread/qatomic_msvc.h
+++ b/src/corelib/thread/qatomic_msvc.h
@@ -291,9 +291,9 @@ template <int N> struct QAtomicOpsBySize : QGenericAtomicOps<QAtomicOpsBySize<N>
private:
typedef typename QAtomicWindowsType<N>::Type Type;
template <typename T> static inline Type *atomic(T *t)
- { Q_STATIC_ASSERT(sizeof(T) == sizeof(Type)); return reinterpret_cast<Type *>(t); }
+ { static_assert(sizeof(T) == sizeof(Type)); return reinterpret_cast<Type *>(t); }
template <typename T> static inline Type value(T t)
- { Q_STATIC_ASSERT(sizeof(T) == sizeof(Type)); return Type(t); }
+ { static_assert(sizeof(T) == sizeof(Type)); return Type(t); }
};
template <typename T>
diff --git a/src/corelib/thread/qbasicatomic.h b/src/corelib/thread/qbasicatomic.h
index c9c95cf6ce..18da268270 100644
--- a/src/corelib/thread/qbasicatomic.h
+++ b/src/corelib/thread/qbasicatomic.h
@@ -93,8 +93,8 @@ public:
typedef T Type;
typedef QAtomicOps<T> Ops;
// static check that this is a valid integer
- Q_STATIC_ASSERT_X(QTypeInfo<T>::isIntegral, "template parameter is not an integral type");
- Q_STATIC_ASSERT_X(QAtomicOpsSupport<sizeof(T)>::IsSupported, "template parameter is an integral of a size not supported on this platform");
+ static_assert(QTypeInfo<T>::isIntegral, "template parameter is not an integral type");
+ static_assert(QAtomicOpsSupport<sizeof(T)>::IsSupported, "template parameter is an integral of a size not supported on this platform");
typename Ops::Type _q_value;
diff --git a/src/corelib/thread/qthread.h b/src/corelib/thread/qthread.h
index 635dd94522..5a1e63ee0a 100644
--- a/src/corelib/thread/qthread.h
+++ b/src/corelib/thread/qthread.h
@@ -253,7 +253,7 @@ QThread *QThread::create(Function &&f)
inline Qt::HANDLE QThread::currentThreadId() noexcept
{
Qt::HANDLE tid; // typedef to void*
- Q_STATIC_ASSERT(sizeof(tid) == sizeof(void*));
+ static_assert(sizeof(tid) == sizeof(void*));
// See https://akkadia.org/drepper/tls.pdf for x86 ABI
#if defined(Q_PROCESSOR_X86_32) && defined(Q_OS_LINUX) // x86 32-bit always uses GS
__asm__("movl %%gs:0, %0" : "=r" (tid) : : );
diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp
index 96c3f5c45c..35bfd35f1a 100644
--- a/src/corelib/thread/qthread_unix.cpp
+++ b/src/corelib/thread/qthread_unix.cpp
@@ -104,7 +104,7 @@ QT_BEGIN_NAMESPACE
#if QT_CONFIG(thread)
-Q_STATIC_ASSERT(sizeof(pthread_t) <= sizeof(Qt::HANDLE));
+static_assert(sizeof(pthread_t) <= sizeof(Qt::HANDLE));
enum { ThreadPriorityResetFlag = 0x80000000 };
diff --git a/src/corelib/thread/qwaitcondition_unix.cpp b/src/corelib/thread/qwaitcondition_unix.cpp
index 88b058f410..a1c973562b 100644
--- a/src/corelib/thread/qwaitcondition_unix.cpp
+++ b/src/corelib/thread/qwaitcondition_unix.cpp
@@ -108,7 +108,7 @@ void qt_abstime_for_timeout(timespec *ts, QDeadlineTimer deadline)
normalizedTimespec(*ts);
#else
// depends on QDeadlineTimer's internals!!
- Q_STATIC_ASSERT(QDeadlineTimerNanosecondsInT2);
+ static_assert(QDeadlineTimerNanosecondsInT2);
ts->tv_sec = deadline._q_data().first;
ts->tv_nsec = deadline._q_data().second;
#endif