Elliott Hughes | 180edef | 2023-11-02 00:08:05 +0000 | [diff] [blame] | 1 | /* |
| 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 Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 7 | #ifndef _ASM_X86_SWAB_H |
| 8 | #define _ASM_X86_SWAB_H |
| 9 | #include <linux/types.h> |
| 10 | #include <linux/compiler.h> |
Elliott Hughes | 8b95640 | 2024-10-28 17:51:26 +0000 | [diff] [blame] | 11 | static inline __attribute__((__const__)) __u32 __arch_swab32(__u32 val) { |
| 12 | asm("bswapl %0" : "=r" (val) : "0" (val)); |
| 13 | return val; |
| 14 | } |
Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 15 | #define __arch_swab32 __arch_swab32 |
Elliott Hughes | 8b95640 | 2024-10-28 17:51:26 +0000 | [diff] [blame] | 16 | static inline __attribute__((__const__)) __u64 __arch_swab64(__u64 val) { |
Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 17 | #ifdef __i386__ |
Elliott Hughes | 8b95640 | 2024-10-28 17:51:26 +0000 | [diff] [blame] | 18 | 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 Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 28 | #else |
Elliott Hughes | 8b95640 | 2024-10-28 17:51:26 +0000 | [diff] [blame] | 29 | asm("bswapq %0" : "=r" (val) : "0" (val)); |
| 30 | return val; |
Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 31 | #endif |
Elliott Hughes | 8b95640 | 2024-10-28 17:51:26 +0000 | [diff] [blame] | 32 | } |
Elliott Hughes | abd6261 | 2013-11-08 11:45:48 -0800 | [diff] [blame] | 33 | #define __arch_swab64 __arch_swab64 |
| 34 | #endif |