summaryrefslogtreecommitdiff
path: root/src/user/lib/libc/start.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/user/lib/libc/start.c')
-rw-r--r--src/user/lib/libc/start.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/user/lib/libc/start.c b/src/user/lib/libc/start.c
index f15f90d..3f51fdb 100644
--- a/src/user/lib/libc/start.c
+++ b/src/user/lib/libc/start.c
@@ -1,18 +1,28 @@
#include <tce/syscall.h>
-extern int main(char **args);
+#include <stdio.h>
+
+extern int main(int argc, char **argv);
extern size_t start_ctors, end_ctors, start_dtors, end_dtors;
-void start(char **args) {
- size_t *call;
+void __tce_libc_start(char **args) {
+ // setup stdio
+ term.fd = 0;
+ __tce_libc_fsetup(&term);
+ // call C++ static constructors
+ size_t *call;
for (call = &start_ctors; call < &end_ctors; call++) {
((void(*)(void))*call)();
}
- int ret = main(args);
+ // call main
+ char **lastarg = args;
+ while (*lastarg) lastarg++;
+ int ret = main((lastarg - args), args);
+ // call C++ static destructors
for (call = &start_dtors; call < &end_dtors; call++) {
((void(*)(void))*call)();
}