diff options
| author | Mårten Nordheim <marten.nordheim@qt.io> | 2025-08-19 15:40:30 +0200 |
|---|---|---|
| committer | Mårten Nordheim <marten.nordheim@qt.io> | 2025-08-21 21:34:13 +0200 |
| commit | 7181d440bcf45ef0d36a5214c0d5f74e988e31a7 (patch) | |
| tree | 495e2d57b8ac843afdf0c3362b26d644843c3f99 /src/corelib/tools/qarraydata.h | |
| parent | d9cb0ed9c5ca93cab9d3862e6cfd037738ca2f68 (diff) | |
QArrayData: Add MSVC attributes to MALLOCLIKE
__declspec(allocator) marks a function as something that allocates
memory, like malloc and new. This doesn't change optimizations in any
way, it is just for event tracking and the debugger.
__declspec(restrict) is used to indicate that any memory pointed to by
a pointer returned by the function is not aliased by any other pointer.
This is useful for the compiler to optimize memory access, namely it
can reorder stores and loads without having to take into account that
the memory might be accessed through another pointer.
Change-Id: Ic1320f3a4c17a12c9ac2c45eeb9ed70822380e6e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qarraydata.h')
| -rw-r--r-- | src/corelib/tools/qarraydata.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h index 38d1091ac1f..5aadbeda538 100644 --- a/src/corelib/tools/qarraydata.h +++ b/src/corelib/tools/qarraydata.h @@ -15,6 +15,8 @@ QT_BEGIN_NAMESPACE #if __has_cpp_attribute(gnu::malloc) # define Q_DECL_MALLOCLIKE [[nodiscard, gnu::malloc]] +#elif Q_CC_MSVC_ONLY +# define Q_DECL_MALLOCLIKE __declspec(allocator) __declspec(restrict) [[nodiscard]] #else # define Q_DECL_MALLOCLIKE [[nodiscard]] #endif |
