blob: 3fff953f7b3da331e3111860f7578ad37c8e5161 [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 */
Ben Chenga6b53f02013-11-06 15:51:05 -08007#ifndef _UAPI__ASM_ARM_SWAB_H
8#define _UAPI__ASM_ARM_SWAB_H
9#include <linux/compiler.h>
10#include <linux/types.h>
Ben Chenga6b53f02013-11-06 15:51:05 -080011#ifndef __STRICT_ANSI__
12#define __SWAB_64_THRU_32__
13#endif
Elliott Hughes8b956402024-10-28 17:51:26 +000014static inline __attribute__((__const__)) __u32 __arch_swab32(__u32 x) {
15 __u32 t;
Ben Chenga6b53f02013-11-06 15:51:05 -080016#ifndef __thumb__
Elliott Hughes8b956402024-10-28 17:51:26 +000017 if(! __builtin_constant_p(x)) {
18 asm("eor\t%0, %1, %1, ror #16" : "=r" (t) : "r" (x));
19 } else
Ben Chenga6b53f02013-11-06 15:51:05 -080020#endif
Elliott Hughes8b956402024-10-28 17:51:26 +000021 t = x ^ ((x << 16) | (x >> 16));
22 x = (x << 24) | (x >> 8);
23 t &= ~0x00FF0000;
24 x ^= (t >> 8);
25 return x;
26}
Ben Chenga6b53f02013-11-06 15:51:05 -080027#define __arch_swab32 __arch_swab32
28#endif