Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:07:40

0001 // Copyright (C) 2023 The Qt Company Ltd.
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0003 
0004 #ifndef QTSYMBOLMACROS_H
0005 #define QTSYMBOLMACROS_H
0006 
0007 #if 0
0008 #  pragma qt_sync_stop_processing
0009 #endif
0010 
0011 // For GHS symbol keeping.
0012 #include <QtCore/qcompilerdetection.h>
0013 #include <QtCore/qtpreprocessorsupport.h>
0014 
0015 // For handling namespaced resources.
0016 #ifdef QT_NAMESPACE
0017 #  define QT_RCC_MANGLE_NAMESPACE0(x) x
0018 #  define QT_RCC_MANGLE_NAMESPACE1(a, b) a##_##b
0019 #  define QT_RCC_MANGLE_NAMESPACE2(a, b) QT_RCC_MANGLE_NAMESPACE1(a,b)
0020 #  define QT_RCC_MANGLE_NAMESPACE(name) QT_RCC_MANGLE_NAMESPACE2( \
0021         QT_RCC_MANGLE_NAMESPACE0(name), QT_RCC_MANGLE_NAMESPACE0(QT_NAMESPACE))
0022 #else
0023 #   define QT_RCC_MANGLE_NAMESPACE(name) name
0024 #endif
0025 
0026 // GHS needs special handling to keep a symbol around.
0027 #if defined(Q_CC_GHS)
0028 #  define Q_GHS_KEEP_REFERENCE(S) QT_DO_PRAGMA(ghs reference S ##__Fv)
0029 #else
0030 #  define Q_GHS_KEEP_REFERENCE(S)
0031 #endif
0032 
0033 // Macros to ensure a symbol is not dropped by the linker even if it's not used.
0034 #define QT_DECLARE_EXTERN_SYMBOL(NAME, RETURN_TYPE) \
0035     extern RETURN_TYPE NAME(); \
0036     Q_GHS_KEEP_REFERENCE(NAME)
0037 
0038 #define QT_DECLARE_EXTERN_SYMBOL_INT(NAME) \
0039     QT_DECLARE_EXTERN_SYMBOL(NAME, int)
0040 
0041 #define QT_DECLARE_EXTERN_SYMBOL_VOID(NAME) \
0042     QT_DECLARE_EXTERN_SYMBOL(NAME, void)
0043 
0044 #define QT_KEEP_SYMBOL_VAR_NAME(NAME) NAME ## _keep
0045 
0046 #define QT_KEEP_SYMBOL_HELPER(NAME, VAR_NAME) \
0047     volatile auto VAR_NAME = &NAME; \
0048     Q_UNUSED(VAR_NAME)
0049 
0050 #define QT_KEEP_SYMBOL(NAME) \
0051     QT_KEEP_SYMBOL_HELPER(NAME, QT_KEEP_SYMBOL_VAR_NAME(NAME))
0052 
0053 
0054 // Similar to the ones above, but for rcc resource symbols specifically.
0055 #define QT_GET_RESOURCE_INIT_SYMBOL(NAME) \
0056     QT_RCC_MANGLE_NAMESPACE(qInitResources_ ## NAME)
0057 
0058 #define QT_DECLARE_EXTERN_RESOURCE(NAME) \
0059     QT_DECLARE_EXTERN_SYMBOL_INT(QT_GET_RESOURCE_INIT_SYMBOL(NAME))
0060 
0061 #define QT_KEEP_RESOURCE(NAME) \
0062     QT_KEEP_SYMBOL(QT_GET_RESOURCE_INIT_SYMBOL(NAME))
0063 
0064 #endif // QTSYMBOLMACROS_H
0065