hawq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m..@apache.org
Subject [2/3] incubator-hawq git commit: HAWQ-316. Rework SSE42 implementation and runtime logic to be more similar to PostgreSQL9.5
Date Fri, 19 Feb 2016 01:48:41 GMT
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/f988a712/src/backend/utils/hash/crc32c.c
----------------------------------------------------------------------
diff --git a/src/backend/utils/hash/crc32c.c b/src/backend/utils/hash/crc32c.c
deleted file mode 100644
index 7c427a8..0000000
--- a/src/backend/utils/hash/crc32c.c
+++ /dev/null
@@ -1,702 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-/*
- * crc32c.c
- *
- *  Created on: Mar 3, 2011
- *      Author: cmcdevitt
- */
-
-#include "c.h"
-#include "utils/pg_crc.h"
-
-extern pg_crc32
-crc32cDetectBestMethod(pg_crc32 crc, const void* data, int length);
-
-
-
-
-
-/* Tables used in Slicing-by-8 calculation of CRC32C.  Not needed for hardware crc32c */
-
-/* Tables generated with code like the following:
-
-#define CRCPOLY 0x82f63b78 // reversed 0x1EDC6F41
-#define CRCINIT 0xFFFFFFFF
-
-void init() {
-	for (uint32 i = 0; i <= 0xFF; i++) {
-		uint32 x = i;
-		for (uint32 j = 0; j < 8; j++)
-			x = (x>>1) ^ (CRCPOLY & (-(int32)(x & 1)));
-		g_crc_slicing[0][i] = x;
-	}
-
-	for (uint32 i = 0; i <= 0xFF; i++) {
-		uint32 c = g_crc_slicing[0][i];
-		for (uint32 j = 1; j < 8; j++) {
-			c = g_crc_slicing[0][c & 0xFF] ^ (c >> 8);
-			g_crc_slicing[j][i] = c;
-		}
-	}
-}
-*/
-
-/*
- * The following CRC lookup table was generated automagically
- * using the following model parameters:
- *
- * Generator Polynomial = ................. 0x1EDC6F41
- * Generator Polynomial Length = .......... 32 bits
- * Reflected Bits = ....................... TRUE
- * Table Generation Offset = .............. 32 bits
- * Number of Slices = ..................... 8 slices
- * Slice Lengths = ........................ 8 8 8 8 8 8 8 8
- * Directory Name = ....................... .\
- * File Name = ............................ 8x256_tables.c
- */
-
-const uint32 crc_tableil8_o32[256] =
-{
- 0x00000000, 0xF26B8303, 0xE13B70F7, 0x1350F3F4, 0xC79A971F, 0x35F1141C, 0x26A1E7E8, 0xD4CA64EB,
- 0x8AD958CF, 0x78B2DBCC, 0x6BE22838, 0x9989AB3B, 0x4D43CFD0, 0xBF284CD3, 0xAC78BF27, 0x5E133C24,
- 0x105EC76F, 0xE235446C, 0xF165B798, 0x030E349B, 0xD7C45070, 0x25AFD373, 0x36FF2087, 0xC494A384,
- 0x9A879FA0, 0x68EC1CA3, 0x7BBCEF57, 0x89D76C54, 0x5D1D08BF, 0xAF768BBC, 0xBC267848, 0x4E4DFB4B,
- 0x20BD8EDE, 0xD2D60DDD, 0xC186FE29, 0x33ED7D2A, 0xE72719C1, 0x154C9AC2, 0x061C6936, 0xF477EA35,
- 0xAA64D611, 0x580F5512, 0x4B5FA6E6, 0xB93425E5, 0x6DFE410E, 0x9F95C20D, 0x8CC531F9, 0x7EAEB2FA,
- 0x30E349B1, 0xC288CAB2, 0xD1D83946, 0x23B3BA45, 0xF779DEAE, 0x05125DAD, 0x1642AE59, 0xE4292D5A,
- 0xBA3A117E, 0x4851927D, 0x5B016189, 0xA96AE28A, 0x7DA08661, 0x8FCB0562, 0x9C9BF696, 0x6EF07595,
- 0x417B1DBC, 0xB3109EBF, 0xA0406D4B, 0x522BEE48, 0x86E18AA3, 0x748A09A0, 0x67DAFA54, 0x95B17957,
- 0xCBA24573, 0x39C9C670, 0x2A993584, 0xD8F2B687, 0x0C38D26C, 0xFE53516F, 0xED03A29B, 0x1F682198,
- 0x5125DAD3, 0xA34E59D0, 0xB01EAA24, 0x42752927, 0x96BF4DCC, 0x64D4CECF, 0x77843D3B, 0x85EFBE38,
- 0xDBFC821C, 0x2997011F, 0x3AC7F2EB, 0xC8AC71E8, 0x1C661503, 0xEE0D9600, 0xFD5D65F4, 0x0F36E6F7,
- 0x61C69362, 0x93AD1061, 0x80FDE395, 0x72966096, 0xA65C047D, 0x5437877E, 0x4767748A, 0xB50CF789,
- 0xEB1FCBAD, 0x197448AE, 0x0A24BB5A, 0xF84F3859, 0x2C855CB2, 0xDEEEDFB1, 0xCDBE2C45, 0x3FD5AF46,
- 0x7198540D, 0x83F3D70E, 0x90A324FA, 0x62C8A7F9, 0xB602C312, 0x44694011, 0x5739B3E5, 0xA55230E6,
- 0xFB410CC2, 0x092A8FC1, 0x1A7A7C35, 0xE811FF36, 0x3CDB9BDD, 0xCEB018DE, 0xDDE0EB2A, 0x2F8B6829,
- 0x82F63B78, 0x709DB87B, 0x63CD4B8F, 0x91A6C88C, 0x456CAC67, 0xB7072F64, 0xA457DC90, 0x563C5F93,
- 0x082F63B7, 0xFA44E0B4, 0xE9141340, 0x1B7F9043, 0xCFB5F4A8, 0x3DDE77AB, 0x2E8E845F, 0xDCE5075C,
- 0x92A8FC17, 0x60C37F14, 0x73938CE0, 0x81F80FE3, 0x55326B08, 0xA759E80B, 0xB4091BFF, 0x466298FC,
- 0x1871A4D8, 0xEA1A27DB, 0xF94AD42F, 0x0B21572C, 0xDFEB33C7, 0x2D80B0C4, 0x3ED04330, 0xCCBBC033,
- 0xA24BB5A6, 0x502036A5, 0x4370C551, 0xB11B4652, 0x65D122B9, 0x97BAA1BA, 0x84EA524E, 0x7681D14D,
- 0x2892ED69, 0xDAF96E6A, 0xC9A99D9E, 0x3BC21E9D, 0xEF087A76, 0x1D63F975, 0x0E330A81, 0xFC588982,
- 0xB21572C9, 0x407EF1CA, 0x532E023E, 0xA145813D, 0x758FE5D6, 0x87E466D5, 0x94B49521, 0x66DF1622,
- 0x38CC2A06, 0xCAA7A905, 0xD9F75AF1, 0x2B9CD9F2, 0xFF56BD19, 0x0D3D3E1A, 0x1E6DCDEE, 0xEC064EED,
- 0xC38D26C4, 0x31E6A5C7, 0x22B65633, 0xD0DDD530, 0x0417B1DB, 0xF67C32D8, 0xE52CC12C, 0x1747422F,
- 0x49547E0B, 0xBB3FFD08, 0xA86F0EFC, 0x5A048DFF, 0x8ECEE914, 0x7CA56A17, 0x6FF599E3, 0x9D9E1AE0,
- 0xD3D3E1AB, 0x21B862A8, 0x32E8915C, 0xC083125F, 0x144976B4, 0xE622F5B7, 0xF5720643, 0x07198540,
- 0x590AB964, 0xAB613A67, 0xB831C993, 0x4A5A4A90, 0x9E902E7B, 0x6CFBAD78, 0x7FAB5E8C, 0x8DC0DD8F,
- 0xE330A81A, 0x115B2B19, 0x020BD8ED, 0xF0605BEE, 0x24AA3F05, 0xD6C1BC06, 0xC5914FF2, 0x37FACCF1,
- 0x69E9F0D5, 0x9B8273D6, 0x88D28022, 0x7AB90321, 0xAE7367CA, 0x5C18E4C9, 0x4F48173D, 0xBD23943E,
- 0xF36E6F75, 0x0105EC76, 0x12551F82, 0xE03E9C81, 0x34F4F86A, 0xC69F7B69, 0xD5CF889D, 0x27A40B9E,
- 0x79B737BA, 0x8BDCB4B9, 0x988C474D, 0x6AE7C44E, 0xBE2DA0A5, 0x4C4623A6, 0x5F16D052, 0xAD7D5351
-};
-
-/*
- * end of the CRC lookup table crc_tableil8_o32
- */
-
-
-
-/*
- * The following CRC lookup table was generated automagically
- * using the following model parameters:
- *
- * Generator Polynomial = ................. 0x1EDC6F41
- * Generator Polynomial Length = .......... 32 bits
- * Reflected Bits = ....................... TRUE
- * Table Generation Offset = .............. 32 bits
- * Number of Slices = ..................... 8 slices
- * Slice Lengths = ........................ 8 8 8 8 8 8 8 8
- * Directory Name = ....................... .\
- * File Name = ............................ 8x256_tables.c
- */
-
-const uint32 crc_tableil8_o40[256] =
-{
- 0x00000000, 0x13A29877, 0x274530EE, 0x34E7A899, 0x4E8A61DC, 0x5D28F9AB, 0x69CF5132, 0x7A6DC945,
- 0x9D14C3B8, 0x8EB65BCF, 0xBA51F356, 0xA9F36B21, 0xD39EA264, 0xC03C3A13, 0xF4DB928A, 0xE7790AFD,
- 0x3FC5F181, 0x2C6769F6, 0x1880C16F, 0x0B225918, 0x714F905D, 0x62ED082A, 0x560AA0B3, 0x45A838C4,
- 0xA2D13239, 0xB173AA4E, 0x859402D7, 0x96369AA0, 0xEC5B53E5, 0xFFF9CB92, 0xCB1E630B, 0xD8BCFB7C,
- 0x7F8BE302, 0x6C297B75, 0x58CED3EC, 0x4B6C4B9B, 0x310182DE, 0x22A31AA9, 0x1644B230, 0x05E62A47,
- 0xE29F20BA, 0xF13DB8CD, 0xC5DA1054, 0xD6788823, 0xAC154166, 0xBFB7D911, 0x8B507188, 0x98F2E9FF,
- 0x404E1283, 0x53EC8AF4, 0x670B226D, 0x74A9BA1A, 0x0EC4735F, 0x1D66EB28, 0x298143B1, 0x3A23DBC6,
- 0xDD5AD13B, 0xCEF8494C, 0xFA1FE1D5, 0xE9BD79A2, 0x93D0B0E7, 0x80722890, 0xB4958009, 0xA737187E,
- 0xFF17C604, 0xECB55E73, 0xD852F6EA, 0xCBF06E9D, 0xB19DA7D8, 0xA23F3FAF, 0x96D89736, 0x857A0F41,
- 0x620305BC, 0x71A19DCB, 0x45463552, 0x56E4AD25, 0x2C896460, 0x3F2BFC17, 0x0BCC548E, 0x186ECCF9,
- 0xC0D23785, 0xD370AFF2, 0xE797076B, 0xF4359F1C, 0x8E585659, 0x9DFACE2E, 0xA91D66B7, 0xBABFFEC0,
- 0x5DC6F43D, 0x4E646C4A, 0x7A83C4D3, 0x69215CA4, 0x134C95E1, 0x00EE0D96, 0x3409A50F, 0x27AB3D78,
- 0x809C2506, 0x933EBD71, 0xA7D915E8, 0xB47B8D9F, 0xCE1644DA, 0xDDB4DCAD, 0xE9537434, 0xFAF1EC43,
- 0x1D88E6BE, 0x0E2A7EC9, 0x3ACDD650, 0x296F4E27, 0x53028762, 0x40A01F15, 0x7447B78C, 0x67E52FFB,
- 0xBF59D487, 0xACFB4CF0, 0x981CE469, 0x8BBE7C1E, 0xF1D3B55B, 0xE2712D2C, 0xD69685B5, 0xC5341DC2,
- 0x224D173F, 0x31EF8F48, 0x050827D1, 0x16AABFA6, 0x6CC776E3, 0x7F65EE94, 0x4B82460D, 0x5820DE7A,
- 0xFBC3FAF9, 0xE861628E, 0xDC86CA17, 0xCF245260, 0xB5499B25, 0xA6EB0352, 0x920CABCB, 0x81AE33BC,
- 0x66D73941, 0x7575A136, 0x419209AF, 0x523091D8, 0x285D589D, 0x3BFFC0EA, 0x0F186873, 0x1CBAF004,
- 0xC4060B78, 0xD7A4930F, 0xE3433B96, 0xF0E1A3E1, 0x8A8C6AA4, 0x992EF2D3, 0xADC95A4A, 0xBE6BC23D,
- 0x5912C8C0, 0x4AB050B7, 0x7E57F82E, 0x6DF56059, 0x1798A91C, 0x043A316B, 0x30DD99F2, 0x237F0185,
- 0x844819FB, 0x97EA818C, 0xA30D2915, 0xB0AFB162, 0xCAC27827, 0xD960E050, 0xED8748C9, 0xFE25D0BE,
- 0x195CDA43, 0x0AFE4234, 0x3E19EAAD, 0x2DBB72DA, 0x57D6BB9F, 0x447423E8, 0x70938B71, 0x63311306,
- 0xBB8DE87A, 0xA82F700D, 0x9CC8D894, 0x8F6A40E3, 0xF50789A6, 0xE6A511D1, 0xD242B948, 0xC1E0213F,
- 0x26992BC2, 0x353BB3B5, 0x01DC1B2C, 0x127E835B, 0x68134A1E, 0x7BB1D269, 0x4F567AF0, 0x5CF4E287,
- 0x04D43CFD, 0x1776A48A, 0x23910C13, 0x30339464, 0x4A5E5D21, 0x59FCC556, 0x6D1B6DCF, 0x7EB9F5B8,
- 0x99C0FF45, 0x8A626732, 0xBE85CFAB, 0xAD2757DC, 0xD74A9E99, 0xC4E806EE, 0xF00FAE77, 0xE3AD3600,
- 0x3B11CD7C, 0x28B3550B, 0x1C54FD92, 0x0FF665E5, 0x759BACA0, 0x663934D7, 0x52DE9C4E, 0x417C0439,
- 0xA6050EC4, 0xB5A796B3, 0x81403E2A, 0x92E2A65D, 0xE88F6F18, 0xFB2DF76F, 0xCFCA5FF6, 0xDC68C781,
- 0x7B5FDFFF, 0x68FD4788, 0x5C1AEF11, 0x4FB87766, 0x35D5BE23, 0x26772654, 0x12908ECD, 0x013216BA,
- 0xE64B1C47, 0xF5E98430, 0xC10E2CA9, 0xD2ACB4DE, 0xA8C17D9B, 0xBB63E5EC, 0x8F844D75, 0x9C26D502,
- 0x449A2E7E, 0x5738B609, 0x63DF1E90, 0x707D86E7, 0x0A104FA2, 0x19B2D7D5, 0x2D557F4C, 0x3EF7E73B,
- 0xD98EEDC6, 0xCA2C75B1, 0xFECBDD28, 0xED69455F, 0x97048C1A, 0x84A6146D, 0xB041BCF4, 0xA3E32483
-};
-
-/*
- * end of the CRC lookup table crc_tableil8_o40
- */
-
-
-
-/*
- * The following CRC lookup table was generated automagically
- * using the following model parameters:
- *
- * Generator Polynomial = ................. 0x1EDC6F41
- * Generator Polynomial Length = .......... 32 bits
- * Reflected Bits = ....................... TRUE
- * Table Generation Offset = .............. 32 bits
- * Number of Slices = ..................... 8 slices
- * Slice Lengths = ........................ 8 8 8 8 8 8 8 8
- * Directory Name = ....................... .\
- * File Name = ............................ 8x256_tables.c
- */
-
-const uint32 crc_tableil8_o48[256] =
-{
- 0x00000000, 0xA541927E, 0x4F6F520D, 0xEA2EC073, 0x9EDEA41A, 0x3B9F3664, 0xD1B1F617, 0x74F06469,
- 0x38513EC5, 0x9D10ACBB, 0x773E6CC8, 0xD27FFEB6, 0xA68F9ADF, 0x03CE08A1, 0xE9E0C8D2, 0x4CA15AAC,
- 0x70A27D8A, 0xD5E3EFF4, 0x3FCD2F87, 0x9A8CBDF9, 0xEE7CD990, 0x4B3D4BEE, 0xA1138B9D, 0x045219E3,
- 0x48F3434F, 0xEDB2D131, 0x079C1142, 0xA2DD833C, 0xD62DE755, 0x736C752B, 0x9942B558, 0x3C032726,
- 0xE144FB14, 0x4405696A, 0xAE2BA919, 0x0B6A3B67, 0x7F9A5F0E, 0xDADBCD70, 0x30F50D03, 0x95B49F7D,
- 0xD915C5D1, 0x7C5457AF, 0x967A97DC, 0x333B05A2, 0x47CB61CB, 0xE28AF3B5, 0x08A433C6, 0xADE5A1B8,
- 0x91E6869E, 0x34A714E0, 0xDE89D493, 0x7BC846ED, 0x0F382284, 0xAA79B0FA, 0x40577089, 0xE516E2F7,
- 0xA9B7B85B, 0x0CF62A25, 0xE6D8EA56, 0x43997828, 0x37691C41, 0x92288E3F, 0x78064E4C, 0xDD47DC32,
- 0xC76580D9, 0x622412A7, 0x880AD2D4, 0x2D4B40AA, 0x59BB24C3, 0xFCFAB6BD, 0x16D476CE, 0xB395E4B0,
- 0xFF34BE1C, 0x5A752C62, 0xB05BEC11, 0x151A7E6F, 0x61EA1A06, 0xC4AB8878, 0x2E85480B, 0x8BC4DA75,
- 0xB7C7FD53, 0x12866F2D, 0xF8A8AF5E, 0x5DE93D20, 0x29195949, 0x8C58CB37, 0x66760B44, 0xC337993A,
- 0x8F96C396, 0x2AD751E8, 0xC0F9919B, 0x65B803E5, 0x1148678C, 0xB409F5F2, 0x5E273581, 0xFB66A7FF,
- 0x26217BCD, 0x8360E9B3, 0x694E29C0, 0xCC0FBBBE, 0xB8FFDFD7, 0x1DBE4DA9, 0xF7908DDA, 0x52D11FA4,
- 0x1E704508, 0xBB31D776, 0x511F1705, 0xF45E857B, 0x80AEE112, 0x25EF736C, 0xCFC1B31F, 0x6A802161,
- 0x56830647, 0xF3C29439, 0x19EC544A, 0xBCADC634, 0xC85DA25D, 0x6D1C3023, 0x8732F050, 0x2273622E,
- 0x6ED23882, 0xCB93AAFC, 0x21BD6A8F, 0x84FCF8F1, 0xF00C9C98, 0x554D0EE6, 0xBF63CE95, 0x1A225CEB,
- 0x8B277743, 0x2E66E53D, 0xC448254E, 0x6109B730, 0x15F9D359, 0xB0B84127, 0x5A968154, 0xFFD7132A,
- 0xB3764986, 0x1637DBF8, 0xFC191B8B, 0x595889F5, 0x2DA8ED9C, 0x88E97FE2, 0x62C7BF91, 0xC7862DEF,
- 0xFB850AC9, 0x5EC498B7, 0xB4EA58C4, 0x11ABCABA, 0x655BAED3, 0xC01A3CAD, 0x2A34FCDE, 0x8F756EA0,
- 0xC3D4340C, 0x6695A672, 0x8CBB6601, 0x29FAF47F, 0x5D0A9016, 0xF84B0268, 0x1265C21B, 0xB7245065,
- 0x6A638C57, 0xCF221E29, 0x250CDE5A, 0x804D4C24, 0xF4BD284D, 0x51FCBA33, 0xBBD27A40, 0x1E93E83E,
- 0x5232B292, 0xF77320EC, 0x1D5DE09F, 0xB81C72E1, 0xCCEC1688, 0x69AD84F6, 0x83834485, 0x26C2D6FB,
- 0x1AC1F1DD, 0xBF8063A3, 0x55AEA3D0, 0xF0EF31AE, 0x841F55C7, 0x215EC7B9, 0xCB7007CA, 0x6E3195B4,
- 0x2290CF18, 0x87D15D66, 0x6DFF9D15, 0xC8BE0F6B, 0xBC4E6B02, 0x190FF97C, 0xF321390F, 0x5660AB71,
- 0x4C42F79A, 0xE90365E4, 0x032DA597, 0xA66C37E9, 0xD29C5380, 0x77DDC1FE, 0x9DF3018D, 0x38B293F3,
- 0x7413C95F, 0xD1525B21, 0x3B7C9B52, 0x9E3D092C, 0xEACD6D45, 0x4F8CFF3B, 0xA5A23F48, 0x00E3AD36,
- 0x3CE08A10, 0x99A1186E, 0x738FD81D, 0xD6CE4A63, 0xA23E2E0A, 0x077FBC74, 0xED517C07, 0x4810EE79,
- 0x04B1B4D5, 0xA1F026AB, 0x4BDEE6D8, 0xEE9F74A6, 0x9A6F10CF, 0x3F2E82B1, 0xD50042C2, 0x7041D0BC,
- 0xAD060C8E, 0x08479EF0, 0xE2695E83, 0x4728CCFD, 0x33D8A894, 0x96993AEA, 0x7CB7FA99, 0xD9F668E7,
- 0x9557324B, 0x3016A035, 0xDA386046, 0x7F79F238, 0x0B899651, 0xAEC8042F, 0x44E6C45C, 0xE1A75622,
- 0xDDA47104, 0x78E5E37A, 0x92CB2309, 0x378AB177, 0x437AD51E, 0xE63B4760, 0x0C158713, 0xA954156D,
- 0xE5F54FC1, 0x40B4DDBF, 0xAA9A1DCC, 0x0FDB8FB2, 0x7B2BEBDB, 0xDE6A79A5, 0x3444B9D6, 0x91052BA8
-};
-
-/*
- * end of the CRC lookup table crc_tableil8_o48
- */
-
-
-
-/*
- * The following CRC lookup table was generated automagically
- * using the following model parameters:
- *
- * Generator Polynomial = ................. 0x1EDC6F41
- * Generator Polynomial Length = .......... 32 bits
- * Reflected Bits = ....................... TRUE
- * Table Generation Offset = .............. 32 bits
- * Number of Slices = ..................... 8 slices
- * Slice Lengths = ........................ 8 8 8 8 8 8 8 8
- * Directory Name = ....................... .\
- * File Name = ............................ 8x256_tables.c
- */
-
-const uint32 crc_tableil8_o56[256] =
-{
- 0x00000000, 0xDD45AAB8, 0xBF672381, 0x62228939, 0x7B2231F3, 0xA6679B4B, 0xC4451272, 0x1900B8CA,
- 0xF64463E6, 0x2B01C95E, 0x49234067, 0x9466EADF, 0x8D665215, 0x5023F8AD, 0x32017194, 0xEF44DB2C,
- 0xE964B13D, 0x34211B85, 0x560392BC, 0x8B463804, 0x924680CE, 0x4F032A76, 0x2D21A34F, 0xF06409F7,
- 0x1F20D2DB, 0xC2657863, 0xA047F15A, 0x7D025BE2, 0x6402E328, 0xB9474990, 0xDB65C0A9, 0x06206A11,
- 0xD725148B, 0x0A60BE33, 0x6842370A, 0xB5079DB2, 0xAC072578, 0x71428FC0, 0x136006F9, 0xCE25AC41,
- 0x2161776D, 0xFC24DDD5, 0x9E0654EC, 0x4343FE54, 0x5A43469E, 0x8706EC26, 0xE524651F, 0x3861CFA7,
- 0x3E41A5B6, 0xE3040F0E, 0x81268637, 0x5C632C8F, 0x45639445, 0x98263EFD, 0xFA04B7C4, 0x27411D7C,
- 0xC805C650, 0x15406CE8, 0x7762E5D1, 0xAA274F69, 0xB327F7A3, 0x6E625D1B, 0x0C40D422, 0xD1057E9A,
- 0xABA65FE7, 0x76E3F55F, 0x14C17C66, 0xC984D6DE, 0xD0846E14, 0x0DC1C4AC, 0x6FE34D95, 0xB2A6E72D,
- 0x5DE23C01, 0x80A796B9, 0xE2851F80, 0x3FC0B538, 0x26C00DF2, 0xFB85A74A, 0x99A72E73, 0x44E284CB,
- 0x42C2EEDA, 0x9F874462, 0xFDA5CD5B, 0x20E067E3, 0x39E0DF29, 0xE4A57591, 0x8687FCA8, 0x5BC25610,
- 0xB4868D3C, 0x69C32784, 0x0BE1AEBD, 0xD6A40405, 0xCFA4BCCF, 0x12E11677, 0x70C39F4E, 0xAD8635F6,
- 0x7C834B6C, 0xA1C6E1D4, 0xC3E468ED, 0x1EA1C255, 0x07A17A9F, 0xDAE4D027, 0xB8C6591E, 0x6583F3A6,
- 0x8AC7288A, 0x57828232, 0x35A00B0B, 0xE8E5A1B3, 0xF1E51979, 0x2CA0B3C1, 0x4E823AF8, 0x93C79040,
- 0x95E7FA51, 0x48A250E9, 0x2A80D9D0, 0xF7C57368, 0xEEC5CBA2, 0x3380611A, 0x51A2E823, 0x8CE7429B,
- 0x63A399B7, 0xBEE6330F, 0xDCC4BA36, 0x0181108E, 0x1881A844, 0xC5C402FC, 0xA7E68BC5, 0x7AA3217D,
- 0x52A0C93F, 0x8FE56387, 0xEDC7EABE, 0x30824006, 0x2982F8CC, 0xF4C75274, 0x96E5DB4D, 0x4BA071F5,
- 0xA4E4AAD9, 0x79A10061, 0x1B838958, 0xC6C623E0, 0xDFC69B2A, 0x02833192, 0x60A1B8AB, 0xBDE41213,
- 0xBBC47802, 0x6681D2BA, 0x04A35B83, 0xD9E6F13B, 0xC0E649F1, 0x1DA3E349, 0x7F816A70, 0xA2C4C0C8,
- 0x4D801BE4, 0x90C5B15C, 0xF2E73865, 0x2FA292DD, 0x36A22A17, 0xEBE780AF, 0x89C50996, 0x5480A32E,
- 0x8585DDB4, 0x58C0770C, 0x3AE2FE35, 0xE7A7548D, 0xFEA7EC47, 0x23E246FF, 0x41C0CFC6, 0x9C85657E,
- 0x73C1BE52, 0xAE8414EA, 0xCCA69DD3, 0x11E3376B, 0x08E38FA1, 0xD5A62519, 0xB784AC20, 0x6AC10698,
- 0x6CE16C89, 0xB1A4C631, 0xD3864F08, 0x0EC3E5B0, 0x17C35D7A, 0xCA86F7C2, 0xA8A47EFB, 0x75E1D443,
- 0x9AA50F6F, 0x47E0A5D7, 0x25C22CEE, 0xF8878656, 0xE1873E9C, 0x3CC29424, 0x5EE01D1D, 0x83A5B7A5,
- 0xF90696D8, 0x24433C60, 0x4661B559, 0x9B241FE1, 0x8224A72B, 0x5F610D93, 0x3D4384AA, 0xE0062E12,
- 0x0F42F53E, 0xD2075F86, 0xB025D6BF, 0x6D607C07, 0x7460C4CD, 0xA9256E75, 0xCB07E74C, 0x16424DF4,
- 0x106227E5, 0xCD278D5D, 0xAF050464, 0x7240AEDC, 0x6B401616, 0xB605BCAE, 0xD4273597, 0x09629F2F,
- 0xE6264403, 0x3B63EEBB, 0x59416782, 0x8404CD3A, 0x9D0475F0, 0x4041DF48, 0x22635671, 0xFF26FCC9,
- 0x2E238253, 0xF36628EB, 0x9144A1D2, 0x4C010B6A, 0x5501B3A0, 0x88441918, 0xEA669021, 0x37233A99,
- 0xD867E1B5, 0x05224B0D, 0x6700C234, 0xBA45688C, 0xA345D046, 0x7E007AFE, 0x1C22F3C7, 0xC167597F,
- 0xC747336E, 0x1A0299D6, 0x782010EF, 0xA565BA57, 0xBC65029D, 0x6120A825, 0x0302211C, 0xDE478BA4,
- 0x31035088, 0xEC46FA30, 0x8E647309, 0x5321D9B1, 0x4A21617B, 0x9764CBC3, 0xF54642FA, 0x2803E842
-};
-
-/*
- * end of the CRC lookup table crc_tableil8_o56
- */
-
-
-
-/*
- * The following CRC lookup table was generated automagically
- * using the following model parameters:
- *
- * Generator Polynomial = ................. 0x1EDC6F41
- * Generator Polynomial Length = .......... 32 bits
- * Reflected Bits = ....................... TRUE
- * Table Generation Offset = .............. 32 bits
- * Number of Slices = ..................... 8 slices
- * Slice Lengths = ........................ 8 8 8 8 8 8 8 8
- * Directory Name = ....................... .\
- * File Name = ............................ 8x256_tables.c
- */
-
-const uint32 crc_tableil8_o64[256] =
-{
- 0x00000000, 0x38116FAC, 0x7022DF58, 0x4833B0F4, 0xE045BEB0, 0xD854D11C, 0x906761E8, 0xA8760E44,
- 0xC5670B91, 0xFD76643D, 0xB545D4C9, 0x8D54BB65, 0x2522B521, 0x1D33DA8D, 0x55006A79, 0x6D1105D5,
- 0x8F2261D3, 0xB7330E7F, 0xFF00BE8B, 0xC711D127, 0x6F67DF63, 0x5776B0CF, 0x1F45003B, 0x27546F97,
- 0x4A456A42, 0x725405EE, 0x3A67B51A, 0x0276DAB6, 0xAA00D4F2, 0x9211BB5E, 0xDA220BAA, 0xE2336406,
- 0x1BA8B557, 0x23B9DAFB, 0x6B8A6A0F, 0x539B05A3, 0xFBED0BE7, 0xC3FC644B, 0x8BCFD4BF, 0xB3DEBB13,
- 0xDECFBEC6, 0xE6DED16A, 0xAEED619E, 0x96FC0E32, 0x3E8A0076, 0x069B6FDA, 0x4EA8DF2E, 0x76B9B082,
- 0x948AD484, 0xAC9BBB28, 0xE4A80BDC, 0xDCB96470, 0x74CF6A34, 0x4CDE0598, 0x04EDB56C, 0x3CFCDAC0,
- 0x51EDDF15, 0x69FCB0B9, 0x21CF004D, 0x19DE6FE1, 0xB1A861A5, 0x89B90E09, 0xC18ABEFD, 0xF99BD151,
- 0x37516AAE, 0x0F400502, 0x4773B5F6, 0x7F62DA5A, 0xD714D41E, 0xEF05BBB2, 0xA7360B46, 0x9F2764EA,
- 0xF236613F, 0xCA270E93, 0x8214BE67, 0xBA05D1CB, 0x1273DF8F, 0x2A62B023, 0x625100D7, 0x5A406F7B,
- 0xB8730B7D, 0x806264D1, 0xC851D425, 0xF040BB89, 0x5836B5CD, 0x6027DA61, 0x28146A95, 0x10050539,
- 0x7D1400EC, 0x45056F40, 0x0D36DFB4, 0x3527B018, 0x9D51BE5C, 0xA540D1F0, 0xED736104, 0xD5620EA8,
- 0x2CF9DFF9, 0x14E8B055, 0x5CDB00A1, 0x64CA6F0D, 0xCCBC6149, 0xF4AD0EE5, 0xBC9EBE11, 0x848FD1BD,
- 0xE99ED468, 0xD18FBBC4, 0x99BC0B30, 0xA1AD649C, 0x09DB6AD8, 0x31CA0574, 0x79F9B580, 0x41E8DA2C,
- 0xA3DBBE2A, 0x9BCAD186, 0xD3F96172, 0xEBE80EDE, 0x439E009A, 0x7B8F6F36, 0x33BCDFC2, 0x0BADB06E,
- 0x66BCB5BB, 0x5EADDA17, 0x169E6AE3, 0x2E8F054F, 0x86F90B0B, 0xBEE864A7, 0xF6DBD453, 0xCECABBFF,
- 0x6EA2D55C, 0x56B3BAF0, 0x1E800A04, 0x269165A8, 0x8EE76BEC, 0xB6F60440, 0xFEC5B4B4, 0xC6D4DB18,
- 0xABC5DECD, 0x93D4B161, 0xDBE70195, 0xE3F66E39, 0x4B80607D, 0x73910FD1, 0x3BA2BF25, 0x03B3D089,
- 0xE180B48F, 0xD991DB23, 0x91A26BD7, 0xA9B3047B, 0x01C50A3F, 0x39D46593, 0x71E7D567, 0x49F6BACB,
- 0x24E7BF1E, 0x1CF6D0B2, 0x54C56046, 0x6CD40FEA, 0xC4A201AE, 0xFCB36E02, 0xB480DEF6, 0x8C91B15A,
- 0x750A600B, 0x4D1B0FA7, 0x0528BF53, 0x3D39D0FF, 0x954FDEBB, 0xAD5EB117, 0xE56D01E3, 0xDD7C6E4F,
- 0xB06D6B9A, 0x887C0436, 0xC04FB4C2, 0xF85EDB6E, 0x5028D52A, 0x6839BA86, 0x200A0A72, 0x181B65DE,
- 0xFA2801D8, 0xC2396E74, 0x8A0ADE80, 0xB21BB12C, 0x1A6DBF68, 0x227CD0C4, 0x6A4F6030, 0x525E0F9C,
- 0x3F4F0A49, 0x075E65E5, 0x4F6DD511, 0x777CBABD, 0xDF0AB4F9, 0xE71BDB55, 0xAF286BA1, 0x9739040D,
- 0x59F3BFF2, 0x61E2D05E, 0x29D160AA, 0x11C00F06, 0xB9B60142, 0x81A76EEE, 0xC994DE1A, 0xF185B1B6,
- 0x9C94B463, 0xA485DBCF, 0xECB66B3B, 0xD4A70497, 0x7CD10AD3, 0x44C0657F, 0x0CF3D58B, 0x34E2BA27,
- 0xD6D1DE21, 0xEEC0B18D, 0xA6F30179, 0x9EE26ED5, 0x36946091, 0x0E850F3D, 0x46B6BFC9, 0x7EA7D065,
- 0x13B6D5B0, 0x2BA7BA1C, 0x63940AE8, 0x5B856544, 0xF3F36B00, 0xCBE204AC, 0x83D1B458, 0xBBC0DBF4,
- 0x425B0AA5, 0x7A4A6509, 0x3279D5FD, 0x0A68BA51, 0xA21EB415, 0x9A0FDBB9, 0xD23C6B4D, 0xEA2D04E1,
- 0x873C0134, 0xBF2D6E98, 0xF71EDE6C, 0xCF0FB1C0, 0x6779BF84, 0x5F68D028, 0x175B60DC, 0x2F4A0F70,
- 0xCD796B76, 0xF56804DA, 0xBD5BB42E, 0x854ADB82, 0x2D3CD5C6, 0x152DBA6A, 0x5D1E0A9E, 0x650F6532,
- 0x081E60E7, 0x300F0F4B, 0x783CBFBF, 0x402DD013, 0xE85BDE57, 0xD04AB1FB, 0x9879010F, 0xA0686EA3
-};
-
-/*
- * end of the CRC lookup table crc_tableil8_o64
- */
-
-
-
-/*
- * The following CRC lookup table was generated automagically
- * using the following model parameters:
- *
- * Generator Polynomial = ................. 0x1EDC6F41
- * Generator Polynomial Length = .......... 32 bits
- * Reflected Bits = ....................... TRUE
- * Table Generation Offset = .............. 32 bits
- * Number of Slices = ..................... 8 slices
- * Slice Lengths = ........................ 8 8 8 8 8 8 8 8
- * Directory Name = ....................... .\
- * File Name = ............................ 8x256_tables.c
- */
-
-const uint32 crc_tableil8_o72[256] =
-{
- 0x00000000, 0xEF306B19, 0xDB8CA0C3, 0x34BCCBDA, 0xB2F53777, 0x5DC55C6E, 0x697997B4, 0x8649FCAD,
- 0x6006181F, 0x8F367306, 0xBB8AB8DC, 0x54BAD3C5, 0xD2F32F68, 0x3DC34471, 0x097F8FAB, 0xE64FE4B2,
- 0xC00C303E, 0x2F3C5B27, 0x1B8090FD, 0xF4B0FBE4, 0x72F90749, 0x9DC96C50, 0xA975A78A, 0x4645CC93,
- 0xA00A2821, 0x4F3A4338, 0x7B8688E2, 0x94B6E3FB, 0x12FF1F56, 0xFDCF744F, 0xC973BF95, 0x2643D48C,
- 0x85F4168D, 0x6AC47D94, 0x5E78B64E, 0xB148DD57, 0x370121FA, 0xD8314AE3, 0xEC8D8139, 0x03BDEA20,
- 0xE5F20E92, 0x0AC2658B, 0x3E7EAE51, 0xD14EC548, 0x570739E5, 0xB83752FC, 0x8C8B9926, 0x63BBF23F,
- 0x45F826B3, 0xAAC84DAA, 0x9E748670, 0x7144ED69, 0xF70D11C4, 0x183D7ADD, 0x2C81B107, 0xC3B1DA1E,
- 0x25FE3EAC, 0xCACE55B5, 0xFE729E6F, 0x1142F576, 0x970B09DB, 0x783B62C2, 0x4C87A918, 0xA3B7C201,
- 0x0E045BEB, 0xE13430F2, 0xD588FB28, 0x3AB89031, 0xBCF16C9C, 0x53C10785, 0x677DCC5F, 0x884DA746,
- 0x6E0243F4, 0x813228ED, 0xB58EE337, 0x5ABE882E, 0xDCF77483, 0x33C71F9A, 0x077BD440, 0xE84BBF59,
- 0xCE086BD5, 0x213800CC, 0x1584CB16, 0xFAB4A00F, 0x7CFD5CA2, 0x93CD37BB, 0xA771FC61, 0x48419778,
- 0xAE0E73CA, 0x413E18D3, 0x7582D309, 0x9AB2B810, 0x1CFB44BD, 0xF3CB2FA4, 0xC777E47E, 0x28478F67,
- 0x8BF04D66, 0x64C0267F, 0x507CEDA5, 0xBF4C86BC, 0x39057A11, 0xD6351108, 0xE289DAD2, 0x0DB9B1CB,
- 0xEBF65579, 0x04C63E60, 0x307AF5BA, 0xDF4A9EA3, 0x5903620E, 0xB6330917, 0x828FC2CD, 0x6DBFA9D4,
- 0x4BFC7D58, 0xA4CC1641, 0x9070DD9B, 0x7F40B682, 0xF9094A2F, 0x16392136, 0x2285EAEC, 0xCDB581F5,
- 0x2BFA6547, 0xC4CA0E5E, 0xF076C584, 0x1F46AE9D, 0x990F5230, 0x763F3929, 0x4283F2F3, 0xADB399EA,
- 0x1C08B7D6, 0xF338DCCF, 0xC7841715, 0x28B47C0C, 0xAEFD80A1, 0x41CDEBB8, 0x75712062, 0x9A414B7B,
- 0x7C0EAFC9, 0x933EC4D0, 0xA7820F0A, 0x48B26413, 0xCEFB98BE, 0x21CBF3A7, 0x1577387D, 0xFA475364,
- 0xDC0487E8, 0x3334ECF1, 0x0788272B, 0xE8B84C32, 0x6EF1B09F, 0x81C1DB86, 0xB57D105C, 0x5A4D7B45,
- 0xBC029FF7, 0x5332F4EE, 0x678E3F34, 0x88BE542D, 0x0EF7A880, 0xE1C7C399, 0xD57B0843, 0x3A4B635A,
- 0x99FCA15B, 0x76CCCA42, 0x42700198, 0xAD406A81, 0x2B09962C, 0xC439FD35, 0xF08536EF, 0x1FB55DF6,
- 0xF9FAB944, 0x16CAD25D, 0x22761987, 0xCD46729E, 0x4B0F8E33, 0xA43FE52A, 0x90832EF0, 0x7FB345E9,
- 0x59F09165, 0xB6C0FA7C, 0x827C31A6, 0x6D4C5ABF, 0xEB05A612, 0x0435CD0B, 0x308906D1, 0xDFB96DC8,
- 0x39F6897A, 0xD6C6E263, 0xE27A29B9, 0x0D4A42A0, 0x8B03BE0D, 0x6433D514, 0x508F1ECE, 0xBFBF75D7,
- 0x120CEC3D, 0xFD3C8724, 0xC9804CFE, 0x26B027E7, 0xA0F9DB4A, 0x4FC9B053, 0x7B757B89, 0x94451090,
- 0x720AF422, 0x9D3A9F3B, 0xA98654E1, 0x46B63FF8, 0xC0FFC355, 0x2FCFA84C, 0x1B736396, 0xF443088F,
- 0xD200DC03, 0x3D30B71A, 0x098C7CC0, 0xE6BC17D9, 0x60F5EB74, 0x8FC5806D, 0xBB794BB7, 0x544920AE,
- 0xB206C41C, 0x5D36AF05, 0x698A64DF, 0x86BA0FC6, 0x00F3F36B, 0xEFC39872, 0xDB7F53A8, 0x344F38B1,
- 0x97F8FAB0, 0x78C891A9, 0x4C745A73, 0xA344316A, 0x250DCDC7, 0xCA3DA6DE, 0xFE816D04, 0x11B1061D,
- 0xF7FEE2AF, 0x18CE89B6, 0x2C72426C, 0xC3422975, 0x450BD5D8, 0xAA3BBEC1, 0x9E87751B, 0x71B71E02,
- 0x57F4CA8E, 0xB8C4A197, 0x8C786A4D, 0x63480154, 0xE501FDF9, 0x0A3196E0, 0x3E8D5D3A, 0xD1BD3623,
- 0x37F2D291, 0xD8C2B988, 0xEC7E7252, 0x034E194B, 0x8507E5E6, 0x6A378EFF, 0x5E8B4525, 0xB1BB2E3C
-};
-
-/*
- * end of the CRC lookup table crc_tableil8_o72
- */
-
-
-
-/*
- * The following CRC lookup table was generated automagically
- * using the following model parameters:
- *
- * Generator Polynomial = ................. 0x1EDC6F41
- * Generator Polynomial Length = .......... 32 bits
- * Reflected Bits = ....................... TRUE
- * Table Generation Offset = .............. 32 bits
- * Number of Slices = ..................... 8 slices
- * Slice Lengths = ........................ 8 8 8 8 8 8 8 8
- * Directory Name = ....................... .\
- * File Name = ............................ 8x256_tables.c
- */
-
-const uint32 crc_tableil8_o80[256] =
-{
- 0x00000000, 0x68032CC8, 0xD0065990, 0xB8057558, 0xA5E0C5D1, 0xCDE3E919, 0x75E69C41, 0x1DE5B089,
- 0x4E2DFD53, 0x262ED19B, 0x9E2BA4C3, 0xF628880B, 0xEBCD3882, 0x83CE144A, 0x3BCB6112, 0x53C84DDA,
- 0x9C5BFAA6, 0xF458D66E, 0x4C5DA336, 0x245E8FFE, 0x39BB3F77, 0x51B813BF, 0xE9BD66E7, 0x81BE4A2F,
- 0xD27607F5, 0xBA752B3D, 0x02705E65, 0x6A7372AD, 0x7796C224, 0x1F95EEEC, 0xA7909BB4, 0xCF93B77C,
- 0x3D5B83BD, 0x5558AF75, 0xED5DDA2D, 0x855EF6E5, 0x98BB466C, 0xF0B86AA4, 0x48BD1FFC, 0x20BE3334,
- 0x73767EEE, 0x1B755226, 0xA370277E, 0xCB730BB6, 0xD696BB3F, 0xBE9597F7, 0x0690E2AF, 0x6E93CE67,
- 0xA100791B, 0xC90355D3, 0x7106208B, 0x19050C43, 0x04E0BCCA, 0x6CE39002, 0xD4E6E55A, 0xBCE5C992,
- 0xEF2D8448, 0x872EA880, 0x3F2BDDD8, 0x5728F110, 0x4ACD4199, 0x22CE6D51, 0x9ACB1809, 0xF2C834C1,
- 0x7AB7077A, 0x12B42BB2, 0xAAB15EEA, 0xC2B27222, 0xDF57C2AB, 0xB754EE63, 0x0F519B3B, 0x6752B7F3,
- 0x349AFA29, 0x5C99D6E1, 0xE49CA3B9, 0x8C9F8F71, 0x917A3FF8, 0xF9791330, 0x417C6668, 0x297F4AA0,
- 0xE6ECFDDC, 0x8EEFD114, 0x36EAA44C, 0x5EE98884, 0x430C380D, 0x2B0F14C5, 0x930A619D, 0xFB094D55,
- 0xA8C1008F, 0xC0C22C47, 0x78C7591F, 0x10C475D7, 0x0D21C55E, 0x6522E996, 0xDD279CCE, 0xB524B006,
- 0x47EC84C7, 0x2FEFA80F, 0x97EADD57, 0xFFE9F19F, 0xE20C4116, 0x8A0F6DDE, 0x320A1886, 0x5A09344E,
- 0x09C17994, 0x61C2555C, 0xD9C72004, 0xB1C40CCC, 0xAC21BC45, 0xC422908D, 0x7C27E5D5, 0x1424C91D,
- 0xDBB77E61, 0xB3B452A9, 0x0BB127F1, 0x63B20B39, 0x7E57BBB0, 0x16549778, 0xAE51E220, 0xC652CEE8,
- 0x959A8332, 0xFD99AFFA, 0x459CDAA2, 0x2D9FF66A, 0x307A46E3, 0x58796A2B, 0xE07C1F73, 0x887F33BB,
- 0xF56E0EF4, 0x9D6D223C, 0x25685764, 0x4D6B7BAC, 0x508ECB25, 0x388DE7ED, 0x808892B5, 0xE88BBE7D,
- 0xBB43F3A7, 0xD340DF6F, 0x6B45AA37, 0x034686FF, 0x1EA33676, 0x76A01ABE, 0xCEA56FE6, 0xA6A6432E,
- 0x6935F452, 0x0136D89A, 0xB933ADC2, 0xD130810A, 0xCCD53183, 0xA4D61D4B, 0x1CD36813, 0x74D044DB,
- 0x27180901, 0x4F1B25C9, 0xF71E5091, 0x9F1D7C59, 0x82F8CCD0, 0xEAFBE018, 0x52FE9540, 0x3AFDB988,
- 0xC8358D49, 0xA036A181, 0x1833D4D9, 0x7030F811, 0x6DD54898, 0x05D66450, 0xBDD31108, 0xD5D03DC0,
- 0x8618701A, 0xEE1B5CD2, 0x561E298A, 0x3E1D0542, 0x23F8B5CB, 0x4BFB9903, 0xF3FEEC5B, 0x9BFDC093,
- 0x546E77EF, 0x3C6D5B27, 0x84682E7F, 0xEC6B02B7, 0xF18EB23E, 0x998D9EF6, 0x2188EBAE, 0x498BC766,
- 0x1A438ABC, 0x7240A674, 0xCA45D32C, 0xA246FFE4, 0xBFA34F6D, 0xD7A063A5, 0x6FA516FD, 0x07A63A35,
- 0x8FD9098E, 0xE7DA2546, 0x5FDF501E, 0x37DC7CD6, 0x2A39CC5F, 0x423AE097, 0xFA3F95CF, 0x923CB907,
- 0xC1F4F4DD, 0xA9F7D815, 0x11F2AD4D, 0x79F18185, 0x6414310C, 0x0C171DC4, 0xB412689C, 0xDC114454,
- 0x1382F328, 0x7B81DFE0, 0xC384AAB8, 0xAB878670, 0xB66236F9, 0xDE611A31, 0x66646F69, 0x0E6743A1,
- 0x5DAF0E7B, 0x35AC22B3, 0x8DA957EB, 0xE5AA7B23, 0xF84FCBAA, 0x904CE762, 0x2849923A, 0x404ABEF2,
- 0xB2828A33, 0xDA81A6FB, 0x6284D3A3, 0x0A87FF6B, 0x17624FE2, 0x7F61632A, 0xC7641672, 0xAF673ABA,
- 0xFCAF7760, 0x94AC5BA8, 0x2CA92EF0, 0x44AA0238, 0x594FB2B1, 0x314C9E79, 0x8949EB21, 0xE14AC7E9,
- 0x2ED97095, 0x46DA5C5D, 0xFEDF2905, 0x96DC05CD, 0x8B39B544, 0xE33A998C, 0x5B3FECD4, 0x333CC01C,
- 0x60F48DC6, 0x08F7A10E, 0xB0F2D456, 0xD8F1F89E, 0xC5144817, 0xAD1764DF, 0x15121187, 0x7D113D4F
-};
-
-/*
- * end of the CRC lookup table crc_tableil8_o80
- */
-
-
-
-/*
- * The following CRC lookup table was generated automagically
- * using the following model parameters:
- *
- * Generator Polynomial = ................. 0x1EDC6F41
- * Generator Polynomial Length = .......... 32 bits
- * Reflected Bits = ....................... TRUE
- * Table Generation Offset = .............. 32 bits
- * Number of Slices = ..................... 8 slices
- * Slice Lengths = ........................ 8 8 8 8 8 8 8 8
- * Directory Name = ....................... .\
- * File Name = ............................ 8x256_tables.c
- */
-
-const uint32 crc_tableil8_o88[256] =
-{
- 0x00000000, 0x493C7D27, 0x9278FA4E, 0xDB448769, 0x211D826D, 0x6821FF4A, 0xB3657823, 0xFA590504,
- 0x423B04DA, 0x0B0779FD, 0xD043FE94, 0x997F83B3, 0x632686B7, 0x2A1AFB90, 0xF15E7CF9, 0xB86201DE,
- 0x847609B4, 0xCD4A7493, 0x160EF3FA, 0x5F328EDD, 0xA56B8BD9, 0xEC57F6FE, 0x37137197, 0x7E2F0CB0,
- 0xC64D0D6E, 0x8F717049, 0x5435F720, 0x1D098A07, 0xE7508F03, 0xAE6CF224, 0x7528754D, 0x3C14086A,
- 0x0D006599, 0x443C18BE, 0x9F789FD7, 0xD644E2F0, 0x2C1DE7F4, 0x65219AD3, 0xBE651DBA, 0xF759609D,
- 0x4F3B6143, 0x06071C64, 0xDD439B0D, 0x947FE62A, 0x6E26E32E, 0x271A9E09, 0xFC5E1960, 0xB5626447,
- 0x89766C2D, 0xC04A110A, 0x1B0E9663, 0x5232EB44, 0xA86BEE40, 0xE1579367, 0x3A13140E, 0x732F6929,
- 0xCB4D68F7, 0x827115D0, 0x593592B9, 0x1009EF9E, 0xEA50EA9A, 0xA36C97BD, 0x782810D4, 0x31146DF3,
- 0x1A00CB32, 0x533CB615, 0x8878317C, 0xC1444C5B, 0x3B1D495F, 0x72213478, 0xA965B311, 0xE059CE36,
- 0x583BCFE8, 0x1107B2CF, 0xCA4335A6, 0x837F4881, 0x79264D85, 0x301A30A2, 0xEB5EB7CB, 0xA262CAEC,
- 0x9E76C286, 0xD74ABFA1, 0x0C0E38C8, 0x453245EF, 0xBF6B40EB, 0xF6573DCC, 0x2D13BAA5, 0x642FC782,
- 0xDC4DC65C, 0x9571BB7B, 0x4E353C12, 0x07094135, 0xFD504431, 0xB46C3916, 0x6F28BE7F, 0x2614C358,
- 0x1700AEAB, 0x5E3CD38C, 0x857854E5, 0xCC4429C2, 0x361D2CC6, 0x7F2151E1, 0xA465D688, 0xED59ABAF,
- 0x553BAA71, 0x1C07D756, 0xC743503F, 0x8E7F2D18, 0x7426281C, 0x3D1A553B, 0xE65ED252, 0xAF62AF75,
- 0x9376A71F, 0xDA4ADA38, 0x010E5D51, 0x48322076, 0xB26B2572, 0xFB575855, 0x2013DF3C, 0x692FA21B,
- 0xD14DA3C5, 0x9871DEE2, 0x4335598B, 0x0A0924AC, 0xF05021A8, 0xB96C5C8F, 0x6228DBE6, 0x2B14A6C1,
- 0x34019664, 0x7D3DEB43, 0xA6796C2A, 0xEF45110D, 0x151C1409, 0x5C20692E, 0x8764EE47, 0xCE589360,
- 0x763A92BE, 0x3F06EF99, 0xE44268F0, 0xAD7E15D7, 0x572710D3, 0x1E1B6DF4, 0xC55FEA9D, 0x8C6397BA,
- 0xB0779FD0, 0xF94BE2F7, 0x220F659E, 0x6B3318B9, 0x916A1DBD, 0xD856609A, 0x0312E7F3, 0x4A2E9AD4,
- 0xF24C9B0A, 0xBB70E62D, 0x60346144, 0x29081C63, 0xD3511967, 0x9A6D6440, 0x4129E329, 0x08159E0E,
- 0x3901F3FD, 0x703D8EDA, 0xAB7909B3, 0xE2457494, 0x181C7190, 0x51200CB7, 0x8A648BDE, 0xC358F6F9,
- 0x7B3AF727, 0x32068A00, 0xE9420D69, 0xA07E704E, 0x5A27754A, 0x131B086D, 0xC85F8F04, 0x8163F223,
- 0xBD77FA49, 0xF44B876E, 0x2F0F0007, 0x66337D20, 0x9C6A7824, 0xD5560503, 0x0E12826A, 0x472EFF4D,
- 0xFF4CFE93, 0xB67083B4, 0x6D3404DD, 0x240879FA, 0xDE517CFE, 0x976D01D9, 0x4C2986B0, 0x0515FB97,
- 0x2E015D56, 0x673D2071, 0xBC79A718, 0xF545DA3F, 0x0F1CDF3B, 0x4620A21C, 0x9D642575, 0xD4585852,
- 0x6C3A598C, 0x250624AB, 0xFE42A3C2, 0xB77EDEE5, 0x4D27DBE1, 0x041BA6C6, 0xDF5F21AF, 0x96635C88,
- 0xAA7754E2, 0xE34B29C5, 0x380FAEAC, 0x7133D38B, 0x8B6AD68F, 0xC256ABA8, 0x19122CC1, 0x502E51E6,
- 0xE84C5038, 0xA1702D1F, 0x7A34AA76, 0x3308D751, 0xC951D255, 0x806DAF72, 0x5B29281B, 0x1215553C,
- 0x230138CF, 0x6A3D45E8, 0xB179C281, 0xF845BFA6, 0x021CBAA2, 0x4B20C785, 0x906440EC, 0xD9583DCB,
- 0x613A3C15, 0x28064132, 0xF342C65B, 0xBA7EBB7C, 0x4027BE78, 0x091BC35F, 0xD25F4436, 0x9B633911,
- 0xA777317B, 0xEE4B4C5C, 0x350FCB35, 0x7C33B612, 0x866AB316, 0xCF56CE31, 0x14124958, 0x5D2E347F,
- 0xE54C35A1, 0xAC704886, 0x7734CFEF, 0x3E08B2C8, 0xC451B7CC, 0x8D6DCAEB, 0x56294D82, 0x1F1530A5
-};
-
-/*
- * end of the CRC lookup table crc_tableil8_o88
- */
-
-/* Fast CRC-32C using Slicing-by-8 design */
-pg_crc32
-crc32cSlicingBy8(pg_crc32 crc, const void* data, int length)
-{
-	const char* p_buf = (const char*) data;
-
-	/* Handle leading misaligned bytes */
-	size_t initial_bytes = (sizeof(int32) - (intptr_t) p_buf) & (sizeof(int32) - 1);
-	if (length < initial_bytes)
-		initial_bytes = length;
-	for (size_t li = 0; li < initial_bytes; li++)
-	{
-		crc = crc_tableil8_o32[(crc ^ *p_buf++) & 0x000000FF] ^ (crc >> 8);
-	}
-
-	length -= initial_bytes;
-	size_t running_length = length & ~(sizeof(uint64) - 1);
-	size_t end_bytes = length - running_length;
-
-	for (size_t li = 0; li < running_length / 8; li++)
-	{
-		crc ^= *(uint32*) p_buf;
-		p_buf += 4;
-		uint32 term1 = crc_tableil8_o88[crc & 0x000000FF]
-				^ crc_tableil8_o80[(crc >> 8) & 0x000000FF];
-		uint32 term2 = crc >> 16;
-		crc = term1 ^ crc_tableil8_o72[term2 & 0x000000FF]
-				^ crc_tableil8_o64[(term2 >> 8) & 0x000000FF];
-		term1 = crc_tableil8_o56[(*(uint32 *) p_buf) & 0x000000FF]
-				^ crc_tableil8_o48[((*(uint32 *) p_buf) >> 8) & 0x000000FF];
-
-		term2 = (*(uint32 *) p_buf) >> 16;
-		crc = crc ^ term1 ^ crc_tableil8_o40[term2 & 0x000000FF]
-				^ crc_tableil8_o32[(term2 >> 8) & 0x000000FF];
-		p_buf += 4;
-	}
-
-	for (size_t li = 0; li < end_bytes; li++)
-	{
-		crc = crc_tableil8_o32[(crc ^ *p_buf++) & 0x000000FF] ^ (crc >> 8);
-	}
-
-	return crc;
-}
-
-#if (defined(__X86__) || defined(__i386__) || defined(i386) || defined(_M_IX86) || defined(__386__) || defined(__x86_64__) || defined(_M_X64))
-#pragma GCC target ("sse4.2")
-#include <nmmintrin.h>
-
-/* Hardware-accelerated CRC-32C (using CRC32 instruction) */
-pg_crc32
-crc32cHardware32(pg_crc32 crc, const void* data, int length)
-{
-	const char* p_buf = (const char*) data;
-	/* alignment doesn't seem to help? */
-	for (int i = 0; i < length / sizeof(uint32); i++)
-	{
-		crc = _mm_crc32_u32(crc, *(uint32*) p_buf);
-		p_buf += sizeof(uint32);
-	}
-
-	/* This ugly switch is slightly faster for short strings than the straightforward loop */
-	length &= sizeof(uint32) - 1;
-	switch (length)
-	{
-	case 3:
-		crc = _mm_crc32_u8(crc, *p_buf++);
-	case 2:
-		crc = _mm_crc32_u16(crc, *(uint16_t*) p_buf);
-		break;
-	case 1:
-		crc = _mm_crc32_u8(crc, *p_buf);
-		break;
-	case 0:
-		break;
-	default:
-		/* This should never happen */
-		/*Assert(false);*/
-		;
-	}
-
-	return crc;
-}
-
-
-/* Hardware-accelerated CRC-32C (using CRC32 instruction) */
-pg_crc32
-crc32cHardware64(pg_crc32 crc, const void* data, int length)
-{
-#ifndef __LP64__
-    return crc32cHardware32(crc, data, length);
-#else
-    const char* p_buf = (const char*) data;
-    uint64 crc64bit = crc;
-
-    for (int i = 0; i < length / sizeof(uint64); i++)
-    {
-        crc64bit = _mm_crc32_u64(crc64bit, *(uint64*) p_buf);
-        p_buf += sizeof(uint64);
-    }
-
-    uint32 crc32bit = (uint32) crc64bit;
-    length &= 7;  /* same as mod 8 */
-
-    /* Depending on remaining length, use a combination of 32, 16, and 8 bit crc32 instructions */
-    switch (length)
-    {
-        case 7:
-            crc32bit = _mm_crc32_u8(crc32bit, *p_buf++);
-        case 6:
-            crc32bit = _mm_crc32_u16(crc32bit, *(uint16*) p_buf);
-            p_buf += 2;
-        /* case 5 is below: 4 + 1 */
-        case 4:
-            crc32bit = _mm_crc32_u32(crc32bit, *(uint32*) p_buf);
-            break;
-        case 3:
-            crc32bit = _mm_crc32_u8(crc32bit, *p_buf++);
-        case 2:
-            crc32bit = _mm_crc32_u16(crc32bit, *(uint16*) p_buf);
-            break;
-        case 5:
-            crc32bit = _mm_crc32_u32(crc32bit, *(uint32*) p_buf);
-            p_buf += 4;
-        case 1:
-            crc32bit = _mm_crc32_u8(crc32bit, *p_buf);
-            break;
-        case 0:
-            break;
-    }
-
-    return crc32bit;
-#endif
-}
-
-#include <cpuid.h>
-
-/*
- * Detect if we have new Intel CPU instructions
- * This gets called the first time someone tries to use crc32c.
- */
-
-pg_crc32
-crc32cDetectBestMethod(pg_crc32 crc, const void* data, int length)
-{
-	uint32 eax,ebx,ecx=0,edx;
-
-	/*
-	 * get the CPU features (level 1). ecx will have the SSE4.2 bit.
-	 * This gcc routine automatically handles saving ebx in the case where we are -fpic or -fPIC
-	 */
-	__get_cpuid(1, &eax, &ebx, &ecx, &edx);
-
-	bool hasSSE42 = (ecx & bit_SSE4_2) != 0;
-	if (hasSSE42)
-	{
-#ifdef __LP64__
-		crc32c = &crc32cHardware64;
-#else
-		crc32c= &crc32cHardware32;
-#endif
-	}
-	else
-		crc32c = &crc32cSlicingBy8;
-
-	return crc32c(crc, data, length);
-}
-
-/* Function pointers to functions customized for the hardware platform */
-CRC32CFunctionPtr crc32c = &crc32cDetectBestMethod;
-
-#else
-/*
- * If not x86, we don't have hardware crc.  We might even not be little-endian.
- * play it safe, and use the stupid slow but 100% portable code.
- */
-extern pg_crc32
-crc32cSimple(pg_crc32 crc, const void* data, int length);
-
-pg_crc32
-crc32cSimple(pg_crc32 crc, const void* data, int length)
-{
-    const char* p_buf = (const char*) data;
-    const char* p_end = p_buf + length;
-
-    while (p_buf < p_end) {
-    crc = crc_tableil8_o32[(crc ^ *p_buf++) & 0x000000FF] ^ (crc >> 8);
-    }
-
-    return crc;
-}
-
-CRC32CFunctionPtr crc32c = &crc32cSimple;
-#endif
-
-

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/f988a712/src/backend/utils/hash/pg_crc.c
----------------------------------------------------------------------
diff --git a/src/backend/utils/hash/pg_crc.c b/src/backend/utils/hash/pg_crc.c
index 27eb4d2..7a25dd1 100644
--- a/src/backend/utils/hash/pg_crc.c
+++ b/src/backend/utils/hash/pg_crc.c
@@ -7,30 +7,28 @@
  * A PAINLESS GUIDE TO CRC ERROR DETECTION ALGORITHMS, available from
  * http://www.ross.net/crc/download/crc_v3.txt or several other net sites.
  *
