| 1 | /**************************************************************************** |
|---|---|
| 2 | ** |
| 3 | ** Copyright (C) 2017 Intel Corporation. |
| 4 | ** Contact: https://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the test suite of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at https://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU |
| 19 | ** General Public License version 3 as published by the Free Software |
| 20 | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT |
| 21 | ** included in the packaging of this file. Please review the following |
| 22 | ** information to ensure the GNU General Public License requirements will |
| 23 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
| 24 | ** |
| 25 | ** $QT_END_LICENSE$ |
| 26 | ** |
| 27 | ****************************************************************************/ |
| 28 | |
| 29 | #include <QtCore/qglobal.h> |
| 30 | |
| 31 | #if __has_include(<stdbool.h>) || __STDC_VERSION__ >= 199901L |
| 32 | # include <stdbool.h> |
| 33 | #else |
| 34 | # undef true |
| 35 | # define true 1 |
| 36 | # undef false |
| 37 | # define false 0 |
| 38 | #endif |
| 39 | |
| 40 | #ifdef Q_COMPILER_THREAD_LOCAL |
| 41 | # include <threads.h> |
| 42 | #endif |
| 43 | |
| 44 | /* |
| 45 | * Certain features of qglobal.h must work in C mode too. We test that |
| 46 | * everything works. |
| 47 | */ |
| 48 | |
| 49 | /* Types and Q_UNUSED */ |
| 50 | void tst_GlobalTypes() |
| 51 | { |
| 52 | qint8 s8; |
| 53 | qint16 s16; |
| 54 | qint32 s32; |
| 55 | qint64 s64; |
| 56 | qlonglong sll; |
| 57 | Q_UNUSED(s8); Q_UNUSED(s16); Q_UNUSED(s32); Q_UNUSED(s64); Q_UNUSED(sll); |
| 58 | |
| 59 | quint8 u8; |
| 60 | quint16 u16; |
| 61 | quint32 u32; |
| 62 | quint64 u64; |
| 63 | qulonglong ull; |
| 64 | Q_UNUSED(u8); Q_UNUSED(u16); Q_UNUSED(u32); Q_UNUSED(u64); Q_UNUSED(ull); |
| 65 | |
| 66 | uchar uc; |
| 67 | ushort us; |
| 68 | uint ui; |
| 69 | ulong ul; |
| 70 | Q_UNUSED(uc); Q_UNUSED(us); Q_UNUSED(ui); Q_UNUSED(ul); |
| 71 | |
| 72 | qreal qr; |
| 73 | Q_UNUSED(qr); |
| 74 | |
| 75 | qsizetype qs; |
| 76 | qptrdiff qp; |
| 77 | qintptr qip; |
| 78 | quintptr qup; |
| 79 | Q_UNUSED(qs); Q_UNUSED(qp); Q_UNUSED(qip); Q_UNUSED(qup); |
| 80 | } |
| 81 | |
| 82 | /* Qt version */ |
| 83 | int tst_QtVersion() |
| 84 | { |
| 85 | return QT_VERSION; |
| 86 | } |
| 87 | |
| 88 | const char *tst_qVersion() Q_DECL_NOEXCEPT |
| 89 | { |
| 90 | #if !defined(QT_NAMESPACE) |
| 91 | return qVersion(); |
| 92 | #else |
| 93 | return NULL; |
| 94 | #endif |
| 95 | } |
| 96 | |
| 97 | /* Static assertion */ |
| 98 | Q_STATIC_ASSERT(true); |
| 99 | Q_STATIC_ASSERT(1); |
| 100 | Q_STATIC_ASSERT_X(true, "Message"); |
| 101 | Q_STATIC_ASSERT_X(1, "Message"); |
| 102 | |
| 103 | Q_STATIC_ASSERT(!false); |
| 104 | Q_STATIC_ASSERT(!0); |
| 105 | |
| 106 | Q_STATIC_ASSERT(!!true); |
| 107 | Q_STATIC_ASSERT(!!1); |
| 108 | |
| 109 | #ifdef Q_COMPILER_THREAD_LOCAL |
| 110 | static thread_local int gt_var; |
| 111 | void thread_local_test() |
| 112 | { |
| 113 | static thread_local int t_var; |
| 114 | t_var = gt_var; |
| 115 | } |
| 116 | #endif |
| 117 | |
| 118 |
