10
10
* We use a normal (not "reflected", in Williams' terms) CRC, using initial
11
11
* all-ones register contents and a final bit inversion.
12
12
*
13
- * The 64-bit variant is not used as of PostgreSQL 8.1, but we retain the
14
- * code for possible future use.
15
- *
16
13
*
17
14
* Portions Copyright (c) 1996-2014, PostgreSQL Global Development Group
18
15
* Portions Copyright (c) 1994, Regents of the University of California
@@ -56,97 +53,4 @@ do { \
56
53
/* Constant table for CRC calculation */
57
54
extern CRCDLLIMPORT const uint32 pg_crc32_table [];
58
55
59
-
60
- #ifdef PROVIDE_64BIT_CRC
61
-
62
- /*
63
- * If we use a 64-bit integer type, then a 64-bit CRC looks just like the
64
- * usual sort of implementation. However, we can also fake it with two
65
- * 32-bit registers. Experience has shown that the two-32-bit-registers code
66
- * is as fast as, or even much faster than, the 64-bit code on all but true
67
- * 64-bit machines. We use SIZEOF_VOID_P to check the native word width.
68
- */
69
-
70
- #if SIZEOF_VOID_P < 8
71
-
72
- /*
73
- * crc0 represents the LSBs of the 64-bit value, crc1 the MSBs. Note that
74
- * with crc0 placed first, the output of 32-bit and 64-bit implementations
75
- * will be bit-compatible only on little-endian architectures. If it were
76
- * important to make the two possible implementations bit-compatible on
77
- * all machines, we could do a configure test to decide how to order the
78
- * two fields, but it seems not worth the trouble.
79
- */
80
- typedef struct pg_crc64
81
- {
82
- uint32 crc0 ;
83
- uint32 crc1 ;
84
- } pg_crc64 ;
85
-
86
- /* Initialize a CRC accumulator */
87
- #define INIT_CRC64 (crc ) ((crc).crc0 = 0xffffffff, (crc).crc1 = 0xffffffff)
88
-
89
- /* Finish a CRC calculation */
90
- #define FIN_CRC64 (crc ) ((crc).crc0 ^= 0xffffffff, (crc).crc1 ^= 0xffffffff)
91
-
92
- /* Accumulate some (more) bytes into a CRC */
93
- #define COMP_CRC64 (crc , data , len ) \
94
- do { \
95
- uint32 __crc0 = (crc).crc0; \
96
- uint32 __crc1 = (crc).crc1; \
97
- unsigned char *__data = (unsigned char *) (data); \
98
- uint32 __len = (len); \
99
- \
100
- while (__len-- > 0) \
101
- { \
102
- int __tab_index = ((int) (__crc1 >> 24) ^ *__data++) & 0xFF; \
103
- __crc1 = pg_crc64_table1[__tab_index] ^ ((__crc1 << 8) | (__crc0 >> 24)); \
104
- __crc0 = pg_crc64_table0[__tab_index] ^ (__crc0 << 8); \
105
- } \
106
- (crc).crc0 = __crc0; \
107
- (crc).crc1 = __crc1; \
108
- } while (0)
109
-
110
- /* Check for equality of two CRCs */
111
- #define EQ_CRC64 (c1 ,c2 ) ((c1).crc0 == (c2).crc0 && (c1).crc1 == (c2).crc1)
112
-
113
- /* Constant table for CRC calculation */
114
- extern CRCDLLIMPORT const uint32 pg_crc64_table0 [];
115
- extern CRCDLLIMPORT const uint32 pg_crc64_table1 [];
116
- #else /* use int64 implementation */
117
-
118
- typedef struct pg_crc64
119
- {
120
- uint64 crc0 ;
121
- } pg_crc64 ;
122
-
123
- /* Initialize a CRC accumulator */
124
- #define INIT_CRC64 (crc ) ((crc).crc0 = UINT64CONST(0xffffffffffffffff))
125
-
126
- /* Finish a CRC calculation */
127
- #define FIN_CRC64 (crc ) ((crc).crc0 ^= UINT64CONST(0xffffffffffffffff))
128
-
129
- /* Accumulate some (more) bytes into a CRC */
130
- #define COMP_CRC64 (crc , data , len ) \
131
- do { \
132
- uint64 __crc0 = (crc).crc0; \
133
- unsigned char *__data = (unsigned char *) (data); \
134
- uint32 __len = (len); \
135
- \
136
- while (__len-- > 0) \
137
- { \
138
- int __tab_index = ((int) (__crc0 >> 56) ^ *__data++) & 0xFF; \
139
- __crc0 = pg_crc64_table[__tab_index] ^ (__crc0 << 8); \
140
- } \
141
- (crc).crc0 = __crc0; \
142
- } while (0)
143
-
144
- /* Check for equality of two CRCs */
145
- #define EQ_CRC64 (c1 ,c2 ) ((c1).crc0 == (c2).crc0)
146
-
147
- /* Constant table for CRC calculation */
148
- extern CRCDLLIMPORT const uint64 pg_crc64_table [];
149
- #endif /* SIZEOF_VOID_P < 8 */
150
- #endif /* PROVIDE_64BIT_CRC */
151
-
152
56
#endif /* PG_CRC_H */
0 commit comments