- * We use a normal (not "reflected", in Williams' terms) CRC, using initial
- * all-ones register contents and a final bit inversion.
  *
- * The 64-bit variant is not used as of PostgreSQL 8.1, but we retain the
- * code for possible future use.
- *
- *
- * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1996-2015, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/utils/hash/pg_crc.c,v 1.21 2009/01/01 17:23:51 momjian Exp $
+ *	  src/backend/utils/hash/pg_crc.c
  *
  *-------------------------------------------------------------------------
  */
 
 /* Use c.h so that this file can be built in either frontend or backend */
 #include "c.h"
+#include "utils/pg_crc.h"
 
 /*
+ * Lookup table for calculating CRC-32 using Sarwate's algorithm.
+ *
  * This table is based on the polynomial
  *	x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1.
  * (This is the same polynomial used in Ethernet checksums, for instance.)
+ * Using Williams' terms, this is the "normal", not "reflected" version.
  */
 const uint32 pg_crc32_table[256] = {
 	0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA,
@@ -99,416 +97,3 @@ const uint32 pg_crc32_table[256] = {
 	0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
 };
 
-
-#ifdef PROVIDE_64BIT_CRC
-
-/*
- * This table is based on the polynomial
- *
- * x^64 + x^62 + x^57 + x^55 + x^54 + x^53 + x^52 + x^47 + x^46 + x^45 +
- * x^40 + x^39 + x^38 + x^37 + x^35 + x^33 + x^32 + x^31 + x^29 + x^27 +
- * x^24 + x^23 + x^22 + x^21 + x^19 + x^17 + x^13 + x^12 + x^10 + x^9 +
- * x^7 + x^4 + x + 1
- *
- * which is borrowed from the DLT1 spec
- * (ECMA-182, available from http://www.ecma.ch/ecma1/STAND/ECMA-182.HTM)
- */
-
-#ifdef INT64_IS_BUSTED
-
-const uint32 pg_crc64_table0[256] = {
-	0x00000000, 0xA9EA3693,
-	0x53D46D26, 0xFA3E5BB5,
-	0x0E42ECDF, 0xA7A8DA4C,
-	0x5D9681F9, 0xF47CB76A,
-	0x1C85D9BE, 0xB56FEF2D,
-	0x4F51B498, 0xE6BB820B,
-	0x12C73561, 0xBB2D03F2,
-	0x41135847, 0xE8F96ED4,
-	0x90E185EF, 0x390BB37C,
-	0xC335E8C9, 0x6ADFDE5A,
-	0x9EA36930, 0x37495FA3,
-	0xCD770416, 0x649D3285,
-	0x8C645C51, 0x258E6AC2,
-	0xDFB03177, 0x765A07E4,
-	0x8226B08E, 0x2BCC861D,
-	0xD1F2DDA8, 0x7818EB3B,
-	0x21C30BDE, 0x88293D4D,
-	0x721766F8, 0xDBFD506B,
-	0x2F81E701, 0x866BD192,
-	0x7C558A27, 0xD5BFBCB4,
-	0x3D46D260, 0x94ACE4F3,
-	0x6E92BF46, 0xC77889D5,
-	0x33043EBF, 0x9AEE082C,
-	0x60D05399, 0xC93A650A,
-	0xB1228E31, 0x18C8B8A2,
-	0xE2F6E317, 0x4B1CD584,
-	0xBF6062EE, 0x168A547D,
-	0xECB40FC8, 0x455E395B,
-	0xADA7578F, 0x044D611C,
-	0xFE733AA9, 0x57990C3A,
-	0xA3E5BB50, 0x0A0F8DC3,
-	0xF031D676, 0x59DBE0E5,
-	0xEA6C212F, 0x438617BC,
-	0xB9B84C09, 0x10527A9A,
-	0xE42ECDF0, 0x4DC4FB63,
-	0xB7FAA0D6, 0x1E109645,
-	0xF6E9F891, 0x5F03CE02,
-	0xA53D95B7, 0x0CD7A324,
-	0xF8AB144E, 0x514122DD,
-	0xAB7F7968, 0x02954FFB,
-	0x7A8DA4C0, 0xD3679253,
-	0x2959C9E6, 0x80B3FF75,
-	0x74CF481F, 0xDD257E8C,
-	0x271B2539, 0x8EF113AA,
-	0x66087D7E, 0xCFE24BED,
-	0x35DC1058, 0x9C3626CB,
-	0x684A91A1, 0xC1A0A732,
-	0x3B9EFC87, 0x9274CA14,
-	0xCBAF2AF1, 0x62451C62,
-	0x987B47D7, 0x31917144,
-	0xC5EDC62E, 0x6C07F0BD,
-	0x9639AB08, 0x3FD39D9B,
-	0xD72AF34F, 0x7EC0C5DC,
-	0x84FE9E69, 0x2D14A8FA,
-	0xD9681F90, 0x70822903,
-	0x8ABC72B6, 0x23564425,
-	0x5B4EAF1E, 0xF2A4998D,
-	0x089AC238, 0xA170F4AB,
-	0x550C43C1, 0xFCE67552,
-	0x06D82EE7, 0xAF321874,
-	0x47CB76A0, 0xEE214033,
-	0x141F1B86, 0xBDF52D15,
-	0x49899A7F, 0xE063ACEC,
-	0x1A5DF759, 0xB3B7C1CA,
-	0x7D3274CD, 0xD4D8425E,
-	0x2EE619EB, 0x870C2F78,
-	0x73709812, 0xDA9AAE81,
-	0x20A4F534, 0x894EC3A7,
-	0x61B7AD73, 0xC85D9BE0,
-	0x3263C055, 0x9B89F6C6,
-	0x6FF541AC, 0xC61F773F,
-	0x3C212C8A, 0x95CB1A19,
-	0xEDD3F122, 0x4439C7B1,
-	0xBE079C04, 0x17EDAA97,
-	0xE3911DFD, 0x4A7B2B6E,
-	0xB04570DB, 0x19AF4648,
-	0xF156289C, 0x58BC1E0F,
-	0xA28245BA, 0x0B687329,
-	0xFF14C443, 0x56FEF2D0,
-	0xACC0A965, 0x052A9FF6,
-	0x5CF17F13, 0xF51B4980,
-	0x0F251235, 0xA6CF24A6,
-	0x52B393CC, 0xFB59A55F,
-	0x0167FEEA, 0xA88DC879,
-	0x4074A6AD, 0xE99E903E,
-	0x13A0CB8B, 0xBA4AFD18,
-	0x4E364A72, 0xE7DC7CE1,
-	0x1DE22754, 0xB40811C7,
-	0xCC10FAFC, 0x65FACC6F,
-	0x9FC497DA, 0x362EA149,
-	0xC2521623, 0x6BB820B0,
-	0x91867B05, 0x386C4D96,
-	0xD0952342, 0x797F15D1,
-	0x83414E64, 0x2AAB78F7,
-	0xDED7CF9D, 0x773DF90E,
-	0x8D03A2BB, 0x24E99428,
-	0x975E55E2, 0x3EB46371,
-	0xC48A38C4, 0x6D600E57,
-	0x991CB93D, 0x30F68FAE,
-	0xCAC8D41B, 0x6322E288,
-	0x8BDB8C5C, 0x2231BACF,
-	0xD80FE17A, 0x71E5D7E9,
-	0x85996083, 0x2C735610,
-	0xD64D0DA5, 0x7FA73B36,
-	0x07BFD00D, 0xAE55E69E,
-	0x546BBD2B, 0xFD818BB8,
-	0x09FD3CD2, 0xA0170A41,
-	0x5A2951F4, 0xF3C36767,
-	0x1B3A09B3, 0xB2D03F20,
-	0x48EE6495, 0xE1045206,
-	0x1578E56C, 0xBC92D3FF,
-	0x46AC884A, 0xEF46BED9,
-	0xB69D5E3C, 0x1F7768AF,
-	0xE549331A, 0x4CA30589,
-	0xB8DFB2E3, 0x11358470,
-	0xEB0BDFC5, 0x42E1E956,
-	0xAA188782, 0x03F2B111,
-	0xF9CCEAA4, 0x5026DC37,
-	0xA45A6B5D, 0x0DB05DCE,
-	0xF78E067B, 0x5E6430E8,
-	0x267CDBD3, 0x8F96ED40,
-	0x75A8B6F5, 0xDC428066,
-	0x283E370C, 0x81D4019F,
-	0x7BEA5A2A, 0xD2006CB9,
-	0x3AF9026D, 0x931334FE,
-	0x692D6F4B, 0xC0C759D8,
-	0x34BBEEB2, 0x9D51D821,
-	0x676F8394, 0xCE85B507
-};
-
-const uint32 pg_crc64_table1[256] = {
-	0x00000000, 0x42F0E1EB,
-	0x85E1C3D7, 0xC711223C,
-	0x49336645, 0x0BC387AE,
-	0xCCD2A592, 0x8E224479,
-	0x9266CC8A, 0xD0962D61,
-	0x17870F5D, 0x5577EEB6,
-	0xDB55AACF, 0x99A54B24,
-	0x5EB46918, 0x1C4488F3,
-	0x663D78FF, 0x24CD9914,
-	0xE3DCBB28, 0xA12C5AC3,
-	0x2F0E1EBA, 0x6DFEFF51,
-	0xAAEFDD6D, 0xE81F3C86,
-	0xF45BB475, 0xB6AB559E,
-	0x71BA77A2, 0x334A9649,
-	0xBD68D230, 0xFF9833DB,
-	0x388911E7, 0x7A79F00C,
-	0xCC7AF1FF, 0x8E8A1014,
-	0x499B3228, 0x0B6BD3C3,
-	0x854997BA, 0xC7B97651,
-	0x00A8546D, 0x4258B586,
-	0x5E1C3D75, 0x1CECDC9E,
-	0xDBFDFEA2, 0x990D1F49,
-	0x172F5B30, 0x55DFBADB,
-	0x92CE98E7, 0xD03E790C,
-	0xAA478900, 0xE8B768EB,
-	0x2FA64AD7, 0x6D56AB3C,
-	0xE374EF45, 0xA1840EAE,
-	0x66952C92, 0x2465CD79,
-	0x3821458A, 0x7AD1A461,
-	0xBDC0865D, 0xFF3067B6,
-	0x711223CF, 0x33E2C224,
-	0xF4F3E018, 0xB60301F3,
-	0xDA050215, 0x98F5E3FE,
-	0x5FE4C1C2, 0x1D142029,
-	0x93366450, 0xD1C685BB,
-	0x16D7A787, 0x5427466C,
-	0x4863CE9F, 0x0A932F74,
-	0xCD820D48, 0x8F72ECA3,
-	0x0150A8DA, 0x43A04931,
-	0x84B16B0D, 0xC6418AE6,
-	0xBC387AEA, 0xFEC89B01,
-	0x39D9B93D, 0x7B2958D6,
-	0xF50B1CAF, 0xB7FBFD44,
-	0x70EADF78, 0x321A3E93,
-	0x2E5EB660, 0x6CAE578B,
-	0xABBF75B7, 0xE94F945C,
-	0x676DD025, 0x259D31CE,
-	0xE28C13F2, 0xA07CF219,
-	0x167FF3EA, 0x548F1201,
-	0x939E303D, 0xD16ED1D6,
-	0x5F4C95AF, 0x1DBC7444,
-	0xDAAD5678, 0x985DB793,
-	0x84193F60, 0xC6E9DE8B,
-	0x01F8FCB7, 0x43081D5C,
-	0xCD2A5925, 0x8FDAB8CE,
-	0x48CB9AF2, 0x0A3B7B19,
-	0x70428B15, 0x32B26AFE,
-	0xF5A348C2, 0xB753A929,
-	0x3971ED50, 0x7B810CBB,
-	0xBC902E87, 0xFE60CF6C,
-	0xE224479F, 0xA0D4A674,
-	0x67C58448, 0x253565A3,
-	0xAB1721DA, 0xE9E7C031,
-	0x2EF6E20D, 0x6C0603E6,
-	0xF6FAE5C0, 0xB40A042B,
-	0x731B2617, 0x31EBC7FC,
-	0xBFC98385, 0xFD39626E,
-	0x3A284052, 0x78D8A1B9,
-	0x649C294A, 0x266CC8A1,
-	0xE17DEA9D, 0xA38D0B76,
-	0x2DAF4F0F, 0x6F5FAEE4,
-	0xA84E8CD8, 0xEABE6D33,
-	0x90C79D3F, 0xD2377CD4,
-	0x15265EE8, 0x57D6BF03,
-	0xD9F4FB7A, 0x9B041A91,
-	0x5C1538AD, 0x1EE5D946,
-	0x02A151B5, 0x4051B05E,
-	0x87409262, 0xC5B07389,
-	0x4B9237F0, 0x0962D61B,
-	0xCE73F427, 0x8C8315CC,
-	0x3A80143F, 0x7870F5D4,
-	0xBF61D7E8, 0xFD913603,
-	0x73B3727A, 0x31439391,
-	0xF652B1AD, 0xB4A25046,
-	0xA8E6D8B5, 0xEA16395E,
-	0x2D071B62, 0x6FF7FA89,
-	0xE1D5BEF0, 0xA3255F1B,
-	0x64347D27, 0x26C49CCC,
-	0x5CBD6CC0, 0x1E4D8D2B,
-	0xD95CAF17, 0x9BAC4EFC,
-	0x158E0A85, 0x577EEB6E,
-	0x906FC952, 0xD29F28B9,
-	0xCEDBA04A, 0x8C2B41A1,
-	0x4B3A639D, 0x09CA8276,
-	0x87E8C60F, 0xC51827E4,
-	0x020905D8, 0x40F9E433,
-	0x2CFFE7D5, 0x6E0F063E,
-	0xA91E2402, 0xEBEEC5E9,
-	0x65CC8190, 0x273C607B,
-	0xE02D4247, 0xA2DDA3AC,
-	0xBE992B5F, 0xFC69CAB4,
-	0x3B78E888, 0x79880963,
-	0xF7AA4D1A, 0xB55AACF1,
-	0x724B8ECD, 0x30BB6F26,
-	0x4AC29F2A, 0x08327EC1,
-	0xCF235CFD, 0x8DD3BD16,
-	0x03F1F96F, 0x41011884,
-	0x86103AB8, 0xC4E0DB53,
-	0xD8A453A0, 0x9A54B24B,
-	0x5D459077, 0x1FB5719C,
-	0x919735E5, 0xD367D40E,
-	0x1476F632, 0x568617D9,
-	0xE085162A, 0xA275F7C1,
-	0x6564D5FD, 0x27943416,
-	0xA9B6706F, 0xEB469184,
-	0x2C57B3B8, 0x6EA75253,
-	0x72E3DAA0, 0x30133B4B,
-	0xF7021977, 0xB5F2F89C,
-	0x3BD0BCE5, 0x79205D0E,
-	0xBE317F32, 0xFCC19ED9,
-	0x86B86ED5, 0xC4488F3E,
-	0x0359AD02, 0x41A94CE9,
-	0xCF8B0890, 0x8D7BE97B,
-	0x4A6ACB47, 0x089A2AAC,
-	0x14DEA25F, 0x562E43B4,
-	0x913F6188, 0xD3CF8063,
-	0x5DEDC41A, 0x1F1D25F1,
-	0xD80C07CD, 0x9AFCE626
-};
-#else							/* int64 works */
-
-const uint64 pg_crc64_table[256] = {
-	UINT64CONST(0x0000000000000000), UINT64CONST(0x42F0E1EBA9EA3693),
-	UINT64CONST(0x85E1C3D753D46D26), UINT64CONST(0xC711223CFA3E5BB5),
-	UINT64CONST(0x493366450E42ECDF), UINT64CONST(0x0BC387AEA7A8DA4C),
-	UINT64CONST(0xCCD2A5925D9681F9), UINT64CONST(0x8E224479F47CB76A),
-	UINT64CONST(0x9266CC8A1C85D9BE), UINT64CONST(0xD0962D61B56FEF2D),
-	UINT64CONST(0x17870F5D4F51B498), UINT64CONST(0x5577EEB6E6BB820B),
-	UINT64CONST(0xDB55AACF12C73561), UINT64CONST(0x99A54B24BB2D03F2),
-	UINT64CONST(0x5EB4691841135847), UINT64CONST(0x1C4488F3E8F96ED4),
-	UINT64CONST(0x663D78FF90E185EF), UINT64CONST(0x24CD9914390BB37C),
-	UINT64CONST(0xE3DCBB28C335E8C9), UINT64CONST(0xA12C5AC36ADFDE5A),
-	UINT64CONST(0x2F0E1EBA9EA36930), UINT64CONST(0x6DFEFF5137495FA3),
-	UINT64CONST(0xAAEFDD6DCD770416), UINT64CONST(0xE81F3C86649D3285),
-	UINT64CONST(0xF45BB4758C645C51), UINT64CONST(0xB6AB559E258E6AC2),
-	UINT64CONST(0x71BA77A2DFB03177), UINT64CONST(0x334A9649765A07E4),
-	UINT64CONST(0xBD68D2308226B08E), UINT64CONST(0xFF9833DB2BCC861D),
-	UINT64CONST(0x388911E7D1F2DDA8), UINT64CONST(0x7A79F00C7818EB3B),
-	UINT64CONST(0xCC7AF1FF21C30BDE), UINT64CONST(0x8E8A101488293D4D),
-	UINT64CONST(0x499B3228721766F8), UINT64CONST(0x0B6BD3C3DBFD506B),
-	UINT64CONST(0x854997BA2F81E701), UINT64CONST(0xC7B97651866BD192),
-	UINT64CONST(0x00A8546D7C558A27), UINT64CONST(0x4258B586D5BFBCB4),
-	UINT64CONST(0x5E1C3D753D46D260), UINT64CONST(0x1CECDC9E94ACE4F3),
-	UINT64CONST(0xDBFDFEA26E92BF46), UINT64CONST(0x990D1F49C77889D5),
-	UINT64CONST(0x172F5B3033043EBF), UINT64CONST(0x55DFBADB9AEE082C),
-	UINT64CONST(0x92CE98E760D05399), UINT64CONST(0xD03E790CC93A650A),
-	UINT64CONST(0xAA478900B1228E31), UINT64CONST(0xE8B768EB18C8B8A2),
-	UINT64CONST(0x2FA64AD7E2F6E317), UINT64CONST(0x6D56AB3C4B1CD584),
-	UINT64CONST(0xE374EF45BF6062EE), UINT64CONST(0xA1840EAE168A547D),
-	UINT64CONST(0x66952C92ECB40FC8), UINT64CONST(0x2465CD79455E395B),
-	UINT64CONST(0x3821458AADA7578F), UINT64CONST(0x7AD1A461044D611C),
-	UINT64CONST(0xBDC0865DFE733AA9), UINT64CONST(0xFF3067B657990C3A),
-	UINT64CONST(0x711223CFA3E5BB50), UINT64CONST(0x33E2C2240A0F8DC3),
-	UINT64CONST(0xF4F3E018F031D676), UINT64CONST(0xB60301F359DBE0E5),
-	UINT64CONST(0xDA050215EA6C212F), UINT64CONST(0x98F5E3FE438617BC),
-	UINT64CONST(0x5FE4C1C2B9B84C09), UINT64CONST(0x1D14202910527A9A),
-	UINT64CONST(0x93366450E42ECDF0), UINT64CONST(0xD1C685BB4DC4FB63),
-	UINT64CONST(0x16D7A787B7FAA0D6), UINT64CONST(0x5427466C1E109645),
-	UINT64CONST(0x4863CE9FF6E9F891), UINT64CONST(0x0A932F745F03CE02),
-	UINT64CONST(0xCD820D48A53D95B7), UINT64CONST(0x8F72ECA30CD7A324),
-	UINT64CONST(0x0150A8DAF8AB144E), UINT64CONST(0x43A04931514122DD),
-	UINT64CONST(0x84B16B0DAB7F7968), UINT64CONST(0xC6418AE602954FFB),
-	UINT64CONST(0xBC387AEA7A8DA4C0), UINT64CONST(0xFEC89B01D3679253),
-	UINT64CONST(0x39D9B93D2959C9E6), UINT64CONST(0x7B2958D680B3FF75),
-	UINT64CONST(0xF50B1CAF74CF481F), UINT64CONST(0xB7FBFD44DD257E8C),
-	UINT64CONST(0x70EADF78271B2539), UINT64CONST(0x321A3E938EF113AA),
-	UINT64CONST(0x2E5EB66066087D7E), UINT64CONST(0x6CAE578BCFE24BED),
-	UINT64CONST(0xABBF75B735DC1058), UINT64CONST(0xE94F945C9C3626CB),
-	UINT64CONST(0x676DD025684A91A1), UINT64CONST(0x259D31CEC1A0A732),
-	UINT64CONST(0xE28C13F23B9EFC87), UINT64CONST(0xA07CF2199274CA14),
-	UINT64CONST(0x167FF3EACBAF2AF1), UINT64CONST(0x548F120162451C62),
-	UINT64CONST(0x939E303D987B47D7), UINT64CONST(0xD16ED1D631917144),
-	UINT64CONST(0x5F4C95AFC5EDC62E), UINT64CONST(0x1DBC74446C07F0BD),
-	UINT64CONST(0xDAAD56789639AB08), UINT64CONST(0x985DB7933FD39D9B),
-	UINT64CONST(0x84193F60D72AF34F), UINT64CONST(0xC6E9DE8B7EC0C5DC),
-	UINT64CONST(0x01F8FCB784FE9E69), UINT64CONST(0x43081D5C2D14A8FA),
-	UINT64CONST(0xCD2A5925D9681F90), UINT64CONST(0x8FDAB8CE70822903),
-	UINT64CONST(0x48CB9AF28ABC72B6), UINT64CONST(0x0A3B7B1923564425),
-	UINT64CONST(0x70428B155B4EAF1E), UINT64CONST(0x32B26AFEF2A4998D),
-	UINT64CONST(0xF5A348C2089AC238), UINT64CONST(0xB753A929A170F4AB),
-	UINT64CONST(0x3971ED50550C43C1), UINT64CONST(0x7B810CBBFCE67552),
-	UINT64CONST(0xBC902E8706D82EE7), UINT64CONST(0xFE60CF6CAF321874),
-	UINT64CONST(0xE224479F47CB76A0), UINT64CONST(0xA0D4A674EE214033),
-	UINT64CONST(0x67C58448141F1B86), UINT64CONST(0x253565A3BDF52D15),
-	UINT64CONST(0xAB1721DA49899A7F), UINT64CONST(0xE9E7C031E063ACEC),
-	UINT64CONST(0x2EF6E20D1A5DF759), UINT64CONST(0x6C0603E6B3B7C1CA),
-	UINT64CONST(0xF6FAE5C07D3274CD), UINT64CONST(0xB40A042BD4D8425E),
-	UINT64CONST(0x731B26172EE619EB), UINT64CONST(0x31EBC7FC870C2F78),
-	UINT64CONST(0xBFC9838573709812), UINT64CONST(0xFD39626EDA9AAE81),
-	UINT64CONST(0x3A28405220A4F534), UINT64CONST(0x78D8A1B9894EC3A7),
-	UINT64CONST(0x649C294A61B7AD73), UINT64CONST(0x266CC8A1C85D9BE0),
-	UINT64CONST(0xE17DEA9D3263C055), UINT64CONST(0xA38D0B769B89F6C6),
-	UINT64CONST(0x2DAF4F0F6FF541AC), UINT64CONST(0x6F5FAEE4C61F773F),
-	UINT64CONST(0xA84E8CD83C212C8A), UINT64CONST(0xEABE6D3395CB1A19),
-	UINT64CONST(0x90C79D3FEDD3F122), UINT64CONST(0xD2377CD44439C7B1),
-	UINT64CONST(0x15265EE8BE079C04), UINT64CONST(0x57D6BF0317EDAA97),
-	UINT64CONST(0xD9F4FB7AE3911DFD), UINT64CONST(0x9B041A914A7B2B6E),
-	UINT64CONST(0x5C1538ADB04570DB), UINT64CONST(0x1EE5D94619AF4648),
-	UINT64CONST(0x02A151B5F156289C), UINT64CONST(0x4051B05E58BC1E0F),
-	UINT64CONST(0x87409262A28245BA), UINT64CONST(0xC5B073890B687329),
-	UINT64CONST(0x4B9237F0FF14C443), UINT64CONST(0x0962D61B56FEF2D0),
-	UINT64CONST(0xCE73F427ACC0A965), UINT64CONST(0x8C8315CC052A9FF6),
-	UINT64CONST(0x3A80143F5CF17F13), UINT64CONST(0x7870F5D4F51B4980),
-	UINT64CONST(0xBF61D7E80F251235), UINT64CONST(0xFD913603A6CF24A6),
-	UINT64CONST(0x73B3727A52B393CC), UINT64CONST(0x31439391FB59A55F),
-	UINT64CONST(0xF652B1AD0167FEEA), UINT64CONST(0xB4A25046A88DC879),
-	UINT64CONST(0xA8E6D8B54074A6AD), UINT64CONST(0xEA16395EE99E903E),
-	UINT64CONST(0x2D071B6213A0CB8B), UINT64CONST(0x6FF7FA89BA4AFD18),
-	UINT64CONST(0xE1D5BEF04E364A72), UINT64CONST(0xA3255F1BE7DC7CE1),
-	UINT64CONST(0x64347D271DE22754), UINT64CONST(0x26C49CCCB40811C7),
-	UINT64CONST(0x5CBD6CC0CC10FAFC), UINT64CONST(0x1E4D8D2B65FACC6F),
-	UINT64CONST(0xD95CAF179FC497DA), UINT64CONST(0x9BAC4EFC362EA149),
-	UINT64CONST(0x158E0A85C2521623), UINT64CONST(0x577EEB6E6BB820B0),
-	UINT64CONST(0x906FC95291867B05), UINT64CONST(0xD29F28B9386C4D96),
-	UINT64CONST(0xCEDBA04AD0952342), UINT64CONST(0x8C2B41A1797F15D1),
-	UINT64CONST(0x4B3A639D83414E64), UINT64CONST(0x09CA82762AAB78F7),
-	UINT64CONST(0x87E8C60FDED7CF9D), UINT64CONST(0xC51827E4773DF90E),
-	UINT64CONST(0x020905D88D03A2BB), UINT64CONST(0x40F9E43324E99428),
-	UINT64CONST(0x2CFFE7D5975E55E2), UINT64CONST(0x6E0F063E3EB46371),
-	UINT64CONST(0xA91E2402C48A38C4), UINT64CONST(0xEBEEC5E96D600E57),
-	UINT64CONST(0x65CC8190991CB93D), UINT64CONST(0x273C607B30F68FAE),
-	UINT64CONST(0xE02D4247CAC8D41B), UINT64CONST(0xA2DDA3AC6322E288),
-	UINT64CONST(0xBE992B5F8BDB8C5C), UINT64CONST(0xFC69CAB42231BACF),
-	UINT64CONST(0x3B78E888D80FE17A), UINT64CONST(0x7988096371E5D7E9),
-	UINT64CONST(0xF7AA4D1A85996083), UINT64CONST(0xB55AACF12C735610),
-	UINT64CONST(0x724B8ECDD64D0DA5), UINT64CONST(0x30BB6F267FA73B36),
-	UINT64CONST(0x4AC29F2A07BFD00D), UINT64CONST(0x08327EC1AE55E69E),
-	UINT64CONST(0xCF235CFD546BBD2B), UINT64CONST(0x8DD3BD16FD818BB8),
-	UINT64CONST(0x03F1F96F09FD3CD2), UINT64CONST(0x41011884A0170A41),
-	UINT64CONST(0x86103AB85A2951F4), UINT64CONST(0xC4E0DB53F3C36767),
-	UINT64CONST(0xD8A453A01B3A09B3), UINT64CONST(0x9A54B24BB2D03F20),
-	UINT64CONST(0x5D45907748EE6495), UINT64CONST(0x1FB5719CE1045206),
-	UINT64CONST(0x919735E51578E56C), UINT64CONST(0xD367D40EBC92D3FF),
-	UINT64CONST(0x1476F63246AC884A), UINT64CONST(0x568617D9EF46BED9),
-	UINT64CONST(0xE085162AB69D5E3C), UINT64CONST(0xA275F7C11F7768AF),
-	UINT64CONST(0x6564D5FDE549331A), UINT64CONST(0x279434164CA30589),
-	UINT64CONST(0xA9B6706FB8DFB2E3), UINT64CONST(0xEB46918411358470),
-	UINT64CONST(0x2C57B3B8EB0BDFC5), UINT64CONST(0x6EA7525342E1E956),
-	UINT64CONST(0x72E3DAA0AA188782), UINT64CONST(0x30133B4B03F2B111),
-	UINT64CONST(0xF7021977F9CCEAA4), UINT64CONST(0xB5F2F89C5026DC37),
-	UINT64CONST(0x3BD0BCE5A45A6B5D), UINT64CONST(0x79205D0E0DB05DCE),
-	UINT64CONST(0xBE317F32F78E067B), UINT64CONST(0xFCC19ED95E6430E8),
-	UINT64CONST(0x86B86ED5267CDBD3), UINT64CONST(0xC4488F3E8F96ED40),
-	UINT64CONST(0x0359AD0275A8B6F5), UINT64CONST(0x41A94CE9DC428066),
-	UINT64CONST(0xCF8B0890283E370C), UINT64CONST(0x8D7BE97B81D4019F),
-	UINT64CONST(0x4A6ACB477BEA5A2A), UINT64CONST(0x089A2AACD2006CB9),
-	UINT64CONST(0x14DEA25F3AF9026D), UINT64CONST(0x562E43B4931334FE),
-	UINT64CONST(0x913F6188692D6F4B), UINT64CONST(0xD3CF8063C0C759D8),
-	UINT64CONST(0x5DEDC41A34BBEEB2), UINT64CONST(0x1F1D25F19D51D821),
-	UINT64CONST(0xD80C07CD676F8394), UINT64CONST(0x9AFCE626CE85B507)
-};
-#endif   /* INT64_IS_BUSTED */
-
-#endif   /* PROVIDE_64BIT_CRC */

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/f988a712/src/bin/gpupgrade/.gitignore
----------------------------------------------------------------------
diff --git a/src/bin/gpupgrade/.gitignore b/src/bin/gpupgrade/.gitignore
index 2a4faa6..c58d291 100644
--- a/src/bin/gpupgrade/.gitignore
+++ b/src/bin/gpupgrade/.gitignore
@@ -5,7 +5,6 @@ libgpupgradefuncs.so
 libgpupgradefuncs.so.0
 libgpupgradefuncs.so.0.0
 pg_crc.c
-crc32c.c
 gpmodcatversion
 gpupgrade.so
 .deps

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/f988a712/src/bin/gpupgrade/Makefile
----------------------------------------------------------------------
diff --git a/src/bin/gpupgrade/Makefile b/src/bin/gpupgrade/Makefile
index 0068cce..5ed0890 100644
--- a/src/bin/gpupgrade/Makefile
+++ b/src/bin/gpupgrade/Makefile
@@ -35,7 +35,7 @@ include $(top_builddir)/src/Makefile.global
 LIBS := $(filter-out -lresolv -lbz2, $(LIBS))
 LIBS := $(filter-out -lreadline -ledit -ltermcap -lncurses -lcurses -lcurl -lssl -lz -lpam -lkrb5 -lgssapi_krb5 -lcom_err -lk5crypto -lnuma -lkrb5support, $(LIBS))
 
-MODCAT_OBJS= gpmodcatversion.o pg_crc.o crc32c.o
+MODCAT_OBJS= gpmodcatversion.o pg_crc.o
 DATADIR=$(top_srcdir)/src/test/regress/data
 
 UPGRADEFILES = $(DATADIR)/upgrade/upg2_catupgrade.sql \
@@ -66,9 +66,6 @@ gpmodcatversion: $(MODCAT_OBJS)
 
 pg_crc.c: $(top_srcdir)/src/backend/utils/hash/pg_crc.c
 	rm -f $@ && $(LN_S) $< .
-	
-crc32c.c: $(top_srcdir)/src/backend/utils/hash/crc32c.c
-	rm -f $@ && $(LN_S) $< .
 
 upgradesql:
 	@for i in $(UPGRADEFILES); \
@@ -80,7 +77,6 @@ gpmodcat_clean:
 	rm -f gpmodcatversion$(X)
 	rm -f $(MODCAT_OBJS)
 	rm -f pg_crc.c
-	rm -f crc32c.c
 	
 upgradesql_clean:
 	rm -f $(DATADIR)/upgrade42/*.sql

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/f988a712/src/bin/gpupgrade/gpmodcatversion.c
----------------------------------------------------------------------
diff --git a/src/bin/gpupgrade/gpmodcatversion.c b/src/bin/gpupgrade/gpmodcatversion.c
index 6101bca..9404a99 100644
--- a/src/bin/gpupgrade/gpmodcatversion.c
+++ b/src/bin/gpupgrade/gpmodcatversion.c
@@ -130,7 +130,7 @@ main(int argc, char *argv[])
 						break;
 					}
 				}
-				
+
 				if (!found)
 				{
 					printf(_("\n\"%s\" is not a valid version to "
@@ -147,7 +147,7 @@ main(int argc, char *argv[])
 		DataDir = argv[argno];
 	else
 		DataDir = getenv("PGDATA");
-	
+
 	if (DataDir == NULL)
 	{
 		fprintf(stderr, _("%s: no data directory specified\n"), progname);
@@ -174,19 +174,20 @@ main(int argc, char *argv[])
 	}
 
 	/* Check the CRC. */
-	crc = crc32c(crc32cInit(), &ControlFile, offsetof(ControlFileData, crc));
-	crc32cFinish(crc);
+	INIT_CRC32C(crc);
+ 	COMP_CRC32C(crc, &ControlFile, offsetof(ControlFileData, crc));
+ 	FIN_CRC32C(crc);
 
-	if (!EQ_CRC32(crc, ControlFile.crc))
+	if (!EQ_LEGACY_CRC32(crc, ControlFile.crc))
 	{
 		/* Check the CRC using old algorithm. */
-		INIT_CRC32(crc);
-		COMP_CRC32(crc,
+		INIT_LEGACY_CRC32(crc);
+		COMP_LEGACY_CRC32(crc,
 				   (char *) &ControlFile,
 				   offsetof(ControlFileData, crc));
-		FIN_CRC32(crc);
+		FIN_LEGACY_CRC32(crc);
 
-		if (!EQ_CRC32(crc, ControlFile.crc))
+		if (!EQ_LEGACY_CRC32(crc, ControlFile.crc))
 			printf(_("WARNING: Calculated CRC checksum does not match value stored in file.\n"
 					 "Either the file is corrupt, or it has a different layout than this program\n"
 					 "is expecting.  The results below are untrustworthy.\n\n"));
@@ -218,20 +219,22 @@ main(int argc, char *argv[])
 			close(fd);
 			return 0;
 		}
-		
+
 		printf(_("New catalog version number: %u\n"), tover);
 
 		ControlFile.catalog_version_no = tover;
 
 		/* recalcualte the CRC. */
-		crc = crc32c(crc32cInit(), &ControlFile, offsetof(ControlFileData, crc));
-		crc32cFinish(crc);
+		INIT_CRC32C(crc);
+		COMP_CRC32C(crc, &ControlFile, offsetof(ControlFileData, crc));
+		FIN_CRC32C(crc);
+
 		/*
-		INIT_CRC32(crc);
-		COMP_CRC32(crc,
+		INIT_LEGACY_CRC32(crc);
+		COMP_LEGACY_CRC32(crc,
 				   (char *) &ControlFile,
 				   offsetof(ControlFileData, crc));
-		FIN_CRC32(crc);
+		FIN_LEGACY_CRC32(crc);
 		*/
 		ControlFile.crc = crc;
 

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/f988a712/src/bin/pg_controldata/.gitignore
----------------------------------------------------------------------
diff --git a/src/bin/pg_controldata/.gitignore b/src/bin/pg_controldata/.gitignore
index 790d2be..bef40a7 100644
--- a/src/bin/pg_controldata/.gitignore
+++ b/src/bin/pg_controldata/.gitignore
@@ -1,3 +1,2 @@
 pg_controldata
 pg_crc.c
-crc32c.c

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/f988a712/src/bin/pg_controldata/Makefile
----------------------------------------------------------------------
diff --git a/src/bin/pg_controldata/Makefile b/src/bin/pg_controldata/Makefile
index 96fdfec..7ef5436 100644
--- a/src/bin/pg_controldata/Makefile
+++ b/src/bin/pg_controldata/Makefile
@@ -20,7 +20,7 @@ LIBS := $(filter-out -lreadline -ledit -ltermcap -lncurses -lcurses -lcurl -lssl
 
 override CPPFLAGS += -DFRONTEND
 
-OBJS= pg_controldata.o pg_crc.o crc32c.o $(WIN32RES)
+OBJS= pg_controldata.o pg_crc.o $(WIN32RES)
 
 all: submake-libpgport pg_controldata
 
@@ -30,9 +30,6 @@ pg_controldata: $(OBJS)
 pg_crc.c: $(top_srcdir)/src/backend/utils/hash/pg_crc.c
 	rm -f $@ && $(LN_S) $< .
 	
-crc32c.c: $(top_srcdir)/src/backend/utils/hash/crc32c.c
-	rm -f $@ && $(LN_S) $< .
-
 install: all installdirs
 	$(INSTALL_PROGRAM) pg_controldata$(X) '$(DESTDIR)$(bindir)/pg_controldata$(X)'
 
@@ -43,4 +40,4 @@ uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_controldata$(X)'
 
 clean distclean maintainer-clean:
-	rm -f pg_controldata$(X) $(OBJS) pg_crc.c crc32c.c
+	rm -f pg_controldata$(X) $(OBJS) pg_crc.c

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/f988a712/src/bin/pg_controldata/pg_controldata.c
----------------------------------------------------------------------
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index e66c2dc..ca9cdd7 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -129,23 +129,24 @@ main(int argc, char *argv[])
 	close(fd);
 
 	/* Check the CRC. */
-	crc = crc32c(crc32cInit(), &ControlFile, offsetof(ControlFileData, crc));
-	crc32cFinish(crc);
+	INIT_CRC32C(crc);
+	COMP_CRC32C(crc, &ControlFile, offsetof(ControlFileData, crc));
+	FIN_CRC32C(crc);
 
-	if (!EQ_CRC32(crc, ControlFile.crc))
+	if (!EQ_LEGACY_CRC32(crc, ControlFile.crc))
 	{
 		/*
 		 * Well, the crc doesn't match our computed crc32c value.
 		 * But it might be an old crc32, using the old polynomial.
 		 * If it is, it's OK.
 		 */
-		INIT_CRC32(crc);
-		COMP_CRC32(crc,
+		INIT_LEGACY_CRC32(crc);
+		COMP_LEGACY_CRC32(crc,
 				   (char *) &ControlFile,
 				   offsetof(ControlFileData, crc));
-		FIN_CRC32(crc);
+		FIN_LEGACY_CRC32(crc);
 
-		if (!EQ_CRC32(crc, ControlFile.crc))
+		if (!EQ_LEGACY_CRC32(crc, ControlFile.crc))
 			printf(_("WARNING: Calculated CRC checksum does not match value stored in file.\n"
 					 "Either the file is corrupt, or it has a different layout than this program\n"
 					 "is expecting.  The results below are untrustworthy.\n\n"));

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/f988a712/src/bin/pg_resetxlog/.gitignore
----------------------------------------------------------------------
diff --git a/src/bin/pg_resetxlog/.gitignore b/src/bin/pg_resetxlog/.gitignore
index ea1a57b..6510853 100644
--- a/src/bin/pg_resetxlog/.gitignore
+++ b/src/bin/pg_resetxlog/.gitignore
@@ -1,3 +1,2 @@
 pg_crc.c
-crc32c.c
 pg_resetxlog

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/f988a712/src/bin/pg_resetxlog/Makefile
----------------------------------------------------------------------
diff --git a/src/bin/pg_resetxlog/Makefile b/src/bin/pg_resetxlog/Makefile
index 2ebe78b..1c7594e 100644
--- a/src/bin/pg_resetxlog/Makefile
+++ b/src/bin/pg_resetxlog/Makefile
@@ -21,7 +21,7 @@ LIBS := $(filter-out -lreadline -ledit -ltermcap -lncurses -lcurses -lcurl -lssl
 
 override CPPFLAGS += -DFRONTEND
 
-OBJS= pg_resetxlog.o pg_crc.o crc32c.o $(WIN32RES)
+OBJS= pg_resetxlog.o pg_crc.o $(WIN32RES)
 
 all: submake-libpgport pg_resetxlog
 
@@ -31,9 +31,6 @@ pg_resetxlog: $(OBJS)
 pg_crc.c: $(top_srcdir)/src/backend/utils/hash/pg_crc.c
 	rm -f $@ && $(LN_S) $< .
 	
-crc32c.c: $(top_srcdir)/src/backend/utils/hash/crc32c.c
-	rm -f $@ && $(LN_S) $< .
-
 install: all installdirs
 	$(INSTALL_PROGRAM) pg_resetxlog$(X) '$(DESTDIR)$(bindir)/pg_resetxlog$(X)'
 
@@ -44,4 +41,4 @@ uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_resetxlog$(X)'
 
 clean distclean maintainer-clean:
-	rm -f pg_resetxlog$(X) $(OBJS) pg_crc.c crc32c.c
+	rm -f pg_resetxlog$(X) $(OBJS) pg_crc.c

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/f988a712/src/bin/pg_resetxlog/pg_resetxlog.c
----------------------------------------------------------------------
diff --git a/src/bin/pg_resetxlog/pg_resetxlog.c b/src/bin/pg_resetxlog/pg_resetxlog.c
index b23363a..3c00815 100644
--- a/src/bin/pg_resetxlog/pg_resetxlog.c
+++ b/src/bin/pg_resetxlog/pg_resetxlog.c
@@ -420,10 +420,11 @@ ReadControlFile(void)
 	  ((ControlFileData *) buffer)->pg_control_version == PG_CONTROL_VERSION)
 	{
 		/* Check the CRC. */
-		crc = crc32c(crc32cInit(), buffer, offsetof(ControlFileData, crc));
-		crc32cFinish(crc);
+		INIT_CRC32C(crc);
+		COMP_CRC32C(crc, buffer, offsetof(ControlFileData, crc));
+		FIN_CRC32C(crc);
 
-		if (EQ_CRC32(crc, ((ControlFileData *) buffer)->crc))
+		if (EQ_LEGACY_CRC32(crc, ((ControlFileData *) buffer)->crc))
 		{
 			/* Valid data... */
 			memcpy(&ControlFile, buffer, sizeof(ControlFile));
@@ -431,13 +432,13 @@ ReadControlFile(void)
 		}
 
 		/* Check the CRC using old algorithm. */
-		INIT_CRC32(crc);
-		COMP_CRC32(crc,
+		INIT_LEGACY_CRC32(crc);
+		COMP_LEGACY_CRC32(crc,
 				   buffer,
 				   offsetof(ControlFileData, crc));
-		FIN_CRC32(crc);
+		FIN_LEGACY_CRC32(crc);
 
-		if (EQ_CRC32(crc, ((ControlFileData *) buffer)->crc))
+		if (EQ_LEGACY_CRC32(crc, ((ControlFileData *) buffer)->crc))
 		{
 			/* Valid data... */
 			memcpy(&ControlFile, buffer, sizeof(ControlFile));
@@ -650,14 +651,15 @@ RewriteControlFile(void)
 	ControlFile.minRecoveryPoint.xrecoff = 0;
 
 	/* Contents are protected with a CRC */
-	ControlFile.crc = crc32c(crc32cInit(), &ControlFile, offsetof(ControlFileData, crc));
-	crc32cFinish(ControlFile.crc);
+	INIT_CRC32C(ControlFile.crc);
+	COMP_CRC32C(ControlFile.crc, &ControlFile, offsetof(ControlFileData, crc));
+	FIN_CRC32C(ControlFile.crc);
 	/*
-	INIT_CRC32(ControlFile.crc);
-	COMP_CRC32(ControlFile.crc,
+	INIT_LEGACY_CRC32(ControlFile.crc);
+	COMP_LEGACY_CRC32(ControlFile.crc,
 			   (char *) &ControlFile,
 			   offsetof(ControlFileData, crc));
-	FIN_CRC32(ControlFile.crc);
+	FIN_LEGACY_CRC32(ControlFile.crc);
 	*/
 
 	/*
@@ -814,15 +816,16 @@ WriteEmptyXLOG(void)
 	memcpy(XLogRecGetData(record), &ControlFile.checkPointCopy,
 		   sizeof(CheckPoint));
 
-	crc = crc32c(crc32cInit(), &ControlFile.checkPointCopy, sizeof(CheckPoint));
-	crc = crc32c(crc, (char *) record + sizeof(pg_crc32), SizeOfXLogRecord - sizeof(pg_crc32));
-	crc32cFinish(crc);
+	INIT_CRC32C(crc);
+	COMP_CRC32C(crc, &ControlFile.checkPointCopy, sizeof(CheckPoint));
+	COMP_CRC32C(crc, (char *) record + sizeof(pg_crc32), SizeOfXLogRecord - sizeof(pg_crc32));
+	FIN_CRC32C(crc);
 	/*
-	INIT_CRC32(crc);
-	COMP_CRC32(crc, &ControlFile.checkPointCopy, sizeof(CheckPoint));
-	COMP_CRC32(crc, (char *) record + sizeof(pg_crc32),
+	INIT_LEGACY_CRC32(crc);
+	COMP_LEGACY_CRC32(crc, &ControlFile.checkPointCopy, sizeof(CheckPoint));
+	COMP_LEGACY_CRC32(crc, (char *) record + sizeof(pg_crc32),
 			   SizeOfXLogRecord - sizeof(pg_crc32));
-	FIN_CRC32(crc);
+	FIN_LEGACY_CRC32(crc);
 	*/
 	record->xl_crc = crc;
 

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/f988a712/src/include/access/xlog.h
----------------------------------------------------------------------
diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h
index ce58476..25281da 100644
--- a/src/include/access/xlog.h
+++ b/src/include/access/xlog.h
@@ -18,6 +18,7 @@
 #include "lib/stringinfo.h"
 #include "storage/buf.h"
 #include "utils/pg_crc.h"
+#include "port/pg_crc32c.h"
 #include "utils/relcache.h"
 #include "utils/segadmin.h"
 #include "cdb/cdbpublic.h"

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/f988a712/src/include/catalog/pg_control.h
----------------------------------------------------------------------
diff --git a/src/include/catalog/pg_control.h b/src/include/catalog/pg_control.h
index da4adce..d1a8b20 100644
--- a/src/include/catalog/pg_control.h
+++ b/src/include/catalog/pg_control.h
@@ -19,6 +19,7 @@
 
 #include "access/xlogdefs.h"
 #include "utils/pg_crc.h"
+#include "port/pg_crc32c.h"
 
 
 /* Version identifier for this pg_control format */

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/f988a712/src/include/cdb/cdbappendonlystorage.h
----------------------------------------------------------------------
diff --git a/src/include/cdb/cdbappendonlystorage.h b/src/include/cdb/cdbappendonlystorage.h
index 7a74557..1af998a 100644
--- a/src/include/cdb/cdbappendonlystorage.h
+++ b/src/include/cdb/cdbappendonlystorage.h
@@ -28,6 +28,7 @@
 
 #include "c.h"
 #include "utils/pg_crc.h"
+#include "port/pg_crc32c.h"
 
 /*
  * Small Content.

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/f988a712/src/include/cdb/cdbsreh.h
----------------------------------------------------------------------
diff --git a/src/include/cdb/cdbsreh.h b/src/include/cdb/cdbsreh.h
index 85c15c2..c6b8450 100644
--- a/src/include/cdb/cdbsreh.h
+++ b/src/include/cdb/cdbsreh.h
@@ -6,9 +6,9 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *   http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -32,7 +32,7 @@
 #include "c.h"
 #include "cdb/cdbcopy.h"
 #include "utils/memutils.h"
-
+#include "port/pg_crc32c.h"
 
 /*
  * The error table is ALWAYS of the following format
@@ -48,18 +48,18 @@
 #define NUM_ERRORTABLE_ATTR 8
 #define errtable_cmdtime 1
 #define errtable_relname 2
-#define errtable_filename 3   
-#define errtable_linenum 4    
-#define errtable_bytenum 5    
-#define errtable_errmsg 6    
-#define errtable_rawdata 7    
-#define errtable_rawbytes 8   
+#define errtable_filename 3
+#define errtable_linenum 4
+#define errtable_bytenum 5
+#define errtable_errmsg 6
+#define errtable_rawdata 7
+#define errtable_rawbytes 8
 
 /*
  * In cases of invalid csv input data we end up with not being able to parse the
  * data, resulting in very large data rows. In copy.c we throw an error ("line
- * too long") and continue to try and parse. In some cases this is enough to 
- * recover and continue parsing. However in other cases, especially in input 
+ * too long") and continue to try and parse. In some cases this is enough to
+ * recover and continue parsing. However in other cases, especially in input
  * data that includes a lot of valid embedded newlines, we may never be able to
  * recover from an error and will continue to parse huge lines and abort. In
  * here we try to detect this case and abort the operation.
@@ -87,28 +87,28 @@ typedef struct CdbSreh
 	int		rejectlimit;	/* SEGMENT REJECT LIMIT value */
 	int		rejectcount;	/* how many were rejected so far */
 	bool	is_limit_in_rows; /* ROWS = true, PERCENT = false */
-	
+
 	/* the error table */
 	Relation errtbl;		/* the error table we use (if any) */
 	struct AppendOnlyInsertDescData *err_aoInsertDesc;
 	int err_aosegno;
 	ResultRelSegFileInfo *err_aosegfileinfo;
-	
+
 	/* error table lifespan */
 	bool	is_keep;		/* if true error table should not get DROP'ed */
 	bool	reusing_errtbl; /* true if we are using an existing table (did not auto generate a new one) */
 	bool	should_drop;	/* true if we decide to DROP errtbl at end of execution (depends on previous 2 vars) */
-	
+
 	/* COPY only vars */
 	CdbCopy *cdbcopy;		/* for QD COPY to send bad rows to random QE */
 	int		lastsegid;		/* last QE COPY segid that QD COPY sent bad row to */
-	
+
 	MemoryContext badrowcontext;	/* per-badrow evaluation context */
 	char	   filename[256];		/* "uri [filename]" */
 
 } CdbSreh;
 
-extern CdbSreh *makeCdbSreh(bool is_keep, bool reusing_existing_errtable, 
+extern CdbSreh *makeCdbSreh(bool is_keep, bool reusing_existing_errtable,
 							int rejectlimit,
 							bool is_limit_in_rows, RangeVar *errtbl, ResultRelSegFileInfo *segfileinfo,
 							char *filename, char *relname);

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/f988a712/src/include/pg_config.h.in
----------------------------------------------------------------------
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index 90e1eca..4099bf7 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -686,6 +686,12 @@
 /* Define to 1 if you have the <winldap.h> header file. */
 #undef HAVE_WINLDAP_H
 
+/* Define to 1 if you have __cpuid. */
+#undef HAVE__CPUID
+
+/* Define to 1 if you have __get_cpuid. */
+#undef HAVE__GET_CPUID
+
 /* Define to 1 if you have the <yaml.h> header file. */
 #undef HAVE_YAML_H
 
@@ -819,9 +825,18 @@
 /* Use replacement snprintf() functions. */
 #undef USE_REPL_SNPRINTF
 
+/* Define to 1 to use Intel SSE 4.2 CRC instructions with a runtime check. */
+#undef USE_SLICING_BY_8_CRC32C
+
 /* Define to 1 to build with snmp capabilities. (--enable-snmp) */
 #undef USE_SNMP
 
+/* Define to 1 use Intel SSE 4.2 CRC instructions. */
+#undef USE_SSE42_CRC32C
+
+/* Define to 1 to use Intel SSSE 4.2 CRC instructions with a runtime check. */
+#undef USE_SSE42_CRC32C_WITH_RUNTIME_CHECK
+
 /* Define to build with (Open)SSL support. (--with-openssl) */
 #undef USE_SSL
 

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/f988a712/src/include/pg_config.h.win32
----------------------------------------------------------------------
diff --git a/src/include/pg_config.h.win32 b/src/include/pg_config.h.win32
index 02103eb..daeb310 100755
--- a/src/include/pg_config.h.win32
+++ b/src/include/pg_config.h.win32
@@ -42,7 +42,8 @@
  *
  * HAVE_CBRT, HAVE_FUNCNAME_FUNC, HAVE_FUNCNAME_FUNCTION, HAVE_GETOPT,
  * HAVE_GETOPT_H, HAVE_GETOPT_LONG, HAVE_RINT, HAVE_STRINGS_H, 
- * HAVE_STRTOLL, HAVE_STRTOULL, HAVE_STRUCT_OPTION, ENABLE_THREAD_SAFETY
+ * HAVE_STRTOLL, HAVE_STRTOULL, HAVE_STRUCT_OPTION, ENABLE_THREAD_SAFETY,
+ * USE_SSE42_CRC32C_WITH_RUNTIME_CHECK
  *
  * For now, also HAVE_IPV6
  */
@@ -584,6 +585,12 @@
 /* Define to 1 if you have the <winldap.h> header file. */
 /* #undef HAVE_WINLDAP_H */
 
+/* Define to 1 if you have __cpuid. */
+#define HAVE__CPUID 1
+
+/* Define to 1 if you have __get_cpuid. */
++#undef HAVE__GET_CPUID
+
 /* Define to the appropriate snprintf format for 64-bit ints, if any. */
 #define INT64_FORMAT "%lld"
 
@@ -672,6 +679,19 @@
 /* Use replacement snprintf() functions. */
 #define USE_REPL_SNPRINTF 1
 
+/* Define to 1 to use Intel SSE 4.2 CRC instructions with a runtime check. */
+#if (_MSC_VER < 1500)
+#define USE_SLICING_BY_8_CRC32C 1
+#end
+
+/* Define to 1 use Intel SSE 4.2 CRC instructions. */
+/* #undef USE_SSE42_CRC32C */
+
+/* Define to 1 to use Intel SSSE 4.2 CRC instructions with a runtime check. */
+#if (_MSC_VER >= 1500)
+#define USE_SSE42_CRC32C_WITH_RUNTIME_CHECK
+#endif
+
 /* Define to build with (Open)SSL support. (--with-openssl) */
 /* #undef USE_SSL */
 

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/f988a712/src/include/port/pg_crc32c.h
----------------------------------------------------------------------
diff --git a/src/include/port/pg_crc32c.h b/src/include/port/pg_crc32c.h
new file mode 100644
index 0000000..e69edef
--- /dev/null
+++ b/src/include/port/pg_crc32c.h
@@ -0,0 +1,93 @@
+/*-------------------------------------------------------------------------
+ *
+ * pg_crc32c.h
+ *      Routines for computing CRC-32C checksums.
+ *
+ * The speed of CRC-32C calculation has a big impact on performance, so we
+ * jump through some hoops to get the best implementation for each
+ * platform. Some CPU architectures have special instructions for speeding
+ * up CRC calculations (e.g. Intel SSE 4.2), on other platforms we use the
+ * Slicing-by-8 algorithm which uses lookup tables.
+ *
+ * The public interface consists of four macros:
+ *
+ * INIT_CRC32C(crc)
+ *        Initialize a CRC accumulator
+ *
+ * COMP_CRC32C(crc, data, len)
+ *        Accumulate some (more) bytes into a CRC
+ *
+ * FIN_CRC32C(crc)
+ *        Finish a CRC calculation
+ *
+ * EQ_CRC32C(c1, c2)
+ *        Check for equality of two CRCs.
+ *
+ * Portions Copyright (c) 1996-2015, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ * src/include/port/pg_crc32c.h
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef PG_CRC32C_H
+#define PG_CRC32C_H
+
+typedef uint32 pg_crc32c;
+
+/* The INIT and EQ macros are the same for all implementations. */
+#define INIT_CRC32C(crc) ((crc) = 0xFFFFFFFF)
+#define EQ_CRC32C(c1, c2) ((c1) == (c2))
+
+#if defined(USE_SSE42_CRC32C)
+/* Use SSE4.2 instructions. */
+#define COMP_CRC32C(crc, data, len) \
+  ((crc) = pg_comp_crc32c_sse42((crc), (data), (len)))
+#define FIN_CRC32C(crc) ((crc) ^= 0xFFFFFFFF)
+
+extern pg_crc32c pg_comp_crc32c_sse42(pg_crc32c crc, const void *data, size_t len);
+
+#elif defined(USE_SSE42_CRC32C_WITH_RUNTIME_CHECK)
+/*
+ * Use SSE4.2 instructions, but perform a runtime check first to check that
+ * they are available.
+ */
+#define COMP_CRC32C(crc, data, len) \
+  ((crc) = pg_comp_crc32c((crc), (data), (len)))
+#define FIN_CRC32C(crc) ((crc) ^= 0xFFFFFFFF)
+
+extern pg_crc32c pg_comp_crc32c_sse42(pg_crc32c crc, const void *data, size_t len);
+extern pg_crc32c pg_comp_crc32c_sb8(pg_crc32c crc, const void *data, size_t len);
+extern pg_crc32c (*pg_comp_crc32c) (pg_crc32c crc, const void *data, size_t len);
+
+#else
+/*
+ * Use slicing-by-8 algorithm.
+ *
+ * On big-endian systems, the intermediate value is kept in reverse byte
+ * order, to avoid byte-swapping during the calculation. FIN_CRC32C reverses
+ * the bytes to the final order.
+ */
+#define COMP_CRC32C(crc, data, len) \
+  ((crc) = pg_comp_crc32c_sb8((crc), (data), (len)))
+#ifdef WORDS_BIGENDIAN
+
+#ifdef HAVE__BUILTIN_BSWAP32
+#define BSWAP32(x) __builtin_bswap32(x)
+#else
+#define BSWAP32(x) (((x << 24) & 0xff000000) | \
+                  ((x << 8) & 0x00ff0000) | \
+                  ((x >> 8) & 0x0000ff00) | \
+                  ((x >> 24) & 0x000000ff))
+#endif
+
+#define FIN_CRC32C(crc) ((crc) = BSWAP32(crc) ^ 0xFFFFFFFF)
+#else
+#define FIN_CRC32C(crc) ((crc) ^= 0xFFFFFFFF)
+#endif
+
+extern pg_crc32c pg_comp_crc32c_sb8(pg_crc32c crc, const void *data, size_t len);
+
+#endif
+
+#endif   /* PG_CRC32C_H */

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/f988a712/src/include/utils/pg_crc.h
----------------------------------------------------------------------
diff --git a/src/include/utils/pg_crc.h b/src/include/utils/pg_crc.h
index b544260..9104d8b 100644
--- a/src/include/utils/pg_crc.h
+++ b/src/include/utils/pg_crc.h
@@ -7,14 +7,26 @@
  * A PAINLESS GUIDE TO CRC ERROR DETECTION ALGORITHMS, available from
  * http://www.ross.net/crc/ or several other net sites.
  *
- * We use a normal (not "reflected", in Williams' terms) CRC, using initial
- * all-ones register contents and a final bit inversion.
+ * We have three slightly different variants of a 32-bit CRC calculation:
+ * CRC-32C (Castagnoli polynomial), CRC-32 (Ethernet polynomial), and a legacy
+ * CRC-32 version that uses the lookup table in a funny way. They all consist
+ * of four macros:
  *
- * The 64-bit variant is not used as of PostgreSQL 8.1, but we retain the
- * code for possible future use.
+ * INIT_<variant>(crc)
+ *       Initialize a CRC accumulator
  *
+ * COMP_<variant>(crc, data, len)
+ *     Accumulate some (more) bytes into a CRC
  *
- * Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
+ * FIN_<variant>(crc)
+ *     Finish a CRC calculation
+ *
+ * EQ_<variant>(c1, c2)
+ *      Check for equality of two CRCs.
+ *
+ * The CRC-32C variant is in port/pg_crc32c.h.
+ *
+ * Portions Copyright (c) 1996-2015, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * src/include/utils/pg_crc.h
@@ -22,159 +34,75 @@
 #ifndef PG_CRC_H
 #define PG_CRC_H
 
-/* ugly hack to let this be used in frontend and backend code on Cygwin */
-#ifdef FRONTEND
-#define CRCDLLIMPORT
-#else
-#define CRCDLLIMPORT PGDLLIMPORT
-#endif
-
 typedef uint32 pg_crc32;
 
-/* Initialize a CRC accumulator */
-#define INIT_CRC32(crc) ((crc) = 0xFFFFFFFF)
-
-/* Finish a CRC calculation */
-#define FIN_CRC32(crc)	((crc) ^= 0xFFFFFFFF)
-
-/* Accumulate some (more) bytes into a CRC */
-#define COMP_CRC32(crc, data, len)	\
-do { \
-	unsigned char *__data = (unsigned char *) (data); \
+/*
+ * CRC-32, the same used e.g. in Ethernet.
+ *
+ * This is currently only used in ltree and hstore contrib modules. It uses
+ * the same lookup table as the legacy algorithm below. New code should
+ * use the Castagnoli version instead.
+ */
+#define INIT_TRADITIONAL_CRC32(crc) ((crc) = 0xFFFFFFFF)
+#define FIN_TRADITIONAL_CRC32(crc)    ((crc) ^= 0xFFFFFFFF)
+#define COMP_TRADITIONAL_CRC32(crc, data, len)    \
+  COMP_CRC32_NORMAL_TABLE(crc, data, len, pg_crc32_table)
+#define EQ_TRADITIONAL_CRC32(c1, c2) ((c1) == (c2))
+
+/* Sarwate's algorithm, for use with a "normal" lookup table */
+#define COMP_CRC32_NORMAL_TABLE(crc, data, len, table)              \
+do {                                                            \
+  const unsigned char *__data = (const unsigned char *) (data); \
 	uint32		__len = (len); \
 \
 	while (__len-- > 0) \
 	{ \
-		int		__tab_index = ((int) ((crc) >> 24) ^ *__data++) & 0xFF; \
-		(crc) = pg_crc32_table[__tab_index] ^ ((crc) << 8); \
+      int     __tab_index = ((int) (crc) ^ *__data++) & 0xFF; \
+      (crc) = table[__tab_index] ^ ((crc) >> 8); \
 	} \
 } while (0)
 
-/* Check for equality of two CRCs */
-#define EQ_CRC32(c1,c2)  ((c1) == (c2))
-
-/* Constant table for CRC calculation */
-extern CRCDLLIMPORT const uint32 pg_crc32_table[];
-
-
-#ifdef PROVIDE_64BIT_CRC
-
 /*
- * If we use a 64-bit integer type, then a 64-bit CRC looks just like the
- * usual sort of implementation.  However, we can also fake it with two
- * 32-bit registers.  Experience has shown that the two-32-bit-registers code
- * is as fast as, or even much faster than, the 64-bit code on all but true
- * 64-bit machines.  We use SIZEOF_VOID_P to check the native word width.
+ * The CRC algorithm used for WAL et al in pre-9.5 versions.
+ *
+ * This closely resembles the normal CRC-32 algorithm, but is subtly
+ * different. Using Williams' terms, we use the "normal" table, but with
+ * "reflected" code. That's bogus, but it was like that for years before
+ * anyone noticed. It does not correspond to any polynomial in a normal CRC
+ * algorithm, so it's not clear what the error-detection properties of this
+ * algorithm actually are.
+ *
+ * We still need to carry this around because it is used in a few on-disk
+ * structures that need to be pg_upgradeable. It should not be used in new
+ * code.
  */
 
-#if SIZEOF_VOID_P < 8
+#define INIT_LEGACY_CRC32(crc) ((crc) = 0xFFFFFFFF)
+#define FIN_LEGACY_CRC32(crc) ((crc) ^= 0xFFFFFFFF)
+#define COMP_LEGACY_CRC32(crc, data, len) \
+  COMP_CRC32_REFLECTED_TABLE(crc, data, len, pg_crc32_table)
+#define EQ_LEGACY_CRC32(c1, c2) ((c1) == (c2))
 
 /*
- * crc0 represents the LSBs of the 64-bit value, crc1 the MSBs.  Note that
- * with crc0 placed first, the output of 32-bit and 64-bit implementations
- * will be bit-compatible only on little-endian architectures.	If it were
- * important to make the two possible implementations bit-compatible on
- * all machines, we could do a configure test to decide how to order the
- * two fields, but it seems not worth the trouble.
+ * Sarwate's algorithm, for use with a "reflected" lookup table (but in the
+ * legacy algorithm, we actually use it on a "normal" table, see above)
  */
-typedef struct pg_crc64
-{
-	uint32		crc0;
-	uint32		crc1;
-}	pg_crc64;
-
-/* Initialize a CRC accumulator */
-#define INIT_CRC64(crc) ((crc).crc0 = 0xffffffff, (crc).crc1 = 0xffffffff)
-
-/* Finish a CRC calculation */
-#define FIN_CRC64(crc)	((crc).crc0 ^= 0xffffffff, (crc).crc1 ^= 0xffffffff)
-
-/* Accumulate some (more) bytes into a CRC */
-#define COMP_CRC64(crc, data, len)	\
-do { \
-	uint32		__crc0 = (crc).crc0; \
-	uint32		__crc1 = (crc).crc1; \
-	unsigned char *__data = (unsigned char *) (data); \
-	uint32		__len = (len); \
-\
-	while (__len-- > 0) \
-	{ \
-		int		__tab_index = ((int) (__crc1 >> 24) ^ *__data++) & 0xFF; \
-		__crc1 = pg_crc64_table1[__tab_index] ^ ((__crc1 << 8) | (__crc0 >> 24)); \
-		__crc0 = pg_crc64_table0[__tab_index] ^ (__crc0 << 8); \
-	} \
-	(crc).crc0 = __crc0; \
-	(crc).crc1 = __crc1; \
-} while (0)
-
-/* Check for equality of two CRCs */
-#define EQ_CRC64(c1,c2)  ((c1).crc0 == (c2).crc0 && (c1).crc1 == (c2).crc1)
-
-/* Constant table for CRC calculation */
-extern CRCDLLIMPORT const uint32 pg_crc64_table0[];
-extern CRCDLLIMPORT const uint32 pg_crc64_table1[];
-#else							/* use int64 implementation */
-
-typedef struct pg_crc64
-{
-	uint64		crc0;
-}	pg_crc64;
-
-/* Initialize a CRC accumulator */
-#define INIT_CRC64(crc) ((crc).crc0 = UINT64CONST(0xffffffffffffffff))
-
-/* Finish a CRC calculation */
-#define FIN_CRC64(crc)	((crc).crc0 ^= UINT64CONST(0xffffffffffffffff))
-
-/* Accumulate some (more) bytes into a CRC */
-#define COMP_CRC64(crc, data, len)	\
-do { \
-	uint64		__crc0 = (crc).crc0; \
-	unsigned char *__data = (unsigned char *) (data); \
+#define COMP_CRC32_REFLECTED_TABLE(crc, data, len, table) \
+do {                                                            \
+    const unsigned char *__data = (const unsigned char *) (data); \
 	uint32		__len = (len); \
 \
 	while (__len-- > 0) \
 	{ \
-		int		__tab_index = ((int) (__crc0 >> 56) ^ *__data++) & 0xFF; \
-		__crc0 = pg_crc64_table[__tab_index] ^ (__crc0 << 8); \
+      int     __tab_index = ((int) ((crc) >> 24) ^ *__data++) & 0xFF; \
+      (crc) = table[__tab_index] ^ ((crc) << 8); \
 	} \
-	(crc).crc0 = __crc0; \
 } while (0)
 
-/* Check for equality of two CRCs */
-#define EQ_CRC64(c1,c2)  ((c1).crc0 == (c2).crc0)
-
-/* Constant table for CRC calculation */
-extern CRCDLLIMPORT const uint64 pg_crc64_table[];
-#endif   /* SIZEOF_VOID_P < 8 */
-#endif   /* PROVIDE_64BIT_CRC */
-
-/** Returns the initial value for a CRC32-C computation. */
-static inline pg_crc32 crc32cInit()
-{
-    return 0xFFFFFFFF;
-}
-
-/** Converts a partial CRC32-C computation to the final value. */
-static inline pg_crc32 crc32cFinish(pg_crc32 crc)
-{
-    return ~crc;
-}
-
-
-/** Pointer to a function that computes a CRC32C checksum.
-@arg crc Previous CRC32C value, or crc32c_init().
-@arg data Pointer to the data to be checksummed.
-@arg length length of the data in bytes.
-*/
-typedef pg_crc32 (*CRC32CFunctionPtr)(pg_crc32 crc, const void* data, int length);
-
-extern pg_crc32 crc32cSlicingBy8(pg_crc32 crc, const void* data, int length);
-extern pg_crc32 crc32cHardware32(pg_crc32 crc, const void* data, int length);
-extern pg_crc32 crc32cHardware64(pg_crc32 crc, const void* data, int length);
-
-/** This will map automatically to the "best" CRC implementation. */
-extern CRC32CFunctionPtr crc32c;
-
+/*
+ * Constant table for the CRC-32 polynomials. The same table is used by both
+ * the normal and traditional variants.
+ */
+extern PGDLLIMPORT const uint32 pg_crc32_table[256];
 
 #endif   /* PG_CRC_H */

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/f988a712/src/port/Makefile
----------------------------------------------------------------------
diff --git a/src/port/Makefile b/src/port/Makefile
index 2c7aac9..08eee31 100644
--- a/src/port/Makefile
+++ b/src/port/Makefile
@@ -30,7 +30,7 @@ include $(top_builddir)/src/Makefile.global
 override CPPFLAGS := -I$(top_builddir)/src/port -DFRONTEND $(CPPFLAGS)
 LIBS += $(PTHREAD_LIBS)
 
-OBJS = $(LIBOBJS) chklocale.o copydir.o dirmod.o exec.o noblock.o path.o \
+OBJS = $(LIBOBJS) $(PG_CRC32C_OBJS) chklocale.o copydir.o dirmod.o exec.o noblock.o path.o \
 	pgsleep.o pgstrcasecmp.o qsort.o qsort_arg.o sprompt.o thread.o strlcpy.o strlcat.o
 ifneq (,$(filter $(PORTNAME),cygwin win32))
 OBJS += pipe.o
@@ -58,6 +58,10 @@ libpgport.a: $(OBJS)
 thread.o: thread.c
 	$(CC) $(CFLAGS) $(CPPFLAGS) $(PTHREAD_CFLAGS) -c $<
 
+# pg_crc32c_sse42.o and its _srv.o version need CFLAGS_SSE42
+pg_crc32c_sse42.o: CFLAGS+=$(CFLAGS_SSE42)
+pg_crc32c_sse42_srv.o: CFLAGS+=$(CFLAGS_SSE42)
+
 #
 # Server versions of object files
 #



Mime
View raw message