aboutsummaryrefslogtreecommitdiffstats
path: root/include/init.h
diff options
context:
space:
mode:
authorturret <turret@duck.com>2023-11-19 18:57:55 -0600
committerturret <turret@duck.com>2023-11-19 18:57:55 -0600
commita8b2282eb88f24c3c5f461e1557fa2cf76ebc251 (patch)
tree67544659f7df20e0286cb82e17aa47520a601f14 /include/init.h
downloaddiscord-bot-skeleton-a8b2282eb88f24c3c5f461e1557fa2cf76ebc251.tar.gz
discord-bot-skeleton-a8b2282eb88f24c3c5f461e1557fa2cf76ebc251.tar.bz2
discord-bot-skeleton-a8b2282eb88f24c3c5f461e1557fa2cf76ebc251.zip
Initial commit
- create subsystem system using clone syscall, shared memory, shared file descriptors - printk-like logging facility (TODO: console loglevel) - initcall system (like linux kernel) TODO: determine license factors: linker.ld, linux kernel licensing (some ideas are more liberally taken rather than paraphrased)
Diffstat (limited to 'include/init.h')
-rw-r--r--include/init.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/include/init.h b/include/init.h
new file mode 100644
index 0000000..c9d8cba
--- /dev/null
+++ b/include/init.h
@@ -0,0 +1,23 @@
+#ifndef __INIT_H
+#define __INIT_H
+
+typedef int (*initcall_t)(void);
+typedef initcall_t initcall_entry_t;
+
+#define __define_initcall(fn, id) \
+ static initcall_t __initcall_##fn##id \
+ __attribute__((used)) \
+ __attribute__((section(".initcall" #id ".init"))) = fn
+
+#define l1_initcall(fn) __define_initcall(fn, 1)
+#define l2_initcall(fn) __define_initcall(fn, 2)
+#define l3_initcall(fn) __define_initcall(fn, 3)
+#define l4_initcall(fn) __define_initcall(fn, 4)
+#define l5_initcall(fn) __define_initcall(fn, 5)
+
+static inline initcall_t initcall_from_entry(initcall_entry_t *entry)
+{
+ return *entry;
+}
+
+#endif