diff options
| author | Julius Ikkala <julius.ikkala@gmail.com> | 2025-07-04 00:09:09 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-03 21:09:09 +0000 |
| commit | 551d0c365571a2e36505851f6a713464662c5fea (patch) | |
| tree | e2c95e6b1016d9e129ac3b463b8a003573284f15 /source/core | |
| parent | ebfb8d0428b12d3a6cd6de8ebeb13297004cfbe8 (diff) | |
Replace SLANG_ALIGN_OF with C++11 alignof (#7523)
* Replace SLANG_ALIGN_OF with C++11 alignof
* Fix formatting (again)
Diffstat (limited to 'source/core')
| -rw-r--r-- | source/core/slang-memory-arena.h | 14 | ||||
| -rw-r--r-- | source/core/slang-offset-container.h | 4 | ||||
| -rw-r--r-- | source/core/slang-rtti-info.cpp | 10 | ||||
| -rw-r--r-- | source/core/slang-rtti-info.h | 4 |
4 files changed, 15 insertions, 17 deletions
diff --git a/source/core/slang-memory-arena.h b/source/core/slang-memory-arena.h index 714918b9a..f08541ddb 100644 --- a/source/core/slang-memory-arena.h +++ b/source/core/slang-memory-arena.h @@ -382,9 +382,8 @@ inline const char* MemoryArena::allocateString(const char* chars, size_t numChar template<typename T> SLANG_FORCE_INLINE T* MemoryArena::allocate() { - void* mem = (SLANG_ALIGN_OF(T) <= kMinAlignment) - ? allocate(sizeof(T)) - : allocateAligned(sizeof(T), SLANG_ALIGN_OF(T)); + void* mem = (alignof(T) <= kMinAlignment) ? allocate(sizeof(T)) + : allocateAligned(sizeof(T), alignof(T)); return reinterpret_cast<T*>(mem); } @@ -392,9 +391,8 @@ SLANG_FORCE_INLINE T* MemoryArena::allocate() template<typename T> SLANG_FORCE_INLINE T* MemoryArena::allocateArray(size_t numElems) { - return (numElems > 0) - ? reinterpret_cast<T*>(allocateAligned(sizeof(T) * numElems, SLANG_ALIGN_OF(T))) - : nullptr; + return (numElems > 0) ? reinterpret_cast<T*>(allocateAligned(sizeof(T) * numElems, alignof(T))) + : nullptr; } // -------------------------------------------------------------------------- @@ -405,7 +403,7 @@ SLANG_FORCE_INLINE T* MemoryArena::allocateAndCopyArray(const T* arr, size_t num if (numElems > 0) { const size_t totalSize = sizeof(T) * numElems; - void* ptr = allocateAligned(totalSize, SLANG_ALIGN_OF(T)); + void* ptr = allocateAligned(totalSize, alignof(T)); ::memcpy(ptr, arr, totalSize); return reinterpret_cast<T*>(ptr); } @@ -419,7 +417,7 @@ SLANG_FORCE_INLINE T* MemoryArena::allocateAndZeroArray(size_t numElems) if (numElems > 0) { const size_t totalSize = sizeof(T) * numElems; - void* ptr = allocateAligned(totalSize, SLANG_ALIGN_OF(T)); + void* ptr = allocateAligned(totalSize, alignof(T)); ::memset(ptr, 0, totalSize); return reinterpret_cast<T*>(ptr); } diff --git a/source/core/slang-offset-container.h b/source/core/slang-offset-container.h index 4e6920bed..7398c3a8d 100644 --- a/source/core/slang-offset-container.h +++ b/source/core/slang-offset-container.h @@ -445,7 +445,7 @@ public: template<typename T> Offset32Ptr<T> newObject() { - void* data = allocate(sizeof(T), SLANG_ALIGN_OF(T)); + void* data = allocate(sizeof(T), alignof(T)); new (data) T(); return Offset32Ptr<T>(getOffset(data)); } @@ -457,7 +457,7 @@ public: { return Offset32Array<T>(); } - T* data = (T*)allocate(sizeof(T) * size, SLANG_ALIGN_OF(T)); + T* data = (T*)allocate(sizeof(T) * size, alignof(T)); for (size_t i = 0; i < size; ++i) { new (data + i) T(); diff --git a/source/core/slang-rtti-info.cpp b/source/core/slang-rtti-info.cpp index 070b9c204..b30b5ac75 100644 --- a/source/core/slang-rtti-info.cpp +++ b/source/core/slang-rtti-info.cpp @@ -13,11 +13,11 @@ namespace Slang { \ RttiInfo::Kind::Invalid, 0, 0 \ } -#define SLANG_RTTI_INFO_BASIC(name, type) \ - RttiInfo \ - { \ - RttiInfo::Kind::name, RttiInfo::AlignmentType(SLANG_ALIGN_OF(type)), \ - RttiInfo::SizeType(sizeof(type)) \ +#define SLANG_RTTI_INFO_BASIC(name, type) \ + RttiInfo \ + { \ + RttiInfo::Kind::name, RttiInfo::AlignmentType(alignof(type)), \ + RttiInfo::SizeType(sizeof(type)) \ } /* static */ const RttiInfo RttiInfo::g_basicTypes[Index(Kind::CountOf)] = { diff --git a/source/core/slang-rtti-info.h b/source/core/slang-rtti-info.h index 58e557dd0..9d4967cfe 100644 --- a/source/core/slang-rtti-info.h +++ b/source/core/slang-rtti-info.h @@ -199,7 +199,7 @@ struct RttiInfo template<typename T> void init(Kind kind) { - init(kind, SLANG_ALIGN_OF(T), sizeof(T)); + init(kind, alignof(T), sizeof(T)); } /// Allocate memory for RttiInfo types. @@ -475,7 +475,7 @@ struct GetRttiInfo<T[COUNT]> { FixedArrayRttiInfo info; info.m_kind = RttiInfo::Kind::FixedArray; - info.m_alignment = RttiInfo::AlignmentType(SLANG_ALIGN_OF(T)); + info.m_alignment = RttiInfo::AlignmentType(alignof(T)); info.m_size = RttiInfo::SizeType(sizeof(T) * COUNT); info.m_elementType = GetRttiInfo<T>::get(); info.m_elementCount = COUNT; |
