merging in the infrastructure to build a custom flasher
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;
diff --git a/aos/atom_code/starter/starter.cc b/aos/atom_code/starter/starter.cc
index 4534ebc..bef4e73 100644
--- a/aos/atom_code/starter/starter.cc
+++ b/aos/atom_code/starter/starter.cc
@@ -198,8 +198,9 @@
}
notifyevt = reinterpret_cast<inotify_event *>(
- reinterpret_cast<char *>(notifyevt) +
- sizeof(*notifyevt) + notifyevt->len);
+ __builtin_assume_aligned(reinterpret_cast<char *>(notifyevt) +
+ sizeof(*notifyevt) + notifyevt->len,
+ alignof(notifyevt)));
}
}
diff --git a/aos/build/aos.gypi b/aos/build/aos.gypi
index d8a4016..0f7d4b6 100644
--- a/aos/build/aos.gypi
+++ b/aos/build/aos.gypi
@@ -30,6 +30,10 @@
'aos_target': 'static_library',
},
}, {
+ 'make_global_settings': [
+ ['CC', '<!(which arm-linux-gnueabihf-gcc-4.7)'],
+ ['CXX', '<!(which arm-linux-gnueabihf-g++-4.7)'],
+ ],
'variables': {
'aos_target': 'executable',
},
@@ -90,8 +94,8 @@
],
}, {
'cflags': [
- '-march=atom',
- '-mfpmath=sse',
+ '-mcpu=cortex-a8',
+ '-mfpu=neon',
'-fstack-protector-all',
],
@@ -169,14 +173,9 @@
],
'ldflags': [
'-pthread',
- '-m32',
- ],
- 'library_dirs': [
- '/usr/lib32',
],
'cflags': [
'-pthread',
- '-m32',
'-Wunused-local-typedefs',
diff --git a/aos/build/download_externals.sh b/aos/build/download_externals.sh
index be77aa5..f33eced 100755
--- a/aos/build/download_externals.sh
+++ b/aos/build/download_externals.sh
@@ -4,6 +4,17 @@
AOS=$(readlink -f $(dirname $0)/..)
. $(dirname $0)/tools_config
+COMPILED=${EXTERNALS}/../compiled-arm
+
+export CC=arm-linux-gnueabihf-gcc-4.7
+export CXX=arm-linux-gnueabihf-g++-4.7
+export CFLAGS=-mcpu="cortex-a8 -mfpu=neon"
+export CXXFLAGS=-mcpu="cortex-a8 -mfpu=neon"
+export OBJDUMP=arm-linux-gnueabihf-objdump
+# Flags that should get passed to all configure scripts.
+# Some of them need to set LDFLAGS separately to work around stupid configure
+# scripts, so we can't just set that here.
+CONFIGURE_FLAGS="--host=arm-linux-gnueabihf CC=${CC} CXX=${CXX} CFLAGS=\"${CFLAGS}\" CXXFLAGS=\"${CXXFLAGS}\" OBJDUMP=${OBJDUMP}"
TMPDIR=/tmp/$$-aos-tmpdir
mkdir -p ${EXTERNALS}
@@ -11,7 +22,7 @@
# get and build ninja
[ -d ${NINJA_DIR} ] || git clone --branch ${NINJA_RELEASE} https://github.com/martine/ninja.git ${NINJA_DIR}
-[ -x ${NINJA} ] || ${NINJA_DIR}/bootstrap.py
+[ -x ${NINJA} ] || env -i "PATH=$PATH" ${NINJA_DIR}/bootstrap.py
# get gyp
[ -d ${GYP_DIR} ] || ( svn co http://gyp.googlecode.com/svn/trunk -r ${GYP_REVISION} ${GYP_DIR} && patch -p1 -d ${GYP_DIR} < ${AOS}/externals/gyp.patch )
@@ -41,14 +52,17 @@
# get and build libjpeg
LIBJPEG_VERSION=8d
-LIBJPEG_DIR=${EXTERNALS}/jpeg-${LIBJPEG_VERSION}
+LIBJPEG_DIR=${COMPILED}/jpeg-${LIBJPEG_VERSION}
# NOTE: this directory ends up in #include names
LIBJPEG_PREFIX=${COMPILED}/libjpeg
LIBJPEG_LIB=${LIBJPEG_PREFIX}/lib/libjpeg.a
LIBJPEG_TAR=${EXTERNALS}/jpegsrc.v${LIBJPEG_VERSION}.tar.gz
[ -f ${LIBJPEG_TAR} ] || wget http://www.ijg.org/files/jpegsrc.v${LIBJPEG_VERSION}.tar.gz -O ${LIBJPEG_TAR}
[ -d ${LIBJPEG_DIR} ] || ( mkdir ${LIBJPEG_DIR} && tar --strip-components=1 -C ${LIBJPEG_DIR} -xf ${LIBJPEG_TAR} )
-[ -f ${LIBJPEG_LIB} ] || env -i PATH="${PATH}" bash -c "cd ${LIBJPEG_DIR} && CFLAGS='-m32' ./configure --disable-shared --prefix=`readlink -f ${LIBJPEG_PREFIX}` && make && make install"
+[ -f ${LIBJPEG_LIB} ] || bash -c \
+ "cd ${LIBJPEG_DIR} && ./configure --disable-shared \
+ ${CONFIGURE_FLAGS} --prefix=`readlink -f ${LIBJPEG_PREFIX}` \
+ && make && make install"
# get gtest
GTEST_VERSION=1.6.0
@@ -77,10 +91,10 @@
[ -d ${CTEMPLATE_DIR} ] || \
svn checkout ${CTEMPLATE_URL} -r ${CTEMPLATE_VERSION} ${CTEMPLATE_DIR}
fi
-[ -f ${CTEMPLATE_LIB} ] || env -i PATH="${PATH}" \
- CFLAGS='-m32' CXXFLAGS='-m32' LDFLAGS='-m32' \
- bash -c "cd ${CTEMPLATE_DIR} && ./configure --disable-shared \
- --prefix=`readlink -f ${CTEMPLATE_PREFIX}` && make && make install"
+[ -f ${CTEMPLATE_LIB} ] || bash -c "cd ${CTEMPLATE_DIR} && \
+ ./configure --disable-shared \
+ ${CONFIGURE_FLAGS} --prefix=`readlink -f ${CTEMPLATE_PREFIX}` \
+ && make && make install"
# get and build gflags
GFLAGS_VERSION=2.0
@@ -92,10 +106,9 @@
[ -f ${GFLAGS_TAR} ] || wget ${GFLAGS_URL} -O ${GFLAGS_TAR}
[ -d ${GFLAGS_DIR} ] || ( mkdir ${GFLAGS_DIR} && tar \
--strip-components=1 -C ${GFLAGS_DIR} -xf ${GFLAGS_TAR} )
-[ -f ${GFLAGS_LIB} ] || env -i PATH="${PATH}" \
- CFLAGS='-m32' CXXFLAGS='-m32' LDFLAGS='-m32' \
- bash -c "cd ${GFLAGS_DIR} && ./configure \
- --prefix=`readlink -f ${GFLAGS_PREFIX}` && make && make install"
+[ -f ${GFLAGS_LIB} ] || bash -c "cd ${GFLAGS_DIR} && ./configure \
+ ${CONFIGURE_FLAGS} --prefix=`readlink -f ${GFLAGS_PREFIX}` \
+ && make && make install"
# get and build libusb
LIBUSB_VERSION=1.0.9
@@ -108,10 +121,9 @@
[ -f ${LIBUSB_TAR} ] || wget ${LIBUSB_URL} -O ${LIBUSB_TAR}
[ -d ${LIBUSB_DIR} ] || ( mkdir ${LIBUSB_DIR} && tar \
--strip-components=1 -C ${LIBUSB_DIR} -xf ${LIBUSB_TAR} )
-[ -f ${LIBUSB_LIB} ] || env -i PATH="${PATH}" \
- CFLAGS='-m32' CXXFLAGS='-m32' LDFLAGS='-m32' \
- bash -c "cd ${LIBUSB_DIR} && ./configure \
- --prefix=`readlink -f ${LIBUSB_PREFIX}` && make && make install"
+[ -f ${LIBUSB_LIB} ] || bash -c "cd ${LIBUSB_DIR} && ./configure \
+ ${CONFIGURE_FLAGS} --prefix=`readlink -f ${LIBUSB_PREFIX}` \
+ && make && make install"
# get the LLVM Compiler-RT source
COMPILER_RT_TAG=RELEASE_32/final
@@ -131,10 +143,23 @@
[ -f ${LIBEVENT_TAR} ] || wget ${LIBEVENT_URL} -O ${LIBEVENT_TAR}
[ -d ${LIBEVENT_DIR} ] || ( mkdir ${LIBEVENT_DIR} && tar \
--strip-components=1 -C ${LIBEVENT_DIR} -xf ${LIBEVENT_TAR} )
-[ -f ${LIBEVENT_LIB} ] || env -i PATH="${PATH}" \
- CFLAGS='-m32' CXXFLAGS='-m32' LDFLAGS='-m32' \
- bash -c "cd ${LIBEVENT_DIR} && ./configure \
- --prefix=`readlink -f ${LIBEVENT_PREFIX}` && make && make install"
+[ -f ${LIBEVENT_LIB} ] || bash -c "cd ${LIBEVENT_DIR} && ./configure \
+ ${CONFIGURE_FLAGS} --prefix=`readlink -f ${LIBEVENT_PREFIX}` \
+ && make && make install"
+
+# get and build gmp
+GMP_VERSION=5.1.3
+GMP_TAR=${EXTERNALS}/gmp-${GMP_VERSION}.tar.lz
+GMP_DIR=${COMPILED}/gmp-${GMP_VERSION}
+GMP_PREFIX=${GMP_DIR}-prefix
+GMP_LIB=${GMP_PREFIX}/lib/libgmp.a
+GMP_URL=http://ftp.gmplib.org/gmp/gmp-${GMP_VERSION}.tar.lz
+[ -f ${GMP_TAR} ] || wget ${GMP_URL} -O ${GMP_TAR}
+[ -d ${GMP_DIR} ] || ( mkdir ${GMP_DIR} && tar \
+ --strip-components=1 -C ${GMP_DIR} -xf ${GMP_TAR} )
+[ -f ${GMP_LIB} ] || bash -c "cd ${GMP_DIR} && ./configure \
+ ${CONFIGURE_FLAGS} --prefix=$(readlink -f ${GMP_PREFIX}) \
+ && make && make install"
# get and build libcdd
LIBCDD_VERSION=094g
@@ -147,9 +172,10 @@
wget ${LIBCDD_URL} -O ${LIBCDD_TAR}
[ -d ${LIBCDD_DIR} ] || ( mkdir ${LIBCDD_DIR} && tar \
--strip-components=1 -C ${LIBCDD_DIR} -xf ${LIBCDD_TAR} )
-[ -f ${LIBCDD_LIB} ] || env -i PATH="${PATH}" \
- CFLAGS='-m32' CXXFLAGS='-m32' LDFLAGS='-m32' \
- bash -c "cd ${LIBCDD_DIR} && ./configure --disable-shared \
- --prefix=`readlink -f ${LIBCDD_PREFIX}` && make && make install"
+[ -f ${LIBCDD_LIB} ] || LDFLAGS=-L${GMP_PREFIX}/lib \
+ bash -c "cd ${LIBCDD_DIR} && ./configure \
+ --disable-shared ${CONFIGURE_FLAGS} \
+ --prefix=$(readlink -f ${LIBCDD_PREFIX}) \
+ && make gmpdir=${GMP_PREFIX} && make install"
rm -rf ${TMPDIR}
diff --git a/aos/build/externals.gyp b/aos/build/externals.gyp
index 283e7ce..836ddde 100644
--- a/aos/build/externals.gyp
+++ b/aos/build/externals.gyp
@@ -4,8 +4,8 @@
'variables': {
'externals': '<(AOS)/../output/downloaded',
'externals_abs': '<!(readlink -f ../../output/downloaded)',
- 'compiled': '<(externals)/../compiled-i386',
- 'compiled_abs': '<(externals_abs)/../compiled-i386',
+ 'compiled': '<(externals)/../compiled-arm',
+ 'compiled_abs': '<(externals_abs)/../compiled-arm',
# These versions have to be kept in sync with the ones in download_externals.sh.
'eigen_version': '3.1.3',
@@ -211,6 +211,9 @@
},
'direct_dependent_settings': {
'include_dirs': ['<(compiled)/libusb-<(libusb_version)-prefix/include'],
+ 'cflags': [
+ '-Wno-error=cast-align',
+ ],
},
},
{
diff --git a/aos/build/tools_config b/aos/build/tools_config
index 653c1ef..d47a3ce 100644
--- a/aos/build/tools_config
+++ b/aos/build/tools_config
@@ -2,7 +2,6 @@
# that download_externals.sh downloads so build.sh can use.
EXTERNALS=${AOS}/../output/downloaded
-COMPILED=${EXTERNALS}/../compiled-i386
NINJA_RELEASE=v1.4.0
NINJA_DIR=${EXTERNALS}/ninja-${NINJA_RELEASE}
diff --git a/aos/common/logging/logging_impl.cc b/aos/common/logging/logging_impl.cc
index bced835..a76c28a 100644
--- a/aos/common/logging/logging_impl.cc
+++ b/aos/common/logging/logging_impl.cc
@@ -57,8 +57,8 @@
const size_t size = output_size - strlen(continued);
const int ret = vsnprintf(output, size, format, ap);
if (ret < 0) {
- LOG(FATAL, "vsnprintf(%p, %zd, %s, %p) failed with %d (%s)\n",
- output, size, format, ap, errno, strerror(errno));
+ LOG(FATAL, "vsnprintf(%p, %zd, %s, args) failed with %d (%s)\n",
+ output, size, format, errno, strerror(errno));
} else if (static_cast<uintmax_t>(ret) >= static_cast<uintmax_t>(size)) {
// Overwrite the '\0' at the end of the existing data and
// copy in the one on the end of continued.
diff --git a/output/downloaded/.gitignore b/output/downloaded/.gitignore
index c45531d..079a15e 100644
--- a/output/downloaded/.gitignore
+++ b/output/downloaded/.gitignore
@@ -23,3 +23,4 @@
/libevent-2.0.21/
/libcdd-094g.tar.gz
/libcdd-094g/
+/gmp-5.1.3.tar.lz