diff options
author | Ben Peddell <klightspeed@killerwolves.net> | 2013-01-27 15:45:43 +1000 |
---|---|---|
committer | David Sterba <dsterba@suse.cz> | 2013-01-28 18:06:43 +0100 |
commit | 7b668965f0cf3fb8632c505a7a011189ee1a5a8e (patch) | |
tree | ed4755aba4bd2c26a232545dc2d636ac83835251 /ctree.h | |
parent | 272c04915252c497c64fd4036b601b82c3368bbd (diff) |
btrfs-progs: fix unaligned accesses v2
gcc optimizes out the memcpy calls at -O2 and -Os.
Replacing memcpy with memmove does't work - gcc treats memmove
the same way it treats memcpy.
This patch brings in {get|put}_unaligned_le{16|32|64} (using the
packed struct method), and uses them in the failing get/set calls.
On architectures where unaligned accesses are cheap, these unaligned
macros should be optimized out by the compiler.
Signed-off-by: Ben Peddell <klightspeed@killerwolves.net>
Diffstat (limited to 'ctree.h')
-rw-r--r-- | ctree.h | 8 |
1 files changed, 2 insertions, 6 deletions
@@ -1086,19 +1086,15 @@ static inline u##bits btrfs_##name(struct extent_buffer *eb, \ type *s) \ { \ unsigned long offset = (unsigned long)s; \ - u##bits m; \ type *p = (type *) (eb->data + offset); \ - memcpy(&m, &p->member, sizeof(m)); \ - return le##bits##_to_cpu(m); \ + return get_unaligned_le##bits(&p->member); \ } \ static inline void btrfs_set_##name(struct extent_buffer *eb, \ type *s, u##bits val) \ { \ unsigned long offset = (unsigned long)s; \ - u##bits m; \ type *p = (type *) (eb->data + offset); \ - m = cpu_to_le##bits(val); \ - memcpy(&p->member, &m, sizeof(m)); \ + put_unaligned_le##bits(val, &p->member); \ } #define BTRFS_SETGET_STACK_FUNCS(name, type, member, bits) \ |