Permalink
Browse files

Merge pull request #7 from maxnet/master

Test for the existence of execinfo.h
  • Loading branch information...
2 parents 9852ce2 + 93ae1bc commit f7b1cad78497c65e59715d78be2b4fc9c63708c1 @popcornmix popcornmix committed Jan 22, 2013
Showing with 12 additions and 2 deletions.
  1. +5 −2 interface/vcos/glibc/vcos_backtrace.c
  2. +4 −0 makefiles/cmake/arm-linux.cmake
  3. +3 −0 makefiles/cmake/cmake_config.h.in
@@ -26,7 +26,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <interface/vcos/vcos.h>
-#ifdef __linux__
+#ifdef HAVE_CMAKE_CONFIG
+#include "cmake_config.h"
+#endif
+#ifdef HAVE_EXECINFO_H
#include <execinfo.h>
#endif
#include <stdio.h>
@@ -35,7 +38,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
void vcos_backtrace_self(void)
{
-#ifdef __linux__
+#ifdef HAVE_EXECINFO_H
void *stack[64];
int depth = backtrace(stack, sizeof(stack)/sizeof(stack[0]));
char **names = backtrace_symbols(stack, depth);
@@ -115,6 +115,10 @@ try_compile(HAVE_MTRACE
${CMAKE_SOURCE_DIR}/makefiles/cmake/srcs/test-mtrace.c
OUTPUT_VARIABLE foo)
+# test for existence of execinfo.h header
+include(CheckIncludeFile)
+check_include_file(execinfo.h HAVE_EXECINFO_H)
+
add_definitions(-DHAVE_CMAKE_CONFIG)
configure_file (
"makefiles/cmake/cmake_config.h.in"
@@ -8,5 +8,8 @@
/** Do we have support for GLIBC mtrace() ? */
#cmakedefine HAVE_MTRACE
+/** Do we have the execinfo.h include file ? */
+#cmakedefine HAVE_EXECINFO_H
+
#endif

0 comments on commit f7b1cad

Please sign in to comment.