Skip to content

Commit

Permalink
Prefer C11's aligned_alloc if it is available
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
  • Loading branch information
sebastinas committed Feb 22, 2014
1 parent 85c2ac6 commit 6a3bd8b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/AESNI.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,16 @@ typedef struct {

static void* memalign_wrapper(size_t alignment, size_t size)
{
#if defined(HAVE_POSIX_MEMALIGN)
#if defined(HAVE_ALIGNED_ALLOC)
/* aligned_alloc is defined by C11 */
return aligned_alloc(alignment, size);
#elif defined(HAVE_POSIX_MEMALIGN)
/* posix_memalign is defined by POSIX */
void* tmp = NULL;
int result = posix_memalign(&tmp, alignment, size);
if (result != 0)
return NULL;
return tmp;
#elif defined(HAVE_ALIGNED_ALLOC)
/* aligned_alloc is defined by C11 */
return aligned_alloc(alignment, size);
#elif defined(HAVE__ALIGNED_MALLOC)
/* _aligned_malloc is available on Windows */
return _aligned_malloc(size, alignment);
Expand Down

0 comments on commit 6a3bd8b

Please sign in to comment.