Add helper functions for easier unaligned memory access.
* include/grub/types.h (grub_get_unaligned16): New function. (grub_get_unaligned32): Likewise. (grub_get_unaligned64): Likewise.
This commit is contained in:
parent
1f1a380be9
commit
b2d7e331e2
2 changed files with 35 additions and 0 deletions
|
@ -1,3 +1,11 @@
|
|||
2001-08-14 Szymon Janc <szymon@janc.net.pl>
|
||||
|
||||
Add helper functions for easier unaligned memory access.
|
||||
|
||||
* include/grub/types.h (grub_get_unaligned16): New function.
|
||||
(grub_get_unaligned32): Likewise.
|
||||
(grub_get_unaligned64): Likewise.
|
||||
|
||||
2011-08-14 Szymon Janc <szymon@janc.net.pl>
|
||||
|
||||
Import minilzo library for LZO decompression support.
|
||||
|
|
|
@ -222,4 +222,31 @@ static inline grub_uint64_t grub_swap_bytes64(grub_uint64_t x)
|
|||
# define grub_cpu_to_le32_compile_time(x) ((grub_uint32_t) (x))
|
||||
#endif /* ! WORDS_BIGENDIAN */
|
||||
|
||||
static inline grub_uint16_t grub_get_unaligned16(void *ptr)
|
||||
{
|
||||
struct
|
||||
{
|
||||
grub_uint16_t d;
|
||||
} __attribute__((packed)) *dd = ptr;
|
||||
return dd->d;
|
||||
}
|
||||
|
||||
static inline grub_uint32_t grub_get_unaligned32(void *ptr)
|
||||
{
|
||||
struct
|
||||
{
|
||||
grub_uint32_t d;
|
||||
} __attribute__((packed)) *dd = ptr;
|
||||
return dd->d;
|
||||
}
|
||||
|
||||
static inline grub_uint64_t grub_get_unaligned64(void *ptr)
|
||||
{
|
||||
struct
|
||||
{
|
||||
grub_uint64_t d;
|
||||
} __attribute__((packed)) *dd = ptr;
|
||||
return dd->d;
|
||||
}
|
||||
|
||||
#endif /* ! GRUB_TYPES_HEADER */
|
||||
|
|
Loading…
Reference in a new issue