aboutsummaryrefslogtreecommitdiff
path: root/have
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2021-10-07 11:36:25 +0000
committerOmar Polo <op@omarpolo.com>2021-10-07 11:36:25 +0000
commit492a274fd712e4589669254be327897868e44812 (patch)
treed39c2374afac8475e3a70414d02e188c2ea4cfeb /have
parent207b3e80d867693ff74cf99c84f7dd41386adba1 (diff)
add compat for sys/tree.h
Diffstat (limited to 'have')
-rw-r--r--have/tree_h.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/have/tree_h.c b/have/tree_h.c
new file mode 100644
index 0000000..c9fbe9e
--- /dev/null
+++ b/have/tree_h.c
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/tree.h>
+
+#include <stdio.h>
+
+struct tree {
+ int i;
+ SPLAY_ENTRY(tree) entry;
+};
+SPLAY_HEAD(tree_id, tree);
+
+static int
+tree_cmp(struct tree *a, struct tree *b)
+{
+ if (a->i == b->i)
+ return 0;
+ else if (a->i < b->i)
+ return -1;
+ else
+ return +1;
+}
+
+SPLAY_PROTOTYPE(tree_id, tree, entry, tree_cmp);
+SPLAY_GENERATE(tree_id, tree, entry, tree_cmp);
+
+int
+main(void)
+{
+ return 0;
+}