1 /*-------------------------------------------------------------------------
4 * Compute CRC-32C checksum using ARMv8 CRC Extension instructions
6 * Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
11 * src/port/pg_crc32c_armv8.c
13 *-------------------------------------------------------------------------
19 #include "port/pg_crc32c.h"
22 pg_comp_crc32c_armv8(pg_crc32c crc
, const void *data
, size_t len
)
24 const unsigned char *p
= data
;
25 const unsigned char *pend
= p
+ len
;
28 * ARMv8 doesn't require alignment, but aligned memory access is
29 * significantly faster. Process leading bytes so that the loop below
30 * starts with a pointer aligned to eight bytes.
32 if (!PointerIsAligned(p
, uint16
) &&
35 crc
= __crc32cb(crc
, *p
);
38 if (!PointerIsAligned(p
, uint32
) &&
41 crc
= __crc32ch(crc
, *(uint16
*) p
);
44 if (!PointerIsAligned(p
, uint64
) &&
47 crc
= __crc32cw(crc
, *(uint32
*) p
);
51 /* Process eight bytes at a time, as far as we can. */
54 crc
= __crc32cd(crc
, *(uint64
*) p
);
58 /* Process remaining 0-7 bytes. */
61 crc
= __crc32cw(crc
, *(uint32
*) p
);
66 crc
= __crc32ch(crc
, *(uint16
*) p
);
71 crc
= __crc32cb(crc
, *p
);