summaryrefslogtreecommitdiff
path: root/crc64.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2007-09-16 17:57:25 -0700
committerH. Peter Anvin <hpa@zytor.com>2007-09-16 18:04:57 -0700
commit97a234782d6fa7fa551a27f2ede452f5a56f1745 (patch)
treee937544cbdb0ac1368b587df71b94d3169726207 /crc64.c
parentd2fb7a699ea8eb953313eead23180986a424271e (diff)
downloadnasm-97a234782d6fa7fa551a27f2ede452f5a56f1745.tar.gz
Switch the preprocessor over to using the hash table library
Switch the preprocessor over to using the hash table library. On my system, this improves the runtime of the output of test/pref/macro.pl from over 600 seconds to 7 seconds. Macros have an odd mix of case-sensitive and case-insensitive behaviour, plus there are matching parameters for arguments, etc. As a result, we use case-insensitive hash tables and use a linked list to store all the possible isomorphs.
Diffstat (limited to 'crc64.c')
-rw-r--r--crc64.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/crc64.c b/crc64.c
index 4a490108..be9a15bc 100644
--- a/crc64.c
+++ b/crc64.c
@@ -1,4 +1,5 @@
#include <inttypes.h>
+#include <ctype.h>
static const uint64_t crc64_tab[256] = {
UINT64_C(0x0000000000000000), UINT64_C(0x7ad870c830358979),
@@ -142,3 +143,16 @@ uint64_t crc64(const char *str)
return crc;
}
+
+uint64_t crc64i(const char *str)
+{
+ uint64_t crc = UINT64_C(0xffffffffffffffff);
+ uint8_t c;
+
+ while ((c = *str++) != 0) {
+ c = tolower(c);
+ crc = crc64_tab[(uint8_t)crc ^ c] ^ (crc >> 8);
+ }
+
+ return crc;
+}