Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
utils: fix volk_malloc's posix_memalign when alignment is 1
Addresses gnuradio issue 692.
  • Loading branch information
Julien Olivain authored and n-west committed Feb 2, 2015
1 parent e7facbc commit cc1abd2
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/volk_malloc.c
Expand Up @@ -23,25 +23,36 @@
#include <volk/volk_malloc.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/*
* For #defines used to determine support for allocation functions,
* see: http://linux.die.net/man/3/aligned_alloc
*/

// Otherwise, test if we are a POSIX or X/Open system
// This only has a restriction that alignment be a power of 2.
// This only has a restriction that alignment be a power of 2 and a
// multiple of sizeof(void *).
#if _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600 || HAVE_POSIX_MEMALIGN

void *volk_malloc(size_t size, size_t alignment)
{
void *ptr;

// quoting posix_memalign() man page:
// "alignment must be a power of two and a multiple of sizeof(void *)"
// volk_get_alignment() could return 1 for some machines (e.g. generic_orc)
if (alignment == 1)
return malloc(size);

int err = posix_memalign(&ptr, alignment, size);
if(err == 0) {
return ptr;
}
else {
fprintf(stderr, "VOLK: Error allocating memory (posix_memalign: %d)\n", err);
fprintf(stderr,
"VOLK: Error allocating memory "
"(posix_memalign: error %d: %s)\n", err, strerror(err));
return NULL;
}
}
Expand Down

3 comments on commit cc1abd2

@michaelld
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jolivain are you the author of this commit? we are trying to relicense VOLK from GPLv3+ to LGPLv3+ . The GitHub handle noted here has made 2 commits. If this is you, then we hope you'd be willing to do relicensing. You don't have to use your actual email; we'd be willing to accept a statement such as:

I, Julien Olivain, hereby resubmit all my contributions to the VOLK project and repository under the terms of the LGPL-3.0-or-later. My GitHub handle jolivain.  I hereby agree that contributions made by me in the past, to previous versions of VOLK, may be re-used for inclusion in VOLK 3. I understand that VOLK 3 will be relicensed under LGPL-3.0-or-later.

If you approve of this statement, you can even just state so in a reply comment here. Thanks for your help with VOLK in the past & we hope you do so in the future too! If you want to use your email that's also fine; most folks do, but some folks want their privacy and we respect that.

@jolivain
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Michael,
Yes, I am the author of this commit, and I also agree to the relicense of VOLK from GPLv3+ to LGPLv3+. I am OK with the statement you made (using my name and Github handle). I'm rewriting it to confirm:

I, Julien Olivain, hereby resubmit all my contributions to the VOLK project and repository under the terms of the LGPL-3.0-or-later. My GitHub handle jolivain. I hereby agree that contributions made by me in the past, to previous versions of VOLK, may be re-used for inclusion in VOLK 3. I understand that VOLK 3 will be relicensed under LGPL-3.0-or-later.

Thanks!

@michaelld
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @jolivain !

Please sign in to comment.