From cffca129a9b2e061dd9f2eea8124607d2086a813 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Tue, 1 Sep 2020 04:37:55 +0000 Subject: [PATCH] Smaller crc for the boot loader. Save 7k of text space by using simpler crc32 for standalone case. we don't need all that fancy optimization in the boot loader, so use a simplified version of the CRC function. We could save more by doing it one bit at a time rather than 32, but this is the biggest savings at the smallest performance hit. With LUA and verfied exec, gptboot, gptzfsboot and friends are pushing the ~530k limit and every little bit helps. Reviewed By: allanjude Differential Revision: https://reviews.freebsd.org/D24225 --- sys/libkern/gsb_crc32.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sys/libkern/gsb_crc32.c b/sys/libkern/gsb_crc32.c index f3991fc5a63..7c2fdd7eb84 100644 --- a/sys/libkern/gsb_crc32.c +++ b/sys/libkern/gsb_crc32.c @@ -227,6 +227,7 @@ singletable_crc32c(uint32_t crc, const void *buf, size_t size) return crc; } +#ifndef _STANDALONE /* * Copyright (c) 2004-2006 Intel Corporation - All Rights Reserved @@ -788,3 +789,10 @@ calculate_crc32c(uint32_t crc32c, return (multitable_crc32c(crc32c, buffer, length)); } } +#else +uint32_t +calculate_crc32c(uint32_t crc32c, const unsigned char *buffer, unsigned int length) +{ + return (singletable_crc32c(crc32c, buffer, length)); +} +#endif