Merge branch 'cross-compile' of

https://github.com/anthony-arnold/gnss-sdr into anthony-cross-compile

# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
This commit is contained in:
Carles Fernandez
2015-03-20 21:14:56 +01:00
8 changed files with 101 additions and 87 deletions
@@ -38,6 +38,7 @@ set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) #allows this to be a sub-proje
set(CMAKE_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) #allows this to be a sub-project
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) #location for custom "Modules"
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
########################################################################
# Environment setup
@@ -20,8 +20,7 @@
#include "volk_gnsssdr/volk_gnsssdr_malloc.h"
#include <pthread.h>
#include <stdio.h>
#include <string.h>
/*
* For #defines used to determine support for allocation functions,
@@ -52,12 +51,20 @@
//#else // _ISOC11_SOURCE
// 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 2and a
// multiple of sizeof(void *).
#if _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600 || HAVE_POSIX_MEMALIGN
void *volk_gnsssdr_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)
{
@@ -65,7 +72,9 @@ void *volk_gnsssdr_malloc(size_t size, size_t alignment)
}
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;
}
}