+2020-08-20 Martin Liska <mliska@suse.cz>
+
+ * as.h: Include hashtab.h.
+ * hash.c (htab_insert): New.
+ (htab_print_statistics): Likewise.
+ * hash.h (htab_insert): Likewise.
+ (htab_print_statistics): Likewise.
+
2020-08-19 Alan Modra <amodra@gmail.com>
* testsuite/gas/ppc/int128.s: Correct vcmpuq.
fprintf (f, "\t%lu empty slots\n", empty);
#endif
}
+
+/* Insert ELEMENT into HTAB. If the element exists, it is overwritten. */
+
+void
+htab_insert (htab_t htab, PTR element)
+{
+ void **slot = htab_find_slot (htab, element, INSERT);
+ if (slot != NULL && htab->del_f)
+ (*htab->del_f) (*slot);
+
+ *slot = element;
+}
+
+/* Print statistics about a hash table. */
+
+void
+htab_print_statistics (FILE *f, const char *name, htab_t table)
+{
+ fprintf (f, "%s hash statistics:\n", name);
+ fprintf (f, "\t%u searches\n", table->searches);
+ fprintf (f, "\t%u collisions\n", table->collisions);
+ fprintf (f, "\t%lu elements\n", (unsigned long) htab_elements (table));
+ fprintf (f, "\t%lu table size\n", (unsigned long) htab_size (table));
+}
\f
#ifdef TEST
extern void hash_print_statistics (FILE *, const char *name,
struct hash_control *);
+/* Insert ELEMENT into HTAB. If the element exists, it is overwritten. */
+
+extern void htab_insert (htab_t, void *);
+
+/* Print statistics about a hash table. */
+
+extern void htab_print_statistics (FILE *f, const char *name, htab_t table);
+
#endif /* HASH_H */