Skip to content

Commit bc2736f

Browse files
committed
lib/crc32: don't bother with pure and const function attributes
Drop the use of __pure and __attribute_const__ from the CRC32 library functions that had them. Both of these are unusual optimizations that don't help properly written code. They seem more likely to cause problems than have any real benefit. Reviewed-by: Ard Biesheuvel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Eric Biggers <[email protected]>
1 parent 2d7da4f commit bc2736f

File tree

4 files changed

+27
-29
lines changed

4 files changed

+27
-29
lines changed

arch/arm64/lib/crc32-glue.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ asmlinkage u32 crc32_le_arm64_4way(u32 crc, unsigned char const *p, size_t len);
2222
asmlinkage u32 crc32c_le_arm64_4way(u32 crc, unsigned char const *p, size_t len);
2323
asmlinkage u32 crc32_be_arm64_4way(u32 crc, unsigned char const *p, size_t len);
2424

25-
u32 __pure crc32_le_arch(u32 crc, const u8 *p, size_t len)
25+
u32 crc32_le_arch(u32 crc, const u8 *p, size_t len)
2626
{
2727
if (!alternative_has_cap_likely(ARM64_HAS_CRC32))
2828
return crc32_le_base(crc, p, len);
@@ -43,7 +43,7 @@ u32 __pure crc32_le_arch(u32 crc, const u8 *p, size_t len)
4343
}
4444
EXPORT_SYMBOL(crc32_le_arch);
4545

46-
u32 __pure crc32c_le_arch(u32 crc, const u8 *p, size_t len)
46+
u32 crc32c_le_arch(u32 crc, const u8 *p, size_t len)
4747
{
4848
if (!alternative_has_cap_likely(ARM64_HAS_CRC32))
4949
return crc32c_le_base(crc, p, len);
@@ -64,7 +64,7 @@ u32 __pure crc32c_le_arch(u32 crc, const u8 *p, size_t len)
6464
}
6565
EXPORT_SYMBOL(crc32c_le_arch);
6666

