aboutsummaryrefslogtreecommitdiffhomepage
path: root/embedfilesdir.c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2025-10-13 19:06:52 +0200
committerlemon <lsof@mailbox.org>2025-10-13 19:09:48 +0200
commit9812f88a9a612144bea02c7acf499867eb0cbeb9 (patch)
tree0575b7c6b6b72b0683c4ffae108292b3d44998be /embedfilesdir.c
parent3048a0b59baae16727d0c259353ff4be1ae559b4 (diff)
implement most of preprocessor
- concatenation (##) - builtin macros (__FILE__ etc) - fails in some edge cases, and code needs cleanup - add embedded system include files (stddef.h, stdarg.h for now) - can handle stdio.h now
Diffstat (limited to 'embedfilesdir.c')
-rw-r--r--embedfilesdir.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/embedfilesdir.c b/embedfilesdir.c
new file mode 100644
index 0000000..e2f223b
--- /dev/null
+++ b/embedfilesdir.c
@@ -0,0 +1,34 @@
+#include <stddef.h>
+
+struct embedfile {
+ const char *name;
+ const char *s;
+ size_t len;
+};
+
+#define S(s) (char [4096]){s}, sizeof #s - 1
+
+struct embedfile embedfilesdir[] = {
+{"stddef.h", S("\
+typedef __typeof__((char*)0 - (char*)0) ptrdiff_t;\n\
+typedef __typeof__(sizeof 0) size_t;\n\
+/*typedef __typeof__(L'a') wchar_t;*/\n\
+#define NULL ((void *)0)\n\
+#define offsetof(_Type, _Memb) ((size_t)(&((_Type *)0)->_Memb - (_Type *)0))\n\
+")},
+
+{"stdarg.h", S("\
+typedef __builtin_va_list va_list;\n\
+#ifndef __GNUC_VA_LIST\n\
+#define __GNUC_VA_LIST\n\
+typedef __builtin_va_list __gnuc_va_list;\n\
+#endif\n\
+#define va_start(ap,n) __builtin_va_start(ap)\n\
+#define va_arg(ap,type) __builtin_va_arg(ap, type)\n\
+#define va_copy(dst,src) (void)((dst)=(src))\n\
+#define va_end(ap) __builtin_va_end(ap)\n\
+")},
+ {NULL}
+};
+
+/* vim:set ts=3 sw=3 expandtab: */