blob: ab721f13d6d3e1a43aab6436fa715755b31905bb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#include <euler/syscall.hpp>
#include <cstdlib>
#include <string>
int main(int argc, char **argv);
extern "C" [[noreturn]] void _start() {
//TODO: call static initializers
auto argc_raw = euler::syscall::try_get_environment_variable("ARGC");
int argc = argc_raw.has_value() ? std::stoi(argc_raw.value()) : 0;
std::vector<std::string> argv;
for (int i = 0; i < argc; ++i) {
std::string arg_name = std::string("ARGV") + std::to_string(i);
auto arg_raw = euler::syscall::try_get_environment_variable(arg_name);
argv.push_back(arg_raw.has_value() ? arg_raw.value() : "");
}
std::vector<char *> c_argv(argc);
for (int i = 0; i < argc; ++i)
c_argv[i] = argv[i].data();
int exit_code = main(argc, c_argv.data());
euler::syscall::end_this_process(exit_code);
}
|