Index: uspace/lib/c/include/adt/hash_table.h
===================================================================
--- uspace/lib/c/include/adt/hash_table.h	(revision 87822cef54e5abb65818d91148b7ff319d6292da)
+++ uspace/lib/c/include/adt/hash_table.h	(revision 7a8af2fa103151ca5b466afc1f9b32c774e99d18)
@@ -41,4 +41,5 @@
 #include <stdbool.h>
 #include <macros.h>
+#include <member.h>
 
 /** Opaque hash table link type. */
Index: uspace/lib/c/include/adt/list.h
===================================================================
--- uspace/lib/c/include/adt/list.h	(revision 87822cef54e5abb65818d91148b7ff319d6292da)
+++ uspace/lib/c/include/adt/list.h	(revision 7a8af2fa103151ca5b466afc1f9b32c774e99d18)
@@ -38,4 +38,5 @@
 
 #include <assert.h>
+#include <member.h>
 #include <stdbool.h>
 #include <stddef.h>
@@ -85,8 +86,8 @@
 
 #define list_get_instance(link, type, member) \
-	((type *) (((void *)(link)) - list_link_to_void(&(((type *) NULL)->member))))
+	member_to_inst(link, type, member)
 
 #define list_foreach(list, member, itype, iterator) \
-	for (itype *iterator = NULL; iterator == NULL; iterator = (itype *) 1) \
+	for (itype *iterator = NULL; iterator == NULL; iterator = &((itype *) NULL)[1]) \
 		for (link_t *_link = (list).head.next; \
 		    iterator = list_get_instance(_link, itype, member), \
@@ -94,5 +95,5 @@
 
 #define list_foreach_rev(list, member, itype, iterator) \
-	for (itype *iterator = NULL; iterator == NULL; iterator = (itype *) 1) \
+	for (itype *iterator = NULL; iterator == NULL; iterator = &((itype *) NULL)[1]) \
 		for (link_t *_link = (list).head.prev; \
 		    iterator = list_get_instance(_link, itype, member), \
@@ -154,5 +155,5 @@
 extern bool list_member(const link_t *, const list_t *);
 extern void list_splice(list_t *, link_t *);
-extern unsigned long list_count(const list_t *);
+extern size_t list_count(const list_t *);
 
 /** Returns true if the link is definitely part of a list. False if not sure. */
@@ -394,7 +395,7 @@
  *
  */
-static inline link_t *list_nth(const list_t *list, unsigned long n)
-{
-	unsigned long cnt = 0;
+static inline link_t *list_nth(const list_t *list, size_t n)
+{
+	size_t cnt = 0;
 
 	link_t *link = list_first(list);
Index: uspace/lib/c/include/macros.h
===================================================================
--- uspace/lib/c/include/macros.h	(revision 87822cef54e5abb65818d91148b7ff319d6292da)
+++ uspace/lib/c/include/macros.h	(revision 7a8af2fa103151ca5b466afc1f9b32c774e99d18)
@@ -55,8 +55,4 @@
 	    | ((((uint64_t) (up)) & 0xffffffff) << 32))
 
-#define member_to_inst(ptr_member, type, member_identif) \
-	((type *) (((void *) (ptr_member)) - \
-	    ((void *) &(((type *) 0)->member_identif))))
-
 #define _paddname(line)     PADD_ ## line ## __
 #define _padd(width, line, n)  uint ## width ## _t _paddname(line) [n]
Index: uspace/lib/c/include/member.h
===================================================================
--- uspace/lib/c/include/member.h	(revision 7a8af2fa103151ca5b466afc1f9b32c774e99d18)
+++ uspace/lib/c/include/member.h	(revision 7a8af2fa103151ca5b466afc1f9b32c774e99d18)
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2021 Martin Decky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libc
+ * @{
+ */
+/** @file
+ */
+
+#ifndef _LIBC_MEMBER_H_
+#define _LIBC_MEMBER_H_
+
+#include <stdint.h>
+
+#define member_to_inst(ptr_member, type, member_identif) \
+	((type *) (((uintptr_t) (ptr_member)) - \
+	    offsetof(type, member_identif)))
+
+#endif
+
+/** @}
+ */
