]> www.infradead.org Git - mtd-utils.git/commitdiff
Add libmissing
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>
Thu, 1 Sep 2016 09:20:05 +0000 (11:20 +0200)
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>
Thu, 17 Nov 2016 10:36:55 +0000 (11:36 +0100)
This patch adds a libmissing library to mtd-utils, containing
implementations of functionality found in glibc but typically
missing from embedded C libraries such as uclibc ot musl.

For now, the library only contains stub implementations of
the backtrace*() family of functions.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
Makefile.am
configure.ac
include/libmissing.h [new file with mode: 0644]
lib/Makemodule.am
lib/execinfo.c [new file with mode: 0644]
tests/fs-tests/Makemodule.am
tests/fs-tests/integrity/integck.c

index 53c6ec3f18761a08b9443559f7cc05a596836529..686a7477b54d45a1b0e1e4c9c79d644c688876f9 100644 (file)
@@ -10,6 +10,10 @@ if WITHOUT_LZO
 AM_CPPFLAGS += -DWITHOUT_LZO
 endif
 
+if HAVE_EXECINFO
+AM_CPPFLAGS += -DHAVE_EXECINFO
+endif
+
 sbin_PROGRAMS =
 sbin_SCRIPTS =
 noinst_LIBRARIES =
index 9c8666c4d6af7e2778a758837472a3554e659c04..637d692e96d05ab50e690555242ff220fd38f9fe 100644 (file)
@@ -72,6 +72,9 @@ AC_ARG_WITH([lzo],
        [AM_CONDITIONAL([WITHOUT_LZO], [false])])
 
 
+AC_CHECK_HEADERS([execinfo.h], [execinfo_found=yes])
+AM_CONDITIONAL([HAVE_EXECINFO], [test "x$execinfo_found" == "xyes"])
+
 PKG_CHECK_MODULES(ZLIB, [ zlib ])
 PKG_CHECK_MODULES(UUID, [ uuid ])
 
diff --git a/include/libmissing.h b/include/libmissing.h
new file mode 100644 (file)
index 0000000..c765f6d
--- /dev/null
@@ -0,0 +1,15 @@
+#ifndef LIBMISSING_H
+#define LIBMISSING_H
+
+#ifdef HAVE_EXECINFO
+#include <execinfo.h>
+#endif
+
+#ifndef HAVE_EXECINFO
+int backtrace(void **buffer, int size);
+char **backtrace_symbols(void *const *buffer, int size);
+void backtrace_symbols_fd(void *const *buffer, int size, int fd);
+#endif
+
+#endif /* LIBMISSING_H */
+
index 2fd933d9e7510b15903ce384153b5ece20dd9753..b30a8aabe157e4333715977c617b50d75796f0f5 100644 (file)
@@ -5,4 +5,7 @@ libmtd_a_SOURCES = \
        lib/libmtd_legacy.c \
        lib/libmtd_int.h
 
-noinst_LIBRARIES += libmtd.a
+libmissing_a_SOURCES = \
+       lib/execinfo.c
+
+noinst_LIBRARIES += libmtd.a libmissing.a
diff --git a/lib/execinfo.c b/lib/execinfo.c
new file mode 100644 (file)
index 0000000..a39df83
--- /dev/null
@@ -0,0 +1,25 @@
+#include "libmissing.h"
+
+#ifndef HAVE_EXECINFO
+#define PROGRAM_NAME "libmissing"
+#include "common.h"
+
+int backtrace(void **buffer, int size)
+{
+       void *addr = __builtin_return_address(0);
+
+       errmsg("backtrace() is not implemented. Called from %p", addr);
+       return 0;
+}
+
+char **backtrace_symbols(void *const *buffer, int size)
+{
+       errmsg("backtrace_symbols() is not implemented");
+       return NULL;
+}
+
+void backtrace_symbols_fd(void *const *buffer, int size, int fd)
+{
+       errmsg("backtrace_symbols_fd() is not implemented");
+}
+#endif /* !HAVE_EXECINFO */
index 031355a8afcd60c0310454d2b3dcc575a475dece..d3acaa5b3daf6263984cc4eaa482410a05c8f674 100644 (file)
@@ -2,6 +2,11 @@ integck_SOURCES = tests/fs-tests/integrity/integck.c
 integck_LDADD = libubi.a
 integck_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/ubi-utils/include
 
+if HAVE_EXECINFO
+else
+integck_LDADD += libmissing.a
+endif
+
 test_1_SOURCES = tests/fs-tests/simple/test_1.c tests/fs-tests/lib/tests.c
 test_1_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/tests/fs-tests/lib
 
index 67384fa83eefd794c6eee0dddf3f0652de437989..7cb530515d42185f979b755f47281ae2b509b0c5 100644 (file)
@@ -31,7 +31,6 @@
 #include <getopt.h>
 #include <assert.h>
 #include <mntent.h>
-#include <execinfo.h>
 #include <sys/mman.h>
 #include <sys/vfs.h>
 #include <sys/mount.h>
@@ -40,6 +39,7 @@
 #define PROGRAM_NAME "integck"
 #include "common.h"
 #include "libubi.h"
+#include "libmissing.h"
 
 /*
  * WARNING! This is a dirty hack! The symbols for static functions are not