aboutsummaryrefslogtreecommitdiff
path: root/test_runner_list.h
diff options
context:
space:
mode:
Diffstat (limited to 'test_runner_list.h')
-rw-r--r--test_runner_list.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/test_runner_list.h b/test_runner_list.h
new file mode 100644
index 0000000..d84026b
--- /dev/null
+++ b/test_runner_list.h
@@ -0,0 +1,24 @@
+#pragma once
+
+/*
+ * This file is a derivative work of include/linker_lists.h from the U-Boot
+ * project <https://www.denx.de/wiki/U-Boot> and is licensed under GPL-2.0+.
+ *
+ * Copyright (C) 2012 Marek Vasut <marex@denx.de>
+ * Copyright (C) 2021 David Phillips <david@yeah.nah.nz>
+ */
+#define list_head(entry_type, list_name) \
+ ({ static char head[0] __attribute__((__aligned__(4), unused, section(".test_runner_list_2_"#list_name"_1")));(entry_type*)&head; })
+
+#define list_tail(entry_type, list_name) \
+ ({ static char tail[0] __attribute__((__aligned__(4), unused, section(".test_runner_list_2_"#list_name"_3")));(entry_type*)&tail; })
+
+#define list_entry_count(entry_type, list_name) \
+ ({ \
+ entry_type* head = list_head(entry_type, list_name); \
+ entry_type* tail = list_tail(entry_type, list_name); \
+ (size_t)(tail - head); \
+ })
+
+#define list_entry(entry_type, list_name, entry_name) \
+ entry_type _test_runner_list_2_##list_name_2_##entry_name __attribute__((__aligned__(4), unused, section(".test_runner_list_2_"#list_name"_2_"#entry_name)))