[compiler-rt] [scudo] Support linking with index in IntrusiveList (PR #101262)

Christopher Ferris via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 8 14:09:50 PDT 2024


================
@@ -11,17 +11,103 @@
 
 #include "internal_defs.h"
 
+// TODO: Move the helpers to a header.
+namespace {
+template <typename T> struct isPointer {
+  static constexpr bool value = false;
+};
+
+template <typename T> struct isPointer<T *> {
+  static constexpr bool value = true;
+};
+} // namespace
+
 namespace scudo {
 
 // Intrusive POD singly and doubly linked list.
 // An object with all zero fields should represent a valid empty list. clear()
 // should be called on all non-zero-initialized objects before using.
+//
+// The intrusive list requires the member `Next` (and `Prev` if doubly linked
+// list)` defined in the node type. The type of `Next`/`Prev` can be a pointer
+// or an index to an array. For example, if the storage of the nodes is an
+// array, instead of using pointer type, linking with index type can save some
----------------
cferris1000 wrote:

Small nit:

using a pointer type, linking with an index type

https://github.com/llvm/llvm-project/pull/101262


More information about the llvm-commits mailing list