Architectures like SuperARM or Xscale needs aligned data for multi-byte operations. GCC can create instructions sequences for packed data, but must know that something will not be aligned. Since list_add will operate on untyped data over void-pointers it cannot know that hna_global_entry is packed and will create only a fast and unsafe version for load and store operations. It is only important for the first 5 bytes of hna_global_entry to be packed we can force these elements to be aligned without changing the relative addresses of the first bytes.
Signed-off-by: Sven Eckelmann sven.eckelmann@gmx.de --- batman/batman.h | 1 + batman/hna.h | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/batman/batman.h b/batman/batman.h index d6b00cf..23f8e9a 100644 --- a/batman/batman.h +++ b/batman/batman.h @@ -153,6 +153,7 @@
#define BATMANUNUSED(x) (x)__attribute__((unused)) #define ALIGN_WORD __attribute__ ((aligned(sizeof(TYPE_OF_WORD)))) +#define ALIGN_POINTER __attribute__ ((aligned(sizeof(void*))))
diff --git a/batman/hna.h b/batman/hna.h index 6063324..a046857 100644 --- a/batman/hna.h +++ b/batman/hna.h @@ -58,8 +58,8 @@ struct hna_global_entry { uint32_t addr; uint8_t netmask; - struct orig_node *curr_orig_node; - struct list_head_first orig_list; + struct orig_node *curr_orig_node ALIGN_POINTER; + struct list_head_first orig_list ALIGN_POINTER; } __attribute__((packed));
struct hna_orig_ptr