Skip to content

Commit

Permalink
Remove the DEF_ALIGN macro
Browse files Browse the repository at this point in the history
  • Loading branch information
kcat committed Jun 6, 2019
1 parent a7be531 commit 585b0cf
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Alc/vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace al {

template<typename T, size_t alignment=DEF_ALIGN>
template<typename T, size_t alignment=alignof(T)>
using vector = std::vector<T, al::allocator<T, alignment>>;

} // namespace al
Expand Down
8 changes: 4 additions & 4 deletions OpenAL32/alSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<ALbufferlistitem*>(al_calloc(DEF_ALIGN,
auto newlist = static_cast<ALbufferlistitem*>(al_calloc(alignof(void*),
ALbufferlistitem::Sizeof(1u)));
newlist->next.store(nullptr, std::memory_order_relaxed);
newlist->max_samples = buffer->SampleLen;
Expand Down Expand Up @@ -3185,13 +3185,13 @@ START_API_FUNC

if(!BufferListStart)
{
BufferListStart = static_cast<ALbufferlistitem*>(al_calloc(DEF_ALIGN,
BufferListStart = static_cast<ALbufferlistitem*>(al_calloc(alignof(void*),
ALbufferlistitem::Sizeof(1u)));
BufferList = BufferListStart;
}
else
{
auto item = static_cast<ALbufferlistitem*>(al_calloc(DEF_ALIGN,
auto item = static_cast<ALbufferlistitem*>(al_calloc(alignof(void*),
ALbufferlistitem::Sizeof(1u)));
BufferList->next.store(item, std::memory_order_relaxed);
BufferList = item;
Expand Down Expand Up @@ -3290,7 +3290,7 @@ START_API_FUNC
}

std::unique_lock<std::mutex> buflock{device->BufferLock};
auto BufferListStart = static_cast<ALbufferlistitem*>(al_calloc(DEF_ALIGN,
auto BufferListStart = static_cast<ALbufferlistitem*>(al_calloc(alignof(void*),
ALbufferlistitem::Sizeof(nb)));
BufferList = BufferListStart;
BufferList->next.store(nullptr, std::memory_order_relaxed);
Expand Down
7 changes: 4 additions & 3 deletions common/almalloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "almalloc.h"

#include <cassert>
#include <cstddef>
#include <cstdlib>
#include <cstring>
#ifdef HAVE_MALLOC_H
Expand All @@ -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);
Expand Down Expand Up @@ -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
Expand All @@ -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;
}
Expand Down
2 changes: 0 additions & 2 deletions common/almalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
#include <limits>
#include <algorithm>

/* 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);
Expand Down

0 comments on commit 585b0cf

Please sign in to comment.