From 585b0cf3bed7d1c5720633eb7e5358a9fca865f6 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Thu, 6 Jun 2019 00:37:00 -0700 Subject: [PATCH] Remove the DEF_ALIGN macro --- Alc/vector.h | 2 +- OpenAL32/alSource.cpp | 8 ++++---- common/almalloc.cpp | 7 ++++--- common/almalloc.h | 2 -- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Alc/vector.h b/Alc/vector.h index a7df54f4..1b69d6a7 100644 --- a/Alc/vector.h +++ b/Alc/vector.h @@ -7,7 +7,7 @@ namespace al { -template +template using vector = std::vector>; } // namespace al diff --git a/OpenAL32/alSource.cpp b/OpenAL32/alSource.cpp index 6d4daecd..b2878b8e 100644 --- a/OpenAL32/alSource.cpp +++ b/OpenAL32/alSource.cpp @@ -1284,7 +1284,7 @@ ALboolean SetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp prop, co if(buffer != nullptr) { /* Add the selected buffer to a one-item queue */ - auto newlist = static_cast(al_calloc(DEF_ALIGN, + auto newlist = static_cast(al_calloc(alignof(void*), ALbufferlistitem::Sizeof(1u))); newlist->next.store(nullptr, std::memory_order_relaxed); newlist->max_samples = buffer->SampleLen; @@ -3185,13 +3185,13 @@ START_API_FUNC if(!BufferListStart) { - BufferListStart = static_cast(al_calloc(DEF_ALIGN, + BufferListStart = static_cast(al_calloc(alignof(void*), ALbufferlistitem::Sizeof(1u))); BufferList = BufferListStart; } else { - auto item = static_cast(al_calloc(DEF_ALIGN, + auto item = static_cast(al_calloc(alignof(void*), ALbufferlistitem::Sizeof(1u))); BufferList->next.store(item, std::memory_order_relaxed); BufferList = item; @@ -3290,7 +3290,7 @@ START_API_FUNC } std::unique_lock buflock{device->BufferLock}; - auto BufferListStart = static_cast(al_calloc(DEF_ALIGN, + auto BufferListStart = static_cast(al_calloc(alignof(void*), ALbufferlistitem::Sizeof(nb))); BufferList = BufferListStart; BufferList->next.store(nullptr, std::memory_order_relaxed); diff --git a/common/almalloc.cpp b/common/almalloc.cpp index f7af5bf3..fbb84479 100644 --- a/common/almalloc.cpp +++ b/common/almalloc.cpp @@ -4,6 +4,7 @@ #include "almalloc.h" #include +#include #include #include #ifdef HAVE_MALLOC_H @@ -28,7 +29,7 @@ void *al_malloc(size_t alignment, size_t size) { assert((alignment & (alignment-1)) == 0); - alignment = std::max(alignment, sizeof(void*)); + alignment = std::max(alignment, alignof(std::max_align_t)); #if defined(HAVE_ALIGNED_ALLOC) size = (size+(alignment-1))&~(alignment-1); @@ -79,7 +80,7 @@ void al_free(void *ptr) noexcept size_t al_get_page_size() noexcept { - static size_t psize = 0; + static size_t psize{0u}; if(UNLIKELY(!psize)) { #ifdef HAVE_SYSCONF @@ -97,7 +98,7 @@ size_t al_get_page_size() noexcept psize = sysinfo.dwPageSize; } #endif - if(!psize) psize = DEF_ALIGN; + if(!psize) psize = alignof(std::max_align_t); } return psize; } diff --git a/common/almalloc.h b/common/almalloc.h index 74aa4afe..7b74b659 100644 --- a/common/almalloc.h +++ b/common/almalloc.h @@ -7,8 +7,6 @@ #include #include -/* Minimum alignment required by posix_memalign. */ -#define DEF_ALIGN sizeof(void*) void *al_malloc(size_t alignment, size_t size); void *al_calloc(size_t alignment, size_t size);