summaryrefslogtreecommitdiff
path: root/hashtbl.c
AgeCommit message (Collapse)AuthorFilesLines
2009-11-06hash_init: check for size being power of twoCyrill Gorcunov1-0/+1
It's really a bug if size is not power of two. We must to be sure all callers are sane. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-11-06hashtbl.c: Unify common hash ops by macrosCyrill Gorcunov1-25/+34
Instead of opencoded repeatable computation use macro helpers. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-10-13style cleanupCyrill Gorcunov1-61/+61
Convert tabs to spaces. Eliminate empty comments. No change on binary level. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-06-28Add copyright headers to the *.c/*.h files in the main directoryH. Peter Anvin1-0/+33
Add copyright headers to the *.c/*.h files in the main directory. For files where I'm sure enough that we have all the approvals, I have given them the 2-BSD license, the others have been given the "LGPL for now" license header. Most of them can probably be changed after auditing. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-06-27hashtbl: make hash_iterate() not crash on an uninitalized tableH. Peter Anvin1-1/+4
Trying to walk an uninitialized table (->table == NULL) should just return nothing. This can happen due when pp_cleanup() is called after a failure. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-05-28hash user allocates struct hash_tableH. Peter Anvin1-7/+4
struct hash_table, a fixed-sized structure, is now allocated by the caller. This lets us integrate it into the Context structure, thus avoiding an additional dynamically allocated object for no good reason. Add some minor code collapsing: make it more obvious that all that differs is a pointer value, rather than relying on the compiler to do tail merging.
2008-05-22Use hash tables even for context-sensitive macrosH. Peter Anvin1-5/+4
Normally, contexts aren't used with a large number of macros, but in case someone does, do use hash tables for those as well. This simplifies the code somewhat, since *all* handling of macros is now done via hash tables. Future note: consider if it wouldn't be better to allow struct hash_table to be allocated by the caller, instead of being allocated by the hash table routine.
2007-10-19Formatting: kill off "stealth whitespace"H. Peter Anvin1-1/+1
"Stealth whitespace" makes it harder to read diffs, and just generally cause unwanted weirdness. Do a source-wide pass to get rid of it.
2007-10-02Portability fixesH. Peter Anvin1-0/+2
Concentrate compiler dependencies to compiler.h; make sure compiler.h is included first in every .c file (since some prototypes may depend on the presence of feature request macros.) Actually use the conditional inclusion of various functions (totally broken in previous releases.)
2007-10-02Use the crc64 we already use as the perfect hash function prehashH. Peter Anvin1-2/+2
Use the same crc64 that we already use for the symbol table hash as the perfect hash function prehash. We appear to get radically faster convergence this way, and the crc64 is probably *faster*, since the table likely to be resident in memory.
2007-09-25Add nasm_zalloc() to nasmlib.cH. Peter Anvin1-3/+1
Add nasm_zalloc(), a wrapper around calloc(), to allocate zero-initialized memory. For large allocations, this is often far more efficient than allocating and zeroing, since the operating system tends to keep a pool of zero pages around.
2007-09-16Switch the preprocessor over to using the hash table libraryH. Peter Anvin1-13/+76
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.
2007-09-14Define a proper hash table libraryH. Peter Anvin1-0/+128
Define a proper hash table library, instead of the current ad hoc stuff used for both labels and macros. This only implements the actual library; it is not yet used. We use a CRC64 as a prehash. This is almost certainly overkill, although it is rather efficient (except, arguably, the table lookup) on 64-bit platforms, and not all that bad on 32-bit platforms. All we really need is a function which produces two independent 32-bit results which are used as the primary and secondary hash respectively. Either way, the prehash function is easily replacable if/when we have a quicker alternative.