Skip to content

Commit 8f2044e

Browse files
committed
Run conformance and CI in single VM
1 parent 9f654ec commit 8f2044e

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/posix.zig

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ const darwin = if (builtin.os.tag.isDarwin()) struct {
4242
} else struct {};
4343

4444
const global = struct {
45-
export var optarg: ?[*:0]u8 = null;
45+
// C ABI global: `extern char *optarg;`
46+
export var optarg: [*:0]allowzero u8 = @ptrFromInt(0);
4647
export var opterr: c_int = 1;
4748
export var optind: c_int = 1;
4849
export var optopt: c_int = 0;
@@ -52,7 +53,7 @@ const global = struct {
5253
/// extern char *optarg;
5354
/// extern int opterr, optind, optopt;
5455
export fn getopt(argc: c_int, argv: [*][*:0]u8, optstring: [*:0]const u8) callconv(.c) c_int {
55-
global.optarg = null;
56+
global.optarg = @ptrFromInt(0);
5657
trace.log("getopt argc={} argv={*} opstring={f} (err={}, ind={}, opt={})", .{
5758
argc,
5859
argv,
@@ -99,7 +100,7 @@ export fn getopt(argc: c_int, argv: [*][*:0]u8, optstring: [*:0]const u8) callco
99100
global.optopt = @as(c_int, arg[1]);
100101
return if (optstring[0] == ':') ':' else '?';
101102
}
102-
global.optarg = argv[@as(usize, @intCast(global.optind))];
103+
global.optarg = @ptrCast(argv[@as(usize, @intCast(global.optind))]);
103104
global.optind += 1;
104105
}
105106
return @as(c_int, arg[1]);

0 commit comments

Comments
 (0)