Skip to content

Commit 9784d82

Browse files
Ard Biesheuvelctmarinas
authored andcommitted
lib/crc32: make core crc32() routines weak so they can be overridden
Allow architectures to drop in accelerated CRC32 routines by making the crc32_le/__crc32c_le entry points weak, and exposing non-weak aliases for them that may be used by the accelerated versions as fallbacks in case the instructions they rely upon are not available. Acked-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent cbbac1c commit 9784d82

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lib/crc32.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,21 +183,21 @@ static inline u32 __pure crc32_le_generic(u32 crc, unsigned char const *p,
183183
}
184184

185185
#if CRC_LE_BITS == 1
186-
u32 __pure crc32_le(u32 crc, unsigned char const *p, size_t len)
186+
u32 __pure __weak crc32_le(u32 crc, unsigned char const *p, size_t len)
187187
{
188188
return crc32_le_generic(crc, p, len, NULL, CRC32_POLY_LE);
189189
}
190-
u32 __pure __crc32c_le(u32 crc, unsigned char const *p, size_t len)
190+
u32 __pure __weak __crc32c_le(u32 crc, unsigned char const *p, size_t len)
191191
{
192192
return crc32_le_generic(crc, p, len, NULL, CRC32C_POLY_LE);
193193
}
194194
#else
195-
u32 __pure crc32_le(u32 crc, unsigned char const *p, size_t len)
195+
u32 __pure __weak crc32_le(u32 crc, unsigned char const *p, size_t len)
196196
{
197197
return crc32_le_generic(crc, p, len,
198198
(const u32 (*)[256])crc32table_le, CRC32_POLY_LE);
199199
}
200-
u32 __pure __crc32c_le(u32 crc, unsigned char const *p, size_t len)
200+
u32 __pure __weak __crc32c_le(u32 crc, unsigned char const *p, size_t len)
201201
{
202202
return crc32_le_generic(crc, p, len,
203203
(const u32 (*)[256])crc32ctable_le, CRC32C_POLY_LE);
@@ -206,6 +206,9 @@ u32 __pure __crc32c_le(u32 crc, unsigned char const *p, size_t len)
206206
EXPORT_SYMBOL(crc32_le);
207207
EXPORT_SYMBOL(__crc32c_le);
208208

209+
u32 crc32_le_base(u32, unsigned char const *, size_t) __alias(crc32_le);
210+
u32 __crc32c_le_base(u32, unsigned char const *, size_t) __alias(__crc32c_le);
211+
209212
/*
210213
* This multiplies the polynomials x and y modulo the given modulus.
211214
* This follows the "little-endian" CRC convention that the lsbit

0 commit comments

Comments
 (0)