PostgreSQL Source Code git master
pg_crc32c_armv8.c File Reference
#include "c.h"
#include <arm_acle.h>
#include "port/pg_crc32c.h"
Include dependency graph for pg_crc32c_armv8.c:

Go to the source code of this file.

Functions

pg_crc32c pg_comp_crc32c_armv8 (pg_crc32c crc, const void *data, size_t len)
 

Function Documentation

◆ pg_comp_crc32c_armv8()

pg_crc32c pg_comp_crc32c_armv8 ( pg_crc32c  crc,
const void *  data,
size_t  len 
)

Definition at line 26 of file pg_crc32c_armv8.c.

27{
28 const unsigned char *p = data;
29 const unsigned char *pend = p + len;
30
31 /*
32 * ARMv8 doesn't require alignment, but aligned memory access is
33 * significantly faster. Process leading bytes so that the loop below
34 * starts with a pointer aligned to eight bytes.
35 */
36 if (!PointerIsAligned(p, uint16) &&
37 p + 1 <= pend)
38 {
39 crc = __crc32cb(crc, *p);
40 p += 1;
41 }
42 if (!PointerIsAligned(p, uint32) &&
43 p + 2 <= pend)
44 {
45 crc = __crc32ch(crc, *(uint16 *) p);
46 p += 2;
47 }
48 if (!PointerIsAligned(p, uint64) &&
49 p + 4 <= pend)
50 {
51 crc = __crc32cw(crc, *(uint32 *) p);
52 p += 4;
53 }
54
55 /* Process eight bytes at a time, as far as we can. */
56 while (p + 8 <= pend)
57 {
58 crc = __crc32cd(crc, *(uint64 *) p);
59 p += 8;
60 }
61
62 /* Process remaining 0-7 bytes. */
63 if (p + 4 <= pend)
64 {
65 crc = __crc32cw(crc, *(uint32 *) p);
66 p += 4;
67 }
68 if (p + 2 <= pend)
69 {
70 crc = __crc32ch(crc, *(uint16 *) p);
71 p += 2;
72 }
73 if (p < pend)
74 {
75 crc = __crc32cb(crc, *p);
76 }
77
78 return crc;
79}
#define PointerIsAligned(pointer, type)
Definition: c.h:788
uint64_t uint64
Definition: c.h:553
uint16_t uint16
Definition: c.h:551
uint32_t uint32
Definition: c.h:552
const void size_t len
const void * data
return crc
const unsigned char * pend

References crc, data, len, pend, and PointerIsAligned.

Referenced by pg_comp_crc32c_choose().