summaryrefslogtreecommitdiff
path: root/include/linux/bitrev.h
blob: d35b8ec1c485cba58a658b34edd2f9621cd20639 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _LINUX_BITREV_H
#define _LINUX_BITREV_H

#include <linux/types.h>

#ifdef CONFIG_HAVE_ARCH_BITREVERSE
#include <asm/bitrev.h>

#define __bitrev32 __arch_bitrev32
#define __bitrev16 __arch_bitrev16
#define __bitrev8 __arch_bitrev8

#else
extern u8 const byte_rev_table[256];
static inline u8 __bitrev8(u8 byte)
{
	return byte_rev_table[byte];
}

static inline u16 __bitrev16(u16 x)
{
	return (__bitrev8(x & 0xff) << 8) | __bitrev8(x >> 8);
}

static inline u32 __bitrev32(u32 x)
{
	return (__bitrev16(x & 0xffff) << 16) | __bitrev16(x >> 16);
}

#endif /* CONFIG_HAVE_ARCH_BITREVERSE */

#define __bitrev8x4(x)	(__bitrev32(swab32(x)))

#define __constant_bitrev32(x)	\
({					\
	u32 ___x = x;			\
	___x = (___x >> 16) | (___x << 16);	\
	___x = ((___x & (u32)0xFF00FF00UL) >> 8) | ((___x & (u32)0x00FF00FFUL) << 8);	\
	___x = ((___x & (u32)0xF0F0F0F0UL) >> 4) | ((___x & (u32)0x0F0F0F0FUL) << 4);	\
	___x = ((___x & (u32)0xCCCCCCCCUL) >> 2) | ((___x & (u32)0x33333333UL) << 2);	\
	___x = ((___x & (u32)0xAAAAAAAAUL) >> 1) | ((___x & (u32)0x55555555UL) << 1);	\
	___x;								\
})

#define __constant_bitrev16(x)	\
({					\
	u16 ___x = x;			\
	___x = (___x >> 8) | (___x << 8);	\
	___x = ((___x & (u16)0xF0F0U) >> 4) | ((___x & (u16)0x0F0FU) << 4);	\
	___x = ((___x & (u16)0xCCCCU) >> 2) | ((___x & (u16)0x3333U) << 2);	\
	___x = ((___x & (u16)0xAAAAU) >> 1) | ((___x & (u16)0x5555U) << 1);	\
	___x;								\
})

#define __constant_bitrev8x4(x) \
({			\
	u32 ___x = x;	\
	___x = ((___x & (u32)0xF0F0F0F0UL) >> 4) | ((___x & (u32)0x0F0F0F0FUL) << 4);	\
	___x = ((___x & (u32)0xCCCCCCCCUL) >> 2) | ((___x & (u32)0x33333333UL) << 2);	\
	___x = ((___x & (u32)0xAAAAAAAAUL) >> 1) | ((___x & (u32)0x55555555UL) << 1);	\
	___x;								\
})

#define __constant_bitrev8(x)	\
({					\
	u8 ___x = x;			\
	___x = (___x >> 4) | (___x << 4);	\
	___x = ((___x & (u8)0xCCU) >> 2) | ((___x & (u8)0x33U) << 2);	\
	___x = ((___x & (u8)0xAAU) >> 1) | ((___x & (u8)0x55U) << 1);	\
	___x;								\
})

#define bitrev32(x) \
({			\
	u32 __x = x;	\
	__builtin_constant_p(__x) ?	\
	__constant_bitrev32(__x) :			\
	__bitrev32(__x);				\
})

#define bitrev16(x) \
({			\
	u16 __x = x;	\
	__builtin_constant_p(__x) ?	\
	__constant_bitrev16(__x) :			\
	__bitrev16(__x);				\
 })

#define bitrev8x4(x) \
({			\
	u32 __x = x;	\
	__builtin_constant_p(__x) ?	\
	__constant_bitrev8x4(__x) :			\
	__bitrev8x4(__x);				\
 })

#define bitrev8(x) \
({			\
	u8 __x = x;	\
	__builtin_constant_p(__x) ?	\
	__constant_bitrev8(__x) :			\
	__bitrev8(__x)	;			\
 })
#endif /* _LINUX_BITREV_H */
Unnamed repository; edit this file to name it for gitweb.root
summaryrefslogtreecommitdiff
path: root/source
AgeCommit message (Expand)AuthorFilesLines
23 hoursupdate translations for master / 25.2HEADmasterChristian Lohmaier2023-147733/+144174
10 daysadd translation files for Santali (Ol-Chiki) (sat-Olck)Christian Lohmaier158-0/+284480
10 daysupdate translations for master/25.2.0 alpha1Christian Lohmaier1216-130450/+143164
11 daysUpdated Slovenian translationMartin Srebotnjak64-13501/+19617
13 daysupdate translations for master / 25.2 alpha1Christian Lohmaier1934-72263/+100204
2024-11-05update translations for masterChristian Lohmaier2013-339716/+413548
2024-10-25update translations for masterChristian Lohmaier248-8678/+9001
2024-10-23add Tagalog (tl) translationsChristian Lohmaier220-0/+789621
2024-10-23update translations for masterChristian Lohmaier1725-190947/+231197
2024-10-04update translations for masterChristian Lohmaier2839-243555/+298302
2024-09-17update translations for masterChristian Lohmaier4999-1016811/+1482054
2024-09-06update translations for 24.8.1 rc2Christian Lohmaier294-4826/+4802
2024-08-23update translations for 24.8.1 rc1Christian Lohmaier464-7996/+9278
2024-08-08update translations for 24.8.0 rc3Christian Lohmaier330-7999/+7194
2024-07-26update translations for 24.8.0 rc2/masterChristian Lohmaier78-778/+848
2024-07-24update translations for 24.8.0 rc2Christian Lohmaier334-5629/+5300
2024-07-15update translations for master/24-8Christian Lohmaier449-6941/+7245
2024-07-08update translations for 24.8.0 rc1/masterChristian Lohmaier752-13300/+15854
2024-07-07Updated Slovenian translationMartin Srebotnjak40-2210/+2458
2024-06-28update translations for 24.8/masterChristian Lohmaier1401-55124/+51822
2024-06-20update translations for 24-8/masterChristian Lohmaier696-19433/+27756
2024-06-20Updated Slovenian translationMartin Srebotnjak39-1188/+1555
2024-06-17update translations for 24-8/masterChristian Lohmaier888-57427/+58764
2024-06-11update translations for master / 24.8.0 beta1libreoffice-24-8-branch-pointChristian Lohmaier1034-10831/+33947
2024-06-06update translations for master / 24.8.0 beta1Christian Lohmaier897-61626/+70322
2024-06-03update translations for masterChristian Lohmaier