summaryrefslogtreecommitdiff
path: root/rbtree.h
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2008-10-29 23:29:23 -0700
committerH. Peter Anvin <hpa@zytor.com>2008-10-29 23:31:56 -0700
commit3e364fe27482c09b33c85b401f601ba7ba5c48bb (patch)
tree0d1f05cb5b4329812d4888465e95fa1d1963f261 /rbtree.h
parent034b009e51fd564f912874f2a59549edc358cbca (diff)
downloadnasm-3e364fe27482c09b33c85b401f601ba7ba5c48bb.tar.gz
Left-leaning red-black tree data structure
Implement library functions for "left-leaning red-black trees" with uint64_t keys. This is meant for looking up symbols by address in the backends that need to do so, e.g. ELF. A good question is if there is a better way to do this, that recovers the original symbol, but that's a future issue. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'rbtree.h')
-rw-r--r--rbtree.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/rbtree.h b/rbtree.h
new file mode 100644
index 00000000..3b45428f
--- /dev/null
+++ b/rbtree.h
@@ -0,0 +1,18 @@
+#ifndef NASM_RBTREE_H
+#define NASM_RBTREE_H
+
+#include "compiler.h"
+#include <inttypes.h>
+
+struct rbtree {
+ uint64_t key;
+ void *data;
+ struct rbtree *left, *right;
+ bool red;
+};
+
+struct rbtree *rb_insert(struct rbtree *, uint64_t, void *);
+const struct rbtree *rb_search(const struct rbtree *, uint64_t);
+void rb_free(struct rbtree *);
+
+#endif /* NASM_RBTREE_H */