1// Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB).
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QT3DRENDER_RENDER_ALIGNED_MALLOC_P_H
5#define QT3DRENDER_RENDER_ALIGNED_MALLOC_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists for the convenience
12// of other Qt classes. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/private/qsimd_p.h>
19#include <Qt3DCore/private/qt3dcore-config_p.h>
20
21#if defined(__AVX2__)
22# define QT3D_ALIGNED_MALLOC(s) _mm_malloc(s, 32)
23#elif defined(__SSE2__)
24# define QT3D_ALIGNED_MALLOC(s) _mm_malloc(s, 16)
25#else
26 #define QT3D_ALIGNED_MALLOC(s) malloc(s)
27#endif
28
29#if defined(__SSE2__)
30# define QT3D_ALIGNED_FREE(ptr) _mm_free(ptr)
31#else
32# define QT3D_ALIGNED_FREE(ptr) free(ptr)
33#endif
34
35#define QT3D_ALIGNED_MALLOC_AND_FREE() \
36 static void *operator new(size_t s) \
37 { \
38 return QT3D_ALIGNED_MALLOC(s); \
39 } \
40 static void operator delete(void *ptr) \
41 { \
42 QT3D_ALIGNED_FREE(ptr); \
43 }
44
45#endif // QT3DRENDER_RENDER_ALIGNED_MALLOC_P_H
46

source code of qt3d/src/core/aligned_malloc_p.h