MCPcopy Create free account
hub / github.com/IntegralPilot/wasm_os / _start

Function _start

stdlib/glue/glue.cpp:4–36  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2#include "src/main.cpp"
3
4extern "C" void _start() {
5// Retrieve command line arguments
6 char* args = getargs(); // Assuming getargs() provides the command line as an array of strings
7
8 // args will be like this
9 // n a m e \0 a r g 1 \0 a r g 2 \0 a r g 3 \0 \0
10 // ^
11 // argv pointer
12
13 // so calculate the number of args
14 // once we have two \0 in a row, we know that we have reached the end of the args
15 // also make a char* [] with the pointers to the start of each arg
16 int argc = 0;
17 int wasNull = 1;
18 char* argv[100];
19 argv[argc] = args;
20 for (int i = 0; i < 1000; i++) {
21 if (args[i] == '\0') {
22 if (wasNull) {
23 break;
24 } else {
25 wasNull = 1;
26 }
27 argc++;
28 argv[argc] = &args[i + 1];
29 } else if (wasNull) {
30 wasNull = 0;
31 }
32 }
33
34 // Call main function
35 main(argc, argv);
36}

Callers

nothing calls this directly

Calls 1

mainFunction · 0.50

Tested by

no test coverage detected