From fc00c656c96528112d05cf0edf8631bd5eaea446 Mon Sep 17 00:00:00 2001 From: Kacper Date: Sun, 7 Dec 2025 20:10:31 +0100 Subject: Add build system scaffolding and libc headers --- include/arch/x86_64/asm/swab.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 include/arch/x86_64/asm/swab.h (limited to 'include/arch/x86_64/asm/swab.h') diff --git a/include/arch/x86_64/asm/swab.h b/include/arch/x86_64/asm/swab.h new file mode 100644 index 00000000..0324f00d --- /dev/null +++ b/include/arch/x86_64/asm/swab.h @@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _ASM_X86_SWAB_H +#define _ASM_X86_SWAB_H + +#include + +static __inline__ __u32 __arch_swab32(__u32 val) +{ + __asm__("bswapl %0" : "=r"(val) : "0"(val)); + return val; +} +#define __arch_swab32 __arch_swab32 + +static __inline__ __u64 __arch_swab64(__u64 val) +{ +#ifdef __i386__ + union { + struct { + __u32 a; + __u32 b; + } s; + __u64 u; + } v; + v.u = val; + __asm__("bswapl %0 ; bswapl %1 ; xchgl %0,%1" + : "=r"(v.s.a), "=r"(v.s.b) + : "0"(v.s.a), "1"(v.s.b)); + return v.u; +#else /* __i386__ */ + __asm__("bswapq %0" : "=r"(val) : "0"(val)); + return val; +#endif +} +#define __arch_swab64 __arch_swab64 + +#endif /* _ASM_X86_SWAB_H */ -- cgit v1.2.3