PostgreSQL Source Code git master
Loading...
Searching...
No Matches
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 30 of file pg_crc32c_armv8.c.

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

References crc, data, fb(), len, pend, and PointerIsAligned.

Referenced by pg_comp_crc32c_choose().