[PATCH weston 2/5] compositor: check for execinfo.h

Pekka Paalanen ppaalanen at gmail.com
Wed May 30 05:53:42 PDT 2012


Some systems may not have execinfo.h. Add a configure test for it, and
if it is not found, make the backtrace() call a no-operation.

Signed-off-by: Pekka Paalanen <ppaalanen at gmail.com>
---
 configure.ac              |    2 ++
 shared/os-compatibility.h |   10 ++++++++++
 src/compositor.c          |    1 -
 3 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/configure.ac b/configure.ac
index 4dfd161..ad8a44a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -24,6 +24,8 @@ AC_CHECK_FUNC([dlopen], [],
               AC_CHECK_LIB([dl], [dlopen], DLOPEN_LIBS="-ldl"))
 AC_SUBST(DLOPEN_LIBS)
 
+AC_CHECK_HEADERS([execinfo.h])
+
 PKG_CHECK_MODULES(COMPOSITOR,
 		  [wayland-server egl >= 7.10 glesv2 xkbcommon pixman-1])
 
diff --git a/shared/os-compatibility.h b/shared/os-compatibility.h
index 77e8672..ca753b6 100644
--- a/shared/os-compatibility.h
+++ b/shared/os-compatibility.h
@@ -23,6 +23,16 @@
 #ifndef OS_COMPATIBILITY_H
 #define OS_COMPATIBILITY_H
 
+#ifdef HAVE_EXECINFO_H
+#include <execinfo.h>
+#else
+static inline int
+backtrace(void **buffer, int size)
+{
+	return 0;
+}
+#endif
+
 int
 os_socketpair_cloexec(int domain, int type, int protocol, int *sv);
 
diff --git a/src/compositor.c b/src/compositor.c
index f701f1b..b8e3860 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -42,7 +42,6 @@
 #include <dlfcn.h>
 #include <signal.h>
 #include <setjmp.h>
-#include <execinfo.h>
 
 #include <wayland-server.h>
 #include "compositor.h"
-- 
1.7.3.4



More information about the wayland-devel mailing list