blob: 3f630e542ddf8334260c335120fe3975d6ae2b1f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
// Native startup support, compiled independently and linked with the CRT.
// Raw native addresses stay i64; only the arrays allocated here are Simple objects.
{ i64 i64 -> i64 } simple_argv = "C";
{ i64 -> i64 } strlen = "C";
{ i64 i64 i64 -> i64 } memcpy = "C";
val simple_args = { i64 argc, i64 argv ->
if( argc < 0 || argc > 4294967295 ) return null;
// Zero-filled reference arrays require nullable elements. Every slot is
// filled before returning; the native entry bridge publishes u8[~][].
val args = new u8[~]?[argc];
for( i64 i=0; i<argc; i++ ) {
i64 src = simple_argv(argv,i);
i64 len = strlen(src);
if( len < 0 || len > 4294967295 ) return null;
val bytes = new u8[len];
i64 dst = bytes;
memcpy(dst,src,len);
args[i] = bytes;
}
return args;
};
|