Consistently use "superuser" instead of "super user"
[pgsql.git] / src / port / pg_crc32c_armv8.c
blob9a6517c9dd91ebb48c3d6f17cd9b7738cca890b1
1 /*-------------------------------------------------------------------------
3 * pg_crc32c_armv8.c
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
10 * IDENTIFICATION
11 * src/port/pg_crc32c_armv8.c
13 *-------------------------------------------------------------------------
15 #include "c.h"
17 #include <arm_acle.h>
19 #include "port/pg_crc32c.h"
21 pg_crc32c
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) &&
33 p + 1 <= pend)
35 crc = __crc32cb(crc, *p);
36 p += 1;
38 if (!PointerIsAligned(p, uint32) &&
39 p + 2 <= pend)
41 crc = __crc32ch(crc, *(uint16 *) p);
42 p += 2;
44 if (!PointerIsAligned(p, uint64) &&
45 p + 4 <= pend)
47 crc = __crc32cw(crc, *(uint32 *) p);
48 p += 4;
51 /* Process eight bytes at a time, as far as we can. */
52 while (p + 8 <= pend)
54 crc = __crc32cd(crc, *(uint64 *) p);
55 p += 8;
58 /* Process remaining 0-7 bytes. */
59 if (p + 4 <= pend)
61 crc = __crc32cw(crc, *(uint32 *) p);
62 p += 4;
64 if (p + 2 <= pend)
66 crc = __crc32ch(crc, *(uint16 *) p);
67 p += 2;
69 if (p < pend)
71 crc = __crc32cb(crc, *p);
74 return crc;