Re: What exactly is our CRC algorithm?

From: Abhijit Menon-Sen <ams(at)2ndQuadrant(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>
Subject: Re: What exactly is our CRC algorithm?
Date: 2014-12-25 06:27:29
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


Here's a proposed patch to use CPUID at startup to determine if the
SSE4.2 CRC instructions are available, to use them instead of the
slice-by-8 implementation (posted earlier).

A few notes:

1. GCC has included cpuid.h since 4.3.0, so I figured it was safe to
use. It can be replaced with some inline assembly otherwise.

2. I've also used the crc32b/crc32q instructions directly rather than
using ".bytes" to encode the instructions; bintuils versions since
2007 or so have supported them.

3. I've included the MSVC implementation mostly as an example of how to
extend this to different compilers/platforms. It's written according
to the documentation for MSVC intrinsics, but I have not tested it.
Suggestions/improvements are welcome.

-- Abhijit

Attachment Content-Type Size
crc.diff text/x-diff 6.8 KB

In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2014-12-25 10:35:31 Re: Securing "make check" (CVE-2014-0067)
Previous Message Noah Misch 2014-12-25 05:27:06 Re: Securing "make check" (CVE-2014-0067)