+ const uintptr_t *valid = actually_valid_pair(ht);
+ /* In the empty case, these are "common_mask" and "rehash"
+ * which cannot be 0 */
+ return valid[0] == off || valid[1] == off;
+}
+
+/* Initialize the "actually valid" pair. */
+static inline void init_actually_valid(struct htable *ht)
+{
+ uintptr_t *valid = actually_valid_pair(ht);
+ valid[0] = valid[1] = ((size_t)1 << ht->bits);
+}
+
+/* Add to the "actually valid" pair: there can only ever be two! */
+static COLD void add_actually_valid(struct htable *ht, size_t off)
+{
+ uintptr_t *valid = actually_valid_pair(ht);
+ if (valid[0] == ((size_t)1 << ht->bits))
+ valid[0] = off;
+ else {
+ assert(valid[1] == ((size_t)1 << ht->bits));
+ valid[1] = off;
+ }
+}
+
+static COLD void del_actually_valid(struct htable *ht, size_t off)
+{
+ uintptr_t *validpair = actually_valid_pair(ht);
+ if (validpair[0] == off)
+ validpair[0] = ((size_t)1 << ht->bits);
+ else {
+ assert(validpair[1] == off);
+ validpair[1] = ((size_t)1 << ht->bits);
+ }
+}
+
+/* If this entry looks invalid, check entry_actually_valid! */
+static inline bool entry_looks_invalid(const struct htable *ht, size_t off)
+{
+ return ht->table[off] <= HTABLE_DELETED;
+}
+
+static inline bool entry_is_valid(const struct htable *ht, size_t off)
+{
+ if (!entry_looks_invalid(ht, off))
+ return true;
+ return entry_actually_valid(ht, off);
+}
+
+static inline uintptr_t ht_perfect_mask(const struct htable *ht)
+{
+ return (uintptr_t)2 << ht->perfect_bitnum;