fixed lots of not-thread-safe things
Most of the things I fixed here were using libc functions that are
fundamentally not thread-safe.
diff --git a/aos/common/libc/aos_strerror.h b/aos/common/libc/aos_strerror.h
new file mode 100644
index 0000000..acce427
--- /dev/null
+++ b/aos/common/libc/aos_strerror.h
@@ -0,0 +1,23 @@
+#ifndef AOS_COMMON_LIBC_AOS_STRERROR_H_
+#define AOS_COMMON_LIBC_AOS_STRERROR_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Thread-safe version of strerror(3) (except it may change errno).
+//
+// Returns a pointer to static data or a thread-local buffer.
+//
+// Necessary because strerror_r(3) is such a mess (which version you get is
+// determined at compile time by black magic related to feature macro
+// definitions, compiler flags, glibc version, and even whether you're using g++
+// or clang++) and strerror_l(3) might not work if you end up with the magic
+// LC_GLOBAL_LOCALE locale.
+const char *aos_strerror(int error);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // AOS_COMMON_LIBC_AOS_STRERROR_H_