kexec/kexec.h: Bring put/get_unaligned() back from the dead.
Subsystems (2)
PATCH 1/1 kexec/kexec.h: Bring put/get_unaligned() back from the dead.
This re-enables the fairly generic put/get_unaligned() routines in kexec.h, while tidying up the variable shadowing clash that results when using it in places like machine_apply_elf_rel().
Needed for SH ELF relocations.
IA64 still does its own put_unaligned64(), which should likely also be converted over to using put_unaligned() directly.
---
kexec/kexec.h | 21 ++++++++++----------- 1 files changed, 10 insertions(+), 11 deletions(-)
kexec/kexec.h +10 -11
@@ -6,6 +6,7 @@#include <sys/types.h> #include <stdio.h> #include <stdint.h> +#include <string.h> #define USE_BSD #include <byteswap.h> #include <endian.h>
@@ -56,43 +57,41 @@#endif -#if 0 /* -* This function doesn't actually exist. The idea is that when someone uses the macros -* below with an unsupported size (datatype), the linker will alert us to the problem via -* an unresolved reference error. +* This function doesn't actually exist. The idea is that when someone +* uses the macros below with an unsupported size (datatype), the linker +* will alert us to the problem via an unresolved reference error. */ extern unsigned long bad_unaligned_access_length (void );#define get_unaligned (loc) \ ({ \ - __typeof__(*(loc)) value; \ + __typeof__(*(loc)) _v; \ size_t size = sizeof(*(loc)); \ switch(size) { \ case 1: case 2: case 4: case 8: \ - memcpy(&value, (loc), size); \ + memcpy(&_v, (loc), size); \ break; \ default: \ - value = bad_unaligned_access_length(); \ + _v = bad_unaligned_access_length(); \ break; \ } \ - value; \ + _v; \ })#define put_unaligned (value, loc) \ do { \ size_t size = sizeof(*(loc)); \ - __typeof__(*(loc)) val = value; \ + __typeof__(*(loc)) _v = value; \ switch(size) { \ case 1: case 2: case 4: case 8: \ - memcpy((loc), &val, size); \ + memcpy((loc), &_v, size); \ break; \ default: \ bad_unaligned_access_length(); \ break; \ } \ } while(0) -#endif extern unsigned long long mem_min, mem_max;
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Quoted 8 lines · Paul Mundt
This re-enables the fairly generic put/get_unaligned() routines in
kexec.h, while tidying up the variable shadowing clash that results when using it in places likemachine_apply_elf_rel().Needed for SH ELF relocations.
IA64 still does its own
put_unaligned64(), which should likely also be converted over to usingput_unaligned()directly.
Thanks Paul, applied.
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec