Skip to content

Commit 6a2e495

Browse files
committed
rt: Remove unused command line parsing
1 parent 2b92962 commit 6a2e495

File tree

1 file changed

+1
-71
lines changed

1 file changed

+1
-71
lines changed

src/rt/rust.cpp

+1-71
Original file line numberDiff line numberDiff line change
@@ -19,64 +19,6 @@
1919
#include "rust_scheduler.h"
2020
#include "rust_gc_metadata.h"
2121

22-
// Creates a rust argument vector from the platform argument vector
23-
struct
24-
command_line_args : public kernel_owned<command_line_args>
25-
{
26-
rust_kernel *kernel;
27-
rust_task *task;
28-
int argc;
29-
char **argv;
30-
31-
// [str] passed to rust_task::start.
32-
rust_vec_box *args;
33-
34-
command_line_args(rust_task *task,
35-
int sys_argc,
36-
char **sys_argv)
37-
: kernel(task->kernel),
38-
task(task),
39-
argc(sys_argc),
40-
argv(sys_argv)
41-
{
42-
#if defined(__WIN32__)
43-
LPCWSTR cmdline = GetCommandLineW();
44-
LPWSTR *wargv = CommandLineToArgvW(cmdline, &argc);
45-
kernel->win32_require("CommandLineToArgvW", wargv != NULL);
46-
argv = (char **) kernel->malloc(sizeof(char*) * argc,
47-
"win32 command line");
48-
for (int i = 0; i < argc; ++i) {
49-
int n_chars = WideCharToMultiByte(CP_UTF8, 0, wargv[i], -1,
50-
NULL, 0, NULL, NULL);
51-
kernel->win32_require("WideCharToMultiByte(0)", n_chars != 0);
52-
argv[i] = (char *) kernel->malloc(n_chars,
53-
"win32 command line arg");
54-
n_chars = WideCharToMultiByte(CP_UTF8, 0, wargv[i], -1,
55-
argv[i], n_chars, NULL, NULL);
56-
kernel->win32_require("WideCharToMultiByte(1)", n_chars != 0);
57-
}
58-
LocalFree(wargv);
59-
#endif
60-
61-
args = make_str_vec(kernel, argc, argv);
62-
}
63-
64-
~command_line_args() {
65-
for (int i = 0; i < argc; ++i) {
66-
rust_vec *s = ((rust_vec**)&args->body.data)[i];
67-
kernel->free(s);
68-
}
69-
kernel->free(args);
70-
71-
#ifdef __WIN32__
72-
for (int i = 0; i < argc; ++i) {
73-
kernel->free(argv[i]);
74-
}
75-
kernel->free(argv);
76-
#endif
77-
}
78-
};
79-
8022
void* global_crate_map = NULL;
8123

8224
/**
@@ -107,19 +49,8 @@ rust_start(uintptr_t main_fn, int argc, char **argv, void* crate_map) {
10749
assert(sched != NULL);
10850
rust_task *root_task = sched->create_task(NULL, "main");
10951

110-
// Build the command line arguments to pass to the root task
111-
command_line_args *args
112-
= new (kernel, "main command line args")
113-
command_line_args(root_task, argc, argv);
114-
115-
LOG(root_task, dom, "startup: %d args in 0x%" PRIxPTR,
116-
args->argc, (uintptr_t)args->args);
117-
for (int i = 0; i < args->argc; i++) {
118-
LOG(root_task, dom, "startup: arg[%d] = '%s'", i, args->argv[i]);
119-
}
120-
12152
// Schedule the main Rust task
122-
root_task->start((spawn_fn)main_fn, NULL, args->args);
53+
root_task->start((spawn_fn)main_fn, NULL, NULL);
12354

12455
// At this point the task lifecycle is responsible for it
12556
// and our pointer may not be valid
@@ -128,7 +59,6 @@ rust_start(uintptr_t main_fn, int argc, char **argv, void* crate_map) {
12859
// Run the kernel until all schedulers exit
12960
int ret = kernel->run();
13061

131-
delete args;
13262
delete kernel;
13363
free_env(env);
13464

0 commit comments

Comments
 (0)