]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
str_hash_find_int
authorAlan Modra <amodra@gmail.com>
Mon, 9 Jun 2025 02:36:00 +0000 (12:06 +0930)
committerAlan Modra <amodra@gmail.com>
Mon, 9 Jun 2025 02:36:00 +0000 (12:06 +0930)
commitb387c0127ea720f2a5d08d8bb7446a15772bc5f5
treef1b94c7076ff30120aa35435828d4c4afaa7b254
parentb3f1e0239c93484b5a06af06a47f833150a3df38
str_hash_find_int

This changes the internal representation of string_tuple.value from
a void* to an intptr_t, removing any concerns that code wanting to
store an integer value will use values that are trap encodings or
suchlike for a pointer.  The ISO C standard says any void* can be
converted to intptr_t and back again and will compare equal to the
original pointer.  It does *not* say any intptr_t can be converted to
void* and back again to get the original integer..

Two new functions, str_hash_find_int and str_hash_insert_int are
provided for handling integer values.  str_hash_find_int returns
(intptr_t) -1 on failing to find the key string.

Most target code need minimal changes to use the new interface, but
some simplification is possible since now a zero can be stored and
differentiated from the NULL "can't find" return.  (Yes, that means
(intptr_t) -1 can't be stored.)

I've changed the avr_no_sreg_hash dummy value to zero, and the
loongarch register numbers don't need to be incremented.  loongarch
also doesn't need to store an empty key string (if it ever did).
gas/config/obj-elf.c
gas/config/tc-avr.c
gas/config/tc-loongarch.c
gas/config/tc-nds32.c
gas/config/tc-riscv.c
gas/config/tc-tilegx.c
gas/config/tc-tilepro.c
gas/hash.h