From 7047a200aff01fff2d4ac4d6f5d388f6344d9d48 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Mon, 2 Sep 2019 13:23:30 +0200 Subject: [PATCH 1/3] cpu/native: advertise support for unaligned memory access On Linux, even if the architecture does not support it, the kernel will catch the fault and emulate the unaligned accesss. --- cpu/native/include/cpu.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cpu/native/include/cpu.h b/cpu/native/include/cpu.h index b1641642c4..ff38639fd5 100644 --- a/cpu/native/include/cpu.h +++ b/cpu/native/include/cpu.h @@ -26,6 +26,12 @@ extern "C" { #endif +/** + * @brief The CPU supports unaligned memory access. + * Even if the underlying architecture does not support it, the kernel will take care of it. + */ +#define CPU_HAS_UNALIGNED_ACCESS + /** * @brief Prints the address the callee will return to */ From bf410c84f15471ede2bd6c6cab63f879d5e4e6a0 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Sun, 1 Sep 2019 17:25:58 +0200 Subject: [PATCH 2/3] pkg/libb2: define HAVE_ALIGNED_ACCESS_REQUIRED based on CPU Most architectures do not support unaligned memory access, so set the define accordingly. --- pkg/libb2/include/config.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/libb2/include/config.h b/pkg/libb2/include/config.h index 55cc6a0e8e..75e6d3aeb4 100644 --- a/pkg/libb2/include/config.h +++ b/pkg/libb2/include/config.h @@ -1,6 +1,8 @@ #ifndef CONFIG_H #define CONFIG_H +#include "cpu.h" + #ifdef __cplusplus extern "C" { #endif @@ -13,6 +15,10 @@ extern "C" { #define NATIVE_LITTLE_ENDIAN #endif +#ifndef CPU_HAS_UNALIGNED_ACCESS +#define HAVE_ALIGNED_ACCESS_REQUIRED +#endif + #ifdef __cplusplus } #endif From 4707f6b74920a672e4ed23d0d2ddc1a30811bfb0 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Sun, 1 Sep 2019 17:26:37 +0200 Subject: [PATCH 3/3] pkg/libb2: rename config.h to libb2_config.h This is to avoid conflics with other config.h files, e.g. when building for esp8266 where $(NEWLIB)/xtensa-lx106-elf/include/config.h gets included instead. --- pkg/libb2/include/{config.h => libb2_config.h} | 6 +++--- .../0001-rename-config.h-to-libb2_config.h.patch | Bin 0 -> 698 bytes 2 files changed, 3 insertions(+), 3 deletions(-) rename pkg/libb2/include/{config.h => libb2_config.h} (82%) create mode 100644 pkg/libb2/patches/0001-rename-config.h-to-libb2_config.h.patch diff --git a/pkg/libb2/include/config.h b/pkg/libb2/include/libb2_config.h similarity index 82% rename from pkg/libb2/include/config.h rename to pkg/libb2/include/libb2_config.h index 75e6d3aeb4..025e093d68 100644 --- a/pkg/libb2/include/config.h +++ b/pkg/libb2/include/libb2_config.h @@ -1,5 +1,5 @@ -#ifndef CONFIG_H -#define CONFIG_H +#ifndef LIBB2_CONFIG_H +#define LIBB2_CONFIG_H #include "cpu.h" @@ -22,4 +22,4 @@ extern "C" { #ifdef __cplusplus } #endif -#endif /* CONFIG_H */ +#endif /* LIBB2_CONFIG_H */ diff --git a/pkg/libb2/patches/0001-rename-config.h-to-libb2_config.h.patch b/pkg/libb2/patches/0001-rename-config.h-to-libb2_config.h.patch new file mode 100644 index 0000000000000000000000000000000000000000..f7e270bfef43d37eadf7eb43bcafe4e0b752d797 GIT binary patch literal 698 zcmZvYQES^U6oudQD=x`PgJV}xTst-;IPF?CmO>$+FJlDRy0+EXQm~aSh5h&`E^XNo z5JLCp-0xn_eP>$WY*t2j9wkY{*;Od!2~GGFgA?D?57BL=Ega@NxjXPj5P?`=0 zIHio-J4^~UsGmivG(3q0wRMl{9Q95Wg~=*oss>x3nxHW4f_xDcQ&{iy6xhJzlqC+F za+cBvJnFb)z0aSquqpg_TyAc^{)7&-Xb}pdOH~CmfHlylJm=eYiI7dLdJr#0$$l_4 zs_5ajvNaf6WB1uyss?-F`#yobD=za!{6g-lcGo!aAK>7*9|lJo6t&P5%Hy(1_t;rw z^o2J$))E^WN`FF#RAmXiUnvXX@|2pNYD8&?2Pl#RXA*-z%p=Y*21aQVhR5~Jk%;Gc zaE_K`;InudgE!n+MqsRT(d;F{b#JA_GN>2-iAviOu~XV5ydeHZ`{+I65%E67f8!q! zaBMe3X@r~A^7|d%etURaZEu&Gi^KGF0tXn6;q|=f?rFJtbDiyVVF2L)rvW46FR{zd A