[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 02/04: volk: add check for posix_memalign f
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 02/04: volk: add check for posix_memalign for OSs that do not directly set _XOPEN_SOURCE or _POSIX_C_SOURCE; define and use the new variable when found. |
Date: |
Thu, 14 Aug 2014 15:23:23 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
trondeau pushed a commit to branch maint
in repository gnuradio.
commit fcc79161210f6da914b16669b835125535dd3895
Author: Michael Dickens <address@hidden>
Date: Thu Aug 7 09:41:33 2014 -0400
volk: add check for posix_memalign for OSs that do not directly set
_XOPEN_SOURCE or _POSIX_C_SOURCE; define and use the new variable when found.
---
volk/lib/CMakeLists.txt | 12 ++++++++++++
volk/lib/volk_malloc.c | 6 +++---
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/volk/lib/CMakeLists.txt b/volk/lib/CMakeLists.txt
index d72eb72..3b12b4a 100644
--- a/volk/lib/CMakeLists.txt
+++ b/volk/lib/CMakeLists.txt
@@ -66,6 +66,18 @@ if(COMPILER_NAME MATCHES "GNU")
endif()
########################################################################
+# check for posix_memalign, since some OSs do not internally define
+# _XOPEN_SOURCE or _POSIX_C_SOURCE; they leave this to the user.
+########################################################################
+
+include(CheckFunctionExists)
+CHECK_FUNCTION_EXISTS(posix_memalign HAVE_POSIX_MEMALIGN)
+
+if(HAVE_POSIX_MEMALIGN)
+ add_definitions(-DHAVE_POSIX_MEMALIGN)
+endif(HAVE_POSIX_MEMALIGN)
+
+########################################################################
# detect x86 flavor of CPU
########################################################################
if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^(i.86|x86|x86_64|amd64)$")
diff --git a/volk/lib/volk_malloc.c b/volk/lib/volk_malloc.c
index b2b77dd..a219d27 100644
--- a/volk/lib/volk_malloc.c
+++ b/volk/lib/volk_malloc.c
@@ -54,7 +54,7 @@
// Otherwise, test if we are a POSIX or X/Open system
// This only has a restriction that alignment be a power of 2.
-#if _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600
+#if _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600 || HAVE_POSIX_MEMALIGN
void *volk_malloc(size_t size, size_t alignment)
{
@@ -75,7 +75,7 @@ void volk_free(void *ptr)
}
// No standard handlers; we'll do it ourselves.
-#else // _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600
+#else // _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600 ||
HAVE_POSIX_MEMALIGN
typedef struct mbuf_t {
void *orig;
@@ -171,6 +171,6 @@ void volk_free(void *ptr)
fprintf(stderr, "VOLK: tried to free a non-VOLK pointer\n");
}
-#endif // _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600
+#endif // _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600 ||
HAVE_POSIX_MEMALIGN
//#endif // _ISOC11_SOURCE