mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "George Spelvin" <linux@horizon.com>
To: akpm@linux-foundation.org, fzago@systemfabricworks.com,
	joakim.tjernlund@transmode.se, linux-kernel@vger.kernel.org,
	linux@horizon.com, rpearson@systemfabricworks.com
Subject: Re: [patch v5 7/8] crc32-add-slicing-by-8.diff
Date: 11 Aug 2011 11:34:01 -0400	[thread overview]
Message-ID: <20110811153401.21426.qmail@science.horizon.com> (raw)
In-Reply-To: <4E4309E4.2080108@systemfabricworks.com>

I don't know if you care, but here's some slightly more compact code for
creating the tables.  It produces the same results, and I don't think
it's any slower.

I can explain it if anyone's confused, but it's hopefully fairly
easy to figure out assuming a backgriund in CRC math.

(Tested against existing code, not in kernel.)
Signed-off-by: George Spelvin <linux@horizon.com>

static void crc32init_le(void)
{
	unsigned i, j, k;
	uint32_t crc = 1;

	for (i = 0; i < LE_TABLE_ROWS; i++) {
		crc32table_le[i][0] = 0;
		for (j = LE_TABLE_SIZE >> 1; j; j >>= 1) {
			crc = (crc >> 1) ^ (crc & 1 ? CRCPOLY_LE : 0);
			for (k = 0; k < LE_TABLE_SIZE; k += 2 * j)
				crc32table_le[i][j + k] = crc ^ crc32table_le[i][k];
		}
	}
}

static void crc32init_be(void)
{
	unsigned i, j, k;
	uint32_t crc = 0x80000000;

	for (i = 0; i < BE_TABLE_ROWS; i++) {
		crc32table_be[i][0] = 0;
		for (j = 1; j < BE_TABLE_SIZE; j <<= 1) {
			crc = (crc << 1) ^ (crc & 0x80000000 ? CRCPOLY_BE : 0);
			for (k = 0; k < j; k++)
				crc32table_be[i][j + k] = crc ^ crc32table_be[i][k];
		}
	}
}

  parent reply	other threads:[~2011-08-11 15:34 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20110810222018.281901163@systemfabricworks.com>
2011-08-10 22:43 ` [patch v5 1/8] crc32-add-pointer-to-tab.diff Bob Pearson
2011-08-10 22:43 ` [patch v5 2/8] crc32-move-to-documentation.diff Bob Pearson
2011-08-10 22:44 ` [patch v5 3/8] crc32-replace-self-test.diff Bob Pearson
2011-08-10 22:44 ` [patch v5 4/8] crc32-misc-cleanup.diff Bob Pearson
2011-08-10 22:44 ` [patch v5 5/8] crc32-fix-check-endian-warnings.diff Bob Pearson
2011-08-10 22:44 ` [patch v5 6/8] crc32-add-real-8-bit.diff Bob Pearson
2011-08-10 22:44 ` [patch v5 7/8] crc32-add-slicing-by-8.diff Bob Pearson
2011-08-11 13:46   ` Joakim Tjernlund
2011-08-11 15:34   ` George Spelvin [this message]
2011-09-07 10:39     ` Joakim Tjernlund
2011-08-10 22:45 ` [patch v5 8/8] crc32-final-cleanup.diff Bob Pearson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110811153401.21426.qmail@science.horizon.com \
    --to=linux@horizon.com \
    --cc=akpm@linux-foundation.org \
    --cc=fzago@systemfabricworks.com \
    --cc=joakim.tjernlund@transmode.se \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rpearson@systemfabricworks.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®