aboutsummaryrefslogtreecommitdiffstats
path: root/lib/crc32.c
diff options
context:
space:
mode:
authorArd Biesheuvel <ard.biesheuvel@linaro.org>2018-08-27 07:02:42 -0400
committerCatalin Marinas <catalin.marinas@arm.com>2018-09-10 11:09:27 -0400
commit9784d82db3eb3de7851e5a3f4a2481607de2452c (patch)
tree4af04116f41e1e1ca3142f1e5ccb6bb8f015df77 /lib/crc32.c
parentcbbac1c3e6a80f32a692703d764f432d357378ec (diff)
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>
Diffstat (limited to 'lib/crc32.c')
-rw-r--r--lib/crc32.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/crc32.c b/lib/crc32.c
index a6c9afafc8c8..45b1d67a1767 100644
--- a/lib/crc32.c
+++ b/lib/crc32.c
@@ -183,21 +183,21 @@ static inline u32 __pure crc32_le_generic(u32 crc, unsigned char const *p,
183} 183}
184 184
185#if CRC_LE_BITS == 1 185#if CRC_LE_BITS == 1
186u32 __pure crc32_le(u32 crc, unsigned char const *p, size_t len) 186u32 __pure __weak crc32_le(u32 crc, unsigned char const *p, size_t len)
187{ 187{
188 return crc32_le_generic(crc, p, len, NULL, CRC32_POLY_LE); 188 return crc32_le_generic(crc, p, len, NULL, CRC32_POLY_LE);
189} 189}
190u32 __pure __crc32c_le(u32 crc, unsigned char const *p, size_t len) 190u32 __pure __weak __crc32c_le(u32 crc, unsigned char const *p, size_t len)
191{ 191{
192 return crc32_le_generic(crc, p, len, NULL, CRC32C_POLY_LE); 192 return crc32_le_generic(crc, p, len, NULL, CRC32C_POLY_LE);
193} 193}
194#else 194#else
195u32 __pure crc32_le(u32 crc, unsigned char const *p, size_t len) 195u32 __pure __weak crc32_le(u32 crc, unsigned char const *p, size_t len)
196{ 196{
197 return crc32_le_generic(crc, p, len, 197 return crc32_le_generic(crc, p, len,
198 (const u32 (*)[256])crc32table_le, CRC32_POLY_LE); 198 (const u32 (*)[256])crc32table_le, CRC32_POLY_LE);
199} 199}
200u32 __pure __crc32c_le(u32 crc, unsigned char const *p, size_t len) 200u32 __pure __weak __crc32c_le(u32 crc, unsigned char const *p, size_t len)
201{ 201{
202 return crc32_le_generic(crc, p, len, 202 return crc32_le_generic(crc, p, len,
203 (const u32 (*)[256])crc32ctable_le, CRC32C_POLY_LE); 203 (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)
206EXPORT_SYMBOL(crc32_le); 206EXPORT_SYMBOL(crc32_le);
207EXPORT_SYMBOL(__crc32c_le); 207EXPORT_SYMBOL(__crc32c_le);
208 208
209u32 crc32_le_base(u32, unsigned char const *, size_t) __alias(crc32_le);
210u32 __crc32c_le_base(u32, unsigned char const *, size_t) __alias(__crc32c_le);
211
209/* 212/*
210 * This multiplies the polynomials x and y modulo the given modulus. 213 * This multiplies the polynomials x and y modulo the given modulus.
211 * This follows the "little-endian" CRC convention that the lsbit 214 * This follows the "little-endian" CRC convention that the lsbit