Convert aos over to flatbuffers
Everything builds, and all the tests pass. I suspect that some entries
are missing from the config files, but those will be found pretty
quickly on startup.
There is no logging or live introspection of queue messages.
Change-Id: I496ee01ed68f202c7851bed7e8786cee30df29f5
diff --git a/aos/ipc_lib/aos_sync.cc b/aos/ipc_lib/aos_sync.cc
index 3bdba21..efb1fb1 100644
--- a/aos/ipc_lib/aos_sync.cc
+++ b/aos/ipc_lib/aos_sync.cc
@@ -26,10 +26,10 @@
#include <algorithm>
#include <type_traits>
-#include "aos/logging/logging.h"
+#include "absl/base/call_once.h"
#include "aos/macros.h"
#include "aos/util/compiler_memory_barrier.h"
-#include "absl/base/call_once.h"
+#include "glog/logging.h"
using ::aos::linux_code::ipc_lib::FutexAccessorObserver;
@@ -354,16 +354,16 @@
return r;
}
-// This gets called by functions before AOS_LOG(FATAL)ing with error messages
+// This gets called by functions before LOG(FATAL)ing with error messages
// that would be incorrect if the error was caused by a process forking without
// initialize_in_new_thread getting called in the fork.
void check_cached_tid(pid_t tid) {
pid_t actual = do_get_tid();
if (tid != actual) {
- AOS_LOG(FATAL,
- "task %jd forked into %jd without letting aos_sync know"
- " so we're not really sure what's going on\n",
- static_cast<intmax_t>(tid), static_cast<intmax_t>(actual));
+ LOG(FATAL) << "task " << static_cast<intmax_t>(tid) << " forked into "
+ << static_cast<intmax_t>(actual)
+ << " without letting aos_sync know so we're not really sure "
+ "what's going on";
}
}
@@ -378,9 +378,9 @@
}
void InstallAtforkHook() {
- if (pthread_atfork(NULL, NULL, atfork_child) != 0) {
- AOS_PLOG(FATAL, "pthread_atfork(NULL, NULL, %p) failed", atfork_child);
- }
+ PCHECK(pthread_atfork(NULL, NULL, &atfork_child) == 0)
+ << ": pthread_atfork(NULL, NULL, "
+ << reinterpret_cast<void *>(&atfork_child) << ") failed";
}
// This gets called to set everything up in a new thread by get_tid().
@@ -472,11 +472,10 @@
robust_head.futex_offset = static_cast<ssize_t>(offsetof(aos_mutex, futex)) -
static_cast<ssize_t>(offsetof(aos_mutex, next));
robust_head.pending_next = 0;
- if (syscall(SYS_set_robust_list, robust_head_next_value(), sizeof(robust_head)) !=
- 0) {
- AOS_PLOG(FATAL, "set_robust_list(%p, %zd) failed",
- reinterpret_cast<void *>(robust_head.next), sizeof(robust_head));
- }
+ PCHECK(syscall(SYS_set_robust_list, robust_head_next_value(),
+ sizeof(robust_head)) == 0)
+ << ": set_robust_list(" << reinterpret_cast<void *>(robust_head.next)
+ << ", " << sizeof(robust_head) << ") failed";
if (kRobustListDebug) {
printf("%" PRId32 ": init done\n", get_tid());
}
@@ -675,12 +674,12 @@
}
}
my_robust_list::robust_head.pending_next = 0;
- if (ret == -EDEADLK) {
- AOS_LOG(FATAL, "multiple lock of %p by %" PRId32 "\n", m, tid);
- }
- AOS_PELOG(FATAL, -ret, "FUTEX_LOCK_PI(%p(=%" PRIu32 "), 1, %p) failed",
- &m->futex, __atomic_load_n(&m->futex, __ATOMIC_SEQ_CST),
- timeout);
+ CHECK_NE(ret, -EDEADLK) << ": multiple lock of " << m << " by " << tid;
+
+ errno = -ret;
+ PLOG(FATAL) << "FUTEX_LOCK_PI(" << &m->futex
+ << "(=" << __atomic_load_n(&m->futex, __ATOMIC_SEQ_CST)
+ << "), 1, " << timeout << ") failed";
} else {
if (kLockDebug) {
printf("%" PRId32 ": %p kernel lock done\n", tid, m);
@@ -746,8 +745,9 @@
continue;
}
my_robust_list::robust_head.pending_next = 0;
- AOS_PELOG(FATAL, -ret, "FUTEX_CMP_REQUEUE_PI(%p, 1, %d, %p, *%p) failed",
- c, number_requeue, &m->futex, c);
+ errno = -ret;
+ PLOG(FATAL) << "FUTEX_CMP_REQUEUE_PI(" << c << ", 1, " << number_requeue
+ << ", " << &m->futex << ", *" << c << ") failed";
} else {
return;
}
@@ -778,11 +778,10 @@
my_robust_list::robust_head.pending_next = 0;
check_cached_tid(tid);
if ((value & FUTEX_TID_MASK) == 0) {
- AOS_LOG(FATAL, "multiple unlock of aos_mutex %p by %" PRId32 "\n", m,
- tid);
+ LOG(FATAL) << "multiple unlock of aos_mutex " << m << " by " << tid;
} else {
- AOS_LOG(FATAL, "aos_mutex %p is locked by %" PRId32 ", not %" PRId32 "\n",
- m, value & FUTEX_TID_MASK, tid);
+ LOG(FATAL) << "aos_mutex " << m << " is locked by "
+ << (value & FUTEX_TID_MASK) << ", not " << tid;
}
}
@@ -795,7 +794,8 @@
const int ret = sys_futex_unlock_pi(&m->futex);
if (ret != 0) {
my_robust_list::robust_head.pending_next = 0;
- AOS_PELOG(FATAL, -ret, "FUTEX_UNLOCK_PI(%p) failed", &m->futex);
+ errno = -ret;
+ PLOG(FATAL) << "FUTEX_UNLOCK_PI(" << (&m->futex) << ") failed";
}
} else {
// There aren't any waiters, so no need to call into the kernel.
@@ -832,8 +832,9 @@
return 4;
}
my_robust_list::robust_head.pending_next = 0;
- AOS_PELOG(FATAL, -ret, "FUTEX_TRYLOCK_PI(%p, 0, NULL) failed",
- &m->futex);
+ errno = -ret;
+ PLOG(FATAL) << "FUTEX_TRYLOCK_PI(" << (&m->futex)
+ << ", 0, NULL) failed";
}
}
}
@@ -898,9 +899,9 @@
continue;
}
my_robust_list::robust_head.pending_next = 0;
- AOS_PELOG(FATAL, -ret,
- "FUTEX_WAIT_REQUEUE_PI(%p, %" PRIu32 ", %p) failed", c,
- wait_start, &m->futex);
+ errno = -ret;
+ PLOG(FATAL) << "FUTEX_WAIT_REQUEUE_PI(" << c << ", " << wait_start << ", "
+ << (&m->futex) << ") failed";
} else {
// Record that the kernel relocked it for us.
lock_pthread_mutex(m);