started getting stuff to compile for ARM
There were lots of places where the ARM compiler is pickier about
alignment and the externals stuff had to be reworked to use the cross
compiler for everything.
The main issues left are the lack of opencv and the x86 asm.
diff --git a/aos/atom_code/configuration.cc b/aos/atom_code/configuration.cc
index a5dd4ee..2d6dab8 100644
--- a/aos/atom_code/configuration.cc
+++ b/aos/atom_code/configuration.cc
@@ -35,7 +35,8 @@
if (addrs->ifa_addr->sa_family == AF_INET) {
if (strcmp(kAtomNetInterface, addrs->ifa_name) == 0) {
static const in_addr r =
- reinterpret_cast<sockaddr_in *>(addrs->ifa_addr)->sin_addr;
+ reinterpret_cast<sockaddr_in *>(__builtin_assume_aligned(
+ addrs->ifa_addr, alignof(sockaddr_in)))->sin_addr;
return &r;
}
}
diff --git a/aos/atom_code/core/LogFileCommon.h b/aos/atom_code/core/LogFileCommon.h
index 3798b06..8c1bd7b 100644
--- a/aos/atom_code/core/LogFileCommon.h
+++ b/aos/atom_code/core/LogFileCommon.h
@@ -132,15 +132,18 @@
sizeof(mutex) > kPageSize) {
char *const temp = current_;
MapNextPage();
- if (futex_set_value(reinterpret_cast<mutex *>(&temp[position_]), 2) == -1) {
- fprintf(stderr, "LogFileCommon: futex_set_value(%p, 2) failed with %d: %s."
- " readers will hang\n", &temp[position_], errno, strerror(errno));
+ if (futex_set_value(static_cast<mutex *>(static_cast<void *>(
+ &temp[position_])), 2) == -1) {
+ fprintf(stderr,
+ "LogFileCommon: futex_set_value(%p, 2) failed with %d: %s."
+ " readers will hang\n",
+ &temp[position_], errno, strerror(errno));
}
Unmap(temp);
position_ = 0;
}
- LogFileMessageHeader *const r = reinterpret_cast<LogFileMessageHeader *>(
- ¤t_[position_]);
+ LogFileMessageHeader *const r = static_cast<LogFileMessageHeader *>(
+ static_cast<void *>(¤t_[position_]));
position_ += message_size;
// keep it aligned for next time
position_ += kAlignment - (position_ % kAlignment);
@@ -150,7 +153,8 @@
const LogFileMessageHeader *ReadNextMessage(bool wait) {
LogFileMessageHeader *r;
do {
- r = reinterpret_cast<LogFileMessageHeader *>(¤t_[position_]);
+ r = static_cast<LogFileMessageHeader *>(
+ static_cast<void *>(¤t_[position_]));
if (wait) {
if (futex_wait(&r->marker) != 0) continue;
}
@@ -158,7 +162,7 @@
Unmap(current_);
MapNextPage();
position_ = 0;
- r = reinterpret_cast<LogFileMessageHeader *>(current_);
+ r = static_cast<LogFileMessageHeader *>(static_cast<void *>(current_));
}
} while (wait && r->marker == 0);
if (r->marker == 0) {
diff --git a/aos/atom_code/ipc_lib/queue.cc b/aos/atom_code/ipc_lib/queue.cc
index 7ab7b6c..018f03a 100644
--- a/aos/atom_code/ipc_lib/queue.cc
+++ b/aos/atom_code/ipc_lib/queue.cc
@@ -39,9 +39,9 @@
int ref_count;
int index; // in pool_
static MessageHeader *Get(const void *msg) {
- return reinterpret_cast<MessageHeader *>(
- static_cast<uint8_t *>(const_cast<void *>(msg)) -
- sizeof(MessageHeader));
+ return reinterpret_cast<MessageHeader *>(__builtin_assume_aligned(
+ static_cast<uint8_t *>(const_cast<void *>(msg)) - sizeof(MessageHeader),
+ alignof(MessageHeader)));
}
void Swap(MessageHeader *other) {
MessageHeader temp;