Add a stub getenv() implementation.
authorwhitequark <whitequark@whitequark.org>
Sun, 26 Jul 2015 09:55:52 +0000 (12:55 +0300)
committerwhitequark <whitequark@whitequark.org>
Sun, 26 Jul 2015 09:55:52 +0000 (12:55 +0300)
This is not strictly necessary to build libunwind (it can
be built with -DNDEBUG), but it will be handy while it is
debugged.

It can be removed afterwards.

software/libbase/Makefile
software/libbase/environ.c [new file with mode: 0644]

index c1f2434dfcad16a3fc1e19062bea5614087c9b2d..35f92f659dcfd119ff270eca411d16dd0b37e547 100644 (file)
@@ -1,7 +1,7 @@
 MSCDIR=../..
 include $(MSCDIR)/software/common.mak
 
-OBJECTS=exception.o libc.o errno.o crc16.o crc32.o console.o system.o id.o uart.o time.o qsort.o strtod.o spiflash.o
+OBJECTS=exception.o libc.o errno.o crc16.o crc32.o console.o environ.o system.o id.o uart.o time.o qsort.o strtod.o spiflash.o
 
 all: crt0-$(CPU).o libbase.a libbase-nofloat.a
 
diff --git a/software/libbase/environ.c b/software/libbase/environ.c
new file mode 100644 (file)
index 0000000..2c2c92f
--- /dev/null
@@ -0,0 +1,11 @@
+#include <stdlib.h>
+#include <string.h>
+
+char *getenv(const char *varname) {
+  if(!strcmp(varname, "LIBUNWIND_PRINT_APIS") ||
+     !strcmp(varname, "LIBUNWIND_PRINT_UNWINDING")) {
+    return "1";
+  } else {
+    return NULL;
+  }
+}