blob: ce436582e46d4f1db157a7fa1e949e7a99fdf38d [file] [log] [blame]
Elliott Hughes180edef2023-11-02 00:08:05 +00001/*
2 * This file is auto-generated. Modifications will be lost.
3 *
4 * See https://android.googlesource.com/platform/bionic/+/master/libc/kernel/
5 * for more information.
6 */
Elliott Hughesabd62612013-11-08 11:45:48 -08007#ifndef _ASM_X86_SWAB_H
8#define _ASM_X86_SWAB_H
9#include <linux/types.h>
10#include <linux/compiler.h>
Elliott Hughes8b956402024-10-28 17:51:26 +000011static inline __attribute__((__const__)) __u32 __arch_swab32(__u32 val) {
12 asm("bswapl %0" : "=r" (val) : "0" (val));
13 return val;
14}
Elliott Hughesabd62612013-11-08 11:45:48 -080015#define __arch_swab32 __arch_swab32
Elliott Hughes8b956402024-10-28 17:51:26 +000016static inline __attribute__((__const__)) __u64 __arch_swab64(__u64 val) {
Elliott Hughesabd62612013-11-08 11:45:48 -080017#ifdef __i386__
Elliott Hughes8b956402024-10-28 17:51:26 +000018 union {
19 struct {
20 __u32 a;
21 __u32 b;
22 } s;
23 __u64 u;
24 } v;
25 v.u = val;
26 asm("bswapl %0; bswapl %1; xchgl %0,%1" : "=r" (v.s.a), "=r" (v.s.b) : "0" (v.s.a), "1" (v.s.b));
27 return v.u;
Elliott Hughesabd62612013-11-08 11:45:48 -080028#else
Elliott Hughes8b956402024-10-28 17:51:26 +000029 asm("bswapq %0" : "=r" (val) : "0" (val));
30 return val;
Elliott Hughesabd62612013-11-08 11:45:48 -080031#endif
Elliott Hughes8b956402024-10-28 17:51:26 +000032}
Elliott Hughesabd62612013-11-08 11:45:48 -080033#define __arch_swab64 __arch_swab64
34#endif