67-
u32 __pure crc32_be_arch(u32 crc, const u8 *p, size_t len)
67+
u32 crc32_be_arch(u32 crc, const u8 *p, size_t len)
6868
{
6969
if (!alternative_has_cap_likely(ARM64_HAS_CRC32))
7070
return crc32_be_base(crc, p, len);

arch/riscv/lib/crc32-riscv.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,9 @@ static inline u32 crc32_le_unaligned(u32 crc, unsigned char const *p,
175175
return crc;
176176
}
177177

178-
static inline u32 __pure crc32_le_generic(u32 crc, unsigned char const *p,
179-
size_t len, u32 poly,
180-
unsigned long poly_qt,
181-
fallback crc_fb)
178+
static inline u32 crc32_le_generic(u32 crc, unsigned char const *p, size_t len,
179+
u32 poly, unsigned long poly_qt,
180+
fallback crc_fb)
182181
{
183182
size_t offset, head_len, tail_len;
184183
unsigned long const *p_ul;
@@ -218,14 +217,14 @@ static inline u32 __pure crc32_le_generic(u32 crc, unsigned char const *p,
218217
return crc_fb(crc, p, len);
219218
}
220219

221-
u32 __pure crc32_le_arch(u32 crc, const u8 *p, size_t len)
220+
u32 crc32_le_arch(u32 crc, const u8 *p, size_t len)
222221
{
223222
return crc32_le_generic(crc, p, len, CRC32_POLY_LE, CRC32_POLY_QT_LE,
224223
crc32_le_base);
225224
}
226225
EXPORT_SYMBOL(crc32_le_arch);
227226

228-
u32 __pure crc32c_le_arch(u32 crc, const u8 *p, size_t len)
227+
u32 crc32c_le_arch(u32 crc, const u8 *p, size_t len)
229228
{
230229
return crc32_le_generic(crc, p, len, CRC32C_POLY_LE,
231230
CRC32C_POLY_QT_LE, crc32c_le_base);
@@ -256,7 +255,7 @@ static inline u32 crc32_be_unaligned(u32 crc, unsigned char const *p,
256255
return crc;
257256
}
258257

259-
u32 __pure crc32_be_arch(u32 crc, const u8 *p, size_t len)
258+
u32 crc32_be_arch(u32 crc, const u8 *p, size_t len)
260259
{
261260
size_t offset, head_len, tail_len;
262261
unsigned long const *p_ul;

include/linux/crc32.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,29 @@
88
#include <linux/types.h>
99
#include <linux/bitrev.h>
1010

11-
u32 __pure crc32_le_arch(u32 crc, const u8 *p, size_t len);
12-
u32 __pure crc32_le_base(u32 crc, const u8 *p, size_t len);
13-
u32 __pure crc32_be_arch(u32 crc, const u8 *p, size_t len);
14-
u32 __pure crc32_be_base(u32 crc, const u8 *p, size_t len);
15-
u32 __pure crc32c_le_arch(u32 crc, const u8 *p, size_t len);
16-
u32 __pure crc32c_le_base(u32 crc, const u8 *p, size_t len);
11+
u32 crc32_le_arch(u32 crc, const u8 *p, size_t len);
12+
u32 crc32_le_base(u32 crc, const u8 *p, size_t len);
13+
u32 crc32_be_arch(u32 crc, const u8 *p, size_t len);
14+
u32 crc32_be_base(u32 crc, const u8 *p, size_t len);
15+
u32 crc32c_le_arch(u32 crc, const u8 *p, size_t len);
16+
u32 crc32c_le_base(u32 crc, const u8 *p, size_t len);
1717

18-
static inline u32 __pure crc32_le(u32 crc, const void *p, size_t len)
18+
static inline u32 crc32_le(u32 crc, const void *p, size_t len)
1919
{
2020
if (IS_ENABLED(CONFIG_CRC32_ARCH))
2121
return crc32_le_arch(crc, p, len);
2222
return crc32_le_base(crc, p, len);
2323
}
2424

25-
static inline u32 __pure crc32_be(u32 crc, const void *p, size_t len)
25+
static inline u32 crc32_be(u32 crc, const void *p, size_t len)
2626
{
2727
if (IS_ENABLED(CONFIG_CRC32_ARCH))
2828
return crc32_be_arch(crc, p, len);
2929
return crc32_be_base(crc, p, len);
3030
}
3131

3232
/* TODO: leading underscores should be dropped once callers have been updated */
33-
static inline u32 __pure __crc32c_le(u32 crc, const void *p, size_t len)
33+
static inline u32 __crc32c_le(u32 crc, const void *p, size_t len)
3434
{
3535
if (IS_ENABLED(CONFIG_CRC32_ARCH))
3636
return crc32c_le_arch(crc, p, len);
@@ -70,7 +70,7 @@ static inline u32 crc32_optimizations(void) { return 0; }
7070
* with the same initializer as crc1, and crc2 seed was 0. See
7171
* also crc32_combine_test().
7272
*/
73-
u32 __attribute_const__ crc32_le_shift(u32 crc, size_t len);
73+
u32 crc32_le_shift(u32 crc, size_t len);
7474

7575
static inline u32 crc32_le_combine(u32 crc1, u32 crc2, size_t len2)
7676
{
@@ -95,7 +95,7 @@ static inline u32 crc32_le_combine(u32 crc1, u32 crc2, size_t len2)
9595
* seeded with the same initializer as crc1, and crc2 seed
9696
* was 0. See also crc32c_combine_test().
9797
*/
98-
u32 __attribute_const__ __crc32c_le_shift(u32 crc, size_t len);
98+
u32 __crc32c_le_shift(u32 crc, size_t len);
9999

100100
static inline u32 __crc32c_le_combine(u32 crc1, u32 crc2, size_t len2)
101101
{

lib/crc32.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ MODULE_AUTHOR("Matt Domsch <[email protected]>");
3737
MODULE_DESCRIPTION("Various CRC32 calculations");
3838
MODULE_LICENSE("GPL");
3939

40-
u32 __pure crc32_le_base(u32 crc, const u8 *p, size_t len)
40+
u32 crc32_le_base(u32 crc, const u8 *p, size_t len)
4141
{
4242
while (len--)
4343
crc = (crc >> 8) ^ crc32table_le[(crc & 255) ^ *p++];
4444
return crc;
4545
}
4646
EXPORT_SYMBOL(crc32_le_base);
4747

48-
u32 __pure crc32c_le_base(u32 crc, const u8 *p, size_t len)
48+
u32 crc32c_le_base(u32 crc, const u8 *p, size_t len)
4949
{
5050
while (len--)
5151
crc = (crc >> 8) ^ crc32ctable_le[(crc & 255) ^ *p++];
@@ -58,7 +58,7 @@ EXPORT_SYMBOL(crc32c_le_base);
5858
* This follows the "little-endian" CRC convention that the lsbit
5959
* represents the highest power of x, and the msbit represents x^0.
6060
*/
61-
static u32 __attribute_const__ gf2_multiply(u32 x, u32 y, u32 modulus)
61+
static u32 gf2_multiply(u32 x, u32 y, u32 modulus)
6262
{
6363
u32 product = x & 1 ? y : 0;
6464
int i;
@@ -84,8 +84,7 @@ static u32 __attribute_const__ gf2_multiply(u32 x, u32 y, u32 modulus)
8484
* as appending len bytes of zero to the data), in time proportional
8585
* to log(len).
8686
*/
87-
static u32 __attribute_const__ crc32_generic_shift(u32 crc, size_t len,
88-
u32 polynomial)
87+
static u32 crc32_generic_shift(u32 crc, size_t len, u32 polynomial)
8988
{
9089
u32 power = polynomial; /* CRC of x^32 */
9190
int i;
@@ -114,19 +113,19 @@ static u32 __attribute_const__ crc32_generic_shift(u32 crc, size_t len,
114113
return crc;
115114
}
116115

117-
u32 __attribute_const__ crc32_le_shift(u32 crc, size_t len)
116+
u32 crc32_le_shift(u32 crc, size_t len)
118117
{
119118
return crc32_generic_shift(crc, len, CRC32_POLY_LE);
120119
}
121120

122-
u32 __attribute_const__ __crc32c_le_shift(u32 crc, size_t len)
121+
u32 __crc32c_le_shift(u32 crc, size_t len)
123122
{
124123
return crc32_generic_shift(crc, len, CRC32C_POLY_LE);
125124
}
126125
EXPORT_SYMBOL(crc32_le_shift);
127126
EXPORT_SYMBOL(__crc32c_le_shift);
128127

129-
u32 __pure crc32_be_base(u32 crc, const u8 *p, size_t len)
128+
u32 crc32_be_base(u32 crc, const u8 *p, size_t len)
130129
{
131130
while (len--)
132131
crc = (crc << 8) ^ crc32table_be[(crc >> 24) ^ *p++];

0 commit comments

Comments
 (0)