diff options
| author | Kacper <kacper@mail.openlinux.dev> | 2025-12-07 20:10:31 +0100 |
|---|---|---|
| committer | Kacper <kacper@mail.openlinux.dev> | 2025-12-07 20:10:31 +0100 |
| commit | fc00c656c96528112d05cf0edf8631bd5eaea446 (patch) | |
| tree | a6e0e6c588191a8bd1c64afc3b7a258e3e66c236 /include/arch/x86_64/asm/swab.h | |
Add build system scaffolding and libc headers
Diffstat (limited to 'include/arch/x86_64/asm/swab.h')
| -rw-r--r-- | include/arch/x86_64/asm/swab.h | 36 |
1 files changed, 36 insertions, 0 deletions
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 <linux/types.h> + +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 */ |
