const unsigned char *nasm_stdmac_find_package(const char *package) { static const struct { const char *package; const unsigned char *macros; } packages[2] = { { "altreg", nasm_stdmac_altreg }, { "smartalign", nasm_stdmac_smartalign }, }; #define UNUSED 16383 static const int16_t hash1[2] = { 0, -1, }; static const int16_t hash2[2] = { 1, UNUSED, }; uint32_t k1, k2; uint64_t crc; uint16_t ix; crc = crc64i(UINT64_C(0x076259c3e291c26c), package); k1 = (uint32_t)crc; k2 = (uint32_t)(crc >> 32); ix = hash1[k1 & 0x1] + hash2[k2 & 0x1]; if (ix >= 2) return NULL; if (nasm_stricmp(packages[ix].package, package)) return NULL; return packages[ix].macros; }
enum preproc_token pp_token_hash(const char *token) { #define UNUSED 16383 static const int16_t hash1[128] = { UNUSED, UNUSED, 0, 0, 0, 0, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, 0, UNUSED, UNUSED, 0, 0, UNUSED, 0, UNUSED, UNUSED, UNUSED, 0, -45, UNUSED, 0, UNUSED, -60, 0, UNUSED, UNUSED, -42, UNUSED, UNUSED, -49, UNUSED, UNUSED, 0, UNUSED, UNUSED, 0, UNUSED, UNUSED, UNUSED, 48, UNUSED, UNUSED, 49, 5, UNUSED, -52, 65, UNUSED, UNUSED, 0, 0, UNUSED, 38, UNUSED, 30, 0, UNUSED, 6, 35, UNUSED, UNUSED, 60, 34, UNUSED, 134, UNUSED, -86, -11, 41, 17, 0, 129, -84, UNUSED, UNUSED, 82, 0, UNUSED, 16, 97, -65, -100, 0, -10, -76, UNUSED, UNUSED, UNUSED, 1, UNUSED, 0, 12, UNUSED, -145, 41, 105, UNUSED, 84, UNUSED, 43, 85, UNUSED, 22, 0, -13, UNUSED, UNUSED, 77, -2, UNUSED, UNUSED, 11, 91, -6, UNUSED, UNUSED, UNUSED, UNUSED, 106, 44, UNUSED, }; static const int16_t hash2[128] = { UNUSED, 0, UNUSED, 0, UNUSED, UNUSED, 0, UNUSED, UNUSED, 0, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, 0, 80, 0, 64, UNUSED, 0, 0, 0, 0, UNUSED, UNUSED, UNUSED, 64, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, 0, 121, 0, UNUSED, 21, 99, 63, UNUSED, 114, UNUSED, 178, UNUSED, UNUSED, UNUSED, 0, UNUSED, -39, UNUSED, 88, UNUSED, UNUSED, UNUSED, UNUSED, 87, UNUSED, 42, UNUSED, UNUSED, 141, UNUSED, UNUSED, UNUSED, 102, UNUSED, 46, 105, 149, UNUSED, 23, 53, 0, UNUSED, UNUSED, UNUSED, 0, UNUSED, UNUSED, UNUSED, 33, 0, 0, 92, UNUSED, 50, 72, UNUSED, 7, 42, 65, UNUSED, UNUSED, 112, 52, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, 98, 100, 71, UNUSED, 19, 63, 32, UNUSED, UNUSED, UNUSED, 96, 17, 84, 132, UNUSED, 37, UNUSED, 9, 20, UNUSED, UNUSED, 75, 97, UNUSED, }; uint32_t k1, k2; uint64_t crc; uint16_t ix; crc = crc64i(UINT64_C(0xaee7ac5ccabdec91), token); k1 = (uint32_t)crc; k2 = (uint32_t)(crc >> 32); ix = hash1[k1 & 0x7f] + hash2[k2 & 0x7f]; if (ix >= 108) return PP_INVALID; if (!pp_directives[ix] || nasm_stricmp(pp_directives[ix], token)) return PP_INVALID; return ix; }