mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-18 03:15:52 +01:00
add namespace to pbd/malign methods; add PBD::aligned_size() which is related
This commit is contained in:
parent
096bff41c5
commit
438cf0419d
2 changed files with 17 additions and 4 deletions
|
|
@ -35,7 +35,7 @@ static const int CPU_CACHE_ALIGN = 64;
|
|||
static const int CPU_CACHE_ALIGN = 16; /* arguably 32 on most arches, but it matters less */
|
||||
#endif
|
||||
|
||||
int cache_aligned_malloc (void** memptr, size_t size)
|
||||
int PBD::cache_aligned_malloc (void** memptr, size_t size)
|
||||
{
|
||||
#ifndef HAVE_POSIX_MEMALIGN
|
||||
#ifdef PLATFORM_WINDOWS
|
||||
|
|
@ -65,7 +65,7 @@ int cache_aligned_malloc (void** memptr, size_t size)
|
|||
#endif
|
||||
}
|
||||
|
||||
void cache_aligned_free (void* memptr)
|
||||
void PBD::cache_aligned_free (void* memptr)
|
||||
{
|
||||
#ifdef PLATFORM_WINDOWS
|
||||
_aligned_free (memptr);
|
||||
|
|
@ -74,7 +74,7 @@ void cache_aligned_free (void* memptr)
|
|||
#endif
|
||||
}
|
||||
|
||||
int aligned_malloc (void** memptr, size_t size, size_t alignment)
|
||||
int PBD::aligned_malloc (void** memptr, size_t size, size_t alignment)
|
||||
{
|
||||
#ifndef HAVE_POSIX_MEMALIGN
|
||||
#ifdef PLATFORM_WINDOWS
|
||||
|
|
@ -104,7 +104,7 @@ int aligned_malloc (void** memptr, size_t size, size_t alignment)
|
|||
#endif
|
||||
}
|
||||
|
||||
void aligned_free (void* memptr)
|
||||
void PBD::aligned_free (void* memptr)
|
||||
{
|
||||
#ifdef PLATFORM_WINDOWS
|
||||
_aligned_free (memptr);
|
||||
|
|
@ -112,3 +112,10 @@ void aligned_free (void* memptr)
|
|||
free (memptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
size_t
|
||||
PBD::aligned_size (size_t size)
|
||||
{
|
||||
const int align_size = 8; /* XXX probably a better value for this */
|
||||
return (size + align_size - 1) & ~(align_size - 1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,10 +24,16 @@
|
|||
|
||||
#include "pbd/libpbd_visibility.h"
|
||||
|
||||
namespace PBD {
|
||||
|
||||
LIBPBD_API int cache_aligned_malloc (void** memptr, size_t size);
|
||||
LIBPBD_API void cache_aligned_free (void* memptr);
|
||||
|
||||
LIBPBD_API int aligned_malloc (void** memptr, size_t size, size_t alignment);
|
||||
LIBPBD_API void aligned_free (void* memptr);
|
||||
|
||||
LIBPBD_API size_t aligned_size (size_t sz);
|
||||
|
||||
}
|
||||
|
||||
#endif /* __pbd_malign_h__ */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue