cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

unaligned.h (701B)


      1/* SPDX-License-Identifier: GPL-2.0-or-later */
      2/*
      3 * Copied from the kernel sources to tools/perf/:
      4 */
      5
      6#ifndef __TOOLS_LINUX_ASM_GENERIC_UNALIGNED_H
      7#define __TOOLS_LINUX_ASM_GENERIC_UNALIGNED_H
      8
      9#define __get_unaligned_t(type, ptr) ({						\
     10	const struct { type x; } __packed *__pptr = (typeof(__pptr))(ptr);	\
     11	__pptr->x;								\
     12})
     13
     14#define __put_unaligned_t(type, val, ptr) do {					\
     15	struct { type x; } __packed *__pptr = (typeof(__pptr))(ptr);		\
     16	__pptr->x = (val);							\
     17} while (0)
     18
     19#define get_unaligned(ptr)	__get_unaligned_t(typeof(*(ptr)), (ptr))
     20#define put_unaligned(val, ptr) __put_unaligned_t(typeof(*(ptr)), (val), (ptr))
     21
     22#endif /* __TOOLS_LINUX_ASM_GENERIC_UNALIGNED_H */
     23