+/* List of known LWPs, keyed by LWP PID. This speeds up the common
+ case of mapping a PID returned from the kernel to our corresponding
+ lwp_info data structure. */
+static htab_t lwp_lwpid_htab;
+
+/* Calculate a hash from a lwp_info's LWP PID. */
+
+static hashval_t
+lwp_info_hash (const void *ap)
+{
+ const struct lwp_info *lp = (struct lwp_info *) ap;
+ pid_t pid = ptid_get_lwp (lp->ptid);
+
+ return iterative_hash_object (pid, 0);
+}
+
+/* Equality function for the lwp_info hash table. Compares the LWP's
+ PID. */
+
+static int
+lwp_lwpid_htab_eq (const void *a, const void *b)
+{
+ const struct lwp_info *entry = (const struct lwp_info *) a;
+ const struct lwp_info *element = (const struct lwp_info *) b;
+
+ return ptid_get_lwp (entry->ptid) == ptid_get_lwp (element->ptid);
+}
+
+/* Create the lwp_lwpid_htab hash table. */
+
+static void
+lwp_lwpid_htab_create (void)
+{
+ lwp_lwpid_htab = htab_create (100, lwp_info_hash, lwp_lwpid_htab_eq, NULL);
+}
+
+/* Add LP to the hash table. */
+
+static void
+lwp_lwpid_htab_add_lwp (struct lwp_info *lp)
+{
+ void **slot;
+
+ slot = htab_find_slot (lwp_lwpid_htab, lp, INSERT);
+ gdb_assert (slot != NULL && *slot == NULL);
+ *slot = lp;
+}
+
+/* Head of doubly-linked list of known LWPs. Sorted by reverse
+ creation order. This order is assumed in some cases. E.g.,
+ reaping status after killing alls lwps of a process: the leader LWP
+ must be reaped last. */