summaryrefslogtreecommitdiff
path: root/nasmlib
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2019-09-23 16:40:03 -0700
committerH. Peter Anvin <hpa@zytor.com>2019-09-23 16:40:03 -0700
commit8571f06061b47471a340e350fdfcd804098637d6 (patch)
treec255ed0e90a4b716e98d6c9b7635bb88b482e212 /nasmlib
parentf7dbdb2e136db99051b14403a0f29c5155bbf7d8 (diff)
downloadnasm-8571f06061b47471a340e350fdfcd804098637d6.tar.gz
preprocessor: major cleanups; inline text into Tokenpp-inline
Major cleanups of the preprocessor. In particular, the block-allocation of Token is pretty ridiculous since nearly every token requires a text allocation anyway. Change the definition of Token so that only very long tokens (48+ characters on 64-bit systems) need to be stored out of line. If malloc() preserves alignment (XXX: glibc doesn't) then this means that each Token will fit in a cache line. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'nasmlib')
-rw-r--r--nasmlib/crc64.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/nasmlib/crc64.c b/nasmlib/crc64.c
index 334cd307..e37e07b6 100644
--- a/nasmlib/crc64.c
+++ b/nasmlib/crc64.c
@@ -1,5 +1,5 @@
/* ----------------------------------------------------------------------- *
- *
+ *
* Copyright 1996-2014 The NASM Authors - All Rights Reserved
* See the file AUTHORS included with the NASM distribution for
* the specific copyright holders.
@@ -14,7 +14,7 @@
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
@@ -35,7 +35,7 @@
#include "nctype.h"
#include "hashtbl.h"
-static const uint64_t crc64_tab[256] = {
+const uint64_t crc64_tab[256] = {
UINT64_C(0x0000000000000000), UINT64_C(0x7ad870c830358979),
UINT64_C(0xf5b0e190606b12f2), UINT64_C(0x8f689158505e9b8b),
UINT64_C(0xc038e5739841b68f), UINT64_C(0xbae095bba8743ff6),
@@ -170,9 +170,8 @@ uint64_t crc64(uint64_t crc, const char *str)
{
uint8_t c;
- while ((c = *str++) != 0) {
- crc = crc64_tab[(uint8_t)crc ^ c] ^ (crc >> 8);
- }
+ while ((c = *str++) != 0)
+ crc = crc64_byte(crc, c);
return crc;
}
@@ -181,9 +180,8 @@ uint64_t crc64i(uint64_t crc, const char *str)
{
uint8_t c;
- while ((c = *str++) != 0) {
- crc = crc64_tab[(uint8_t)crc ^ nasm_tolower(c)] ^ (crc >> 8);
- }
+ while ((c = *str++) != 0)
+ crc = crc64_byte(crc, nasm_tolower(c));
return crc;
}
@@ -192,9 +190,8 @@ uint64_t crc64b(uint64_t crc, const void *data, size_t len)
{
const uint8_t *str = data;
- while (len--) {
- crc = crc64_tab[(uint8_t)crc ^ *str++] ^ (crc >> 8);
- }
+ while (len--)
+ crc = crc64_byte(crc, *str++);
return crc;
}
@@ -203,9 +200,8 @@ uint64_t crc64ib(uint64_t crc, const void *data, size_t len)
{
const uint8_t *str = data;
- while (len--) {
- crc = crc64_tab[(uint8_t)crc ^ nasm_tolower(*str++)] ^ (crc >> 8);
- }
+ while (len--)
+ crc = crc64_byte(crc, nasm_tolower(*str++));
return crc;
}