Skip to content

Commit

Permalink
zig update 0.11.0-dev.2157+f56f3c582
Browse files Browse the repository at this point in the history
  • Loading branch information
marler8997 committed Jul 27, 2023
1 parent a767360 commit 15612d2
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v2
- uses: goto-bus-stop/setup-zig@v1
with:
version: 0.11.0-dev.2157+f56f3c582
version: 0.11.0-dev.4002+7dd1cf26f
- run: |
zig build test -Dfetch -Dis_ci
zig build all -Dis_ci
Expand Down
14 changes: 7 additions & 7 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ pub fn build(b: *Builder) !void {
}

// by default, install the std ssl backend
const default_exe = ssl_exes[@enumToInt(SslBackend.std)];
b.getInstallStep().dependOn(&default_exe.install_step.?.step);
const run_cmd = default_exe.run();
const default_exe = ssl_exes[@intFromEnum(SslBackend.std)];
b.installArtifact(default_exe);
const run_cmd = b.addRunArtifact(default_exe);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
Expand Down Expand Up @@ -106,26 +106,26 @@ fn addTest(
b.fmt("Test the {s} backend{s}", .{backend_name, abled_suffix})
);
{
const run = exe.run();
const run = b.addRunArtifact(exe);
run.addArg("http://google.com");
loggyrunstep.enable(run);
test_backend_step.dependOn(&run.step);
}
if (optional_ssl_backend) |_| {
{
const run = exe.run();
const run = b.addRunArtifact(exe);
run.addArg("http://ziglang.org"); // NOTE: ziglang.org will redirect to HTTPS
loggyrunstep.enable(run);
test_backend_step.dependOn(&run.step);
}
{
const run = exe.run();
const run = b.addRunArtifact(exe);
run.addArg("https://ziglang.org");
loggyrunstep.enable(run);
test_backend_step.dependOn(&run.step);
}
} else {
const run = exe.run();
const run = b.addRunArtifact(exe);
run.addArg("google.com");
loggyrunstep.enable(run);
test_backend_step.dependOn(&run.step);
Expand Down
5 changes: 4 additions & 1 deletion loggyrunstep.zig
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ fn loggyRunStepMake(step: *std.build.Step, prog_node: *std.Progress.Node) !void
for (self.argv.items) |arg| {
switch (arg) {
.bytes => |bytes| try argv_list.append(bytes),
.file_source => |file| try argv_list.append(file.getPath(self.step.owner)),
.file_source => |file| {
if (file.prefix.len != 0) @panic("todo");
try argv_list.append(file.file_source.getPath(self.step.owner));
},
.directory_source => @panic("todo"),
.artifact => |artifact| {
const executable_path = artifact.installed_path orelse artifact.getOutputSource().getPath(self.step.owner);
Expand Down
6 changes: 3 additions & 3 deletions openssl/ssl.zig
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ pub const SslConn = struct {
}
pub fn write(self: *SslConn, data: []const u8) !usize {
// TODO: and writeSize with c_int mask, it's ok if we don't write all the data
const result = openssl.SSL_write(self.ssl, data.ptr, @intCast(c_int, data.len));
const result = openssl.SSL_write(self.ssl, data.ptr, @intCast(data.len));
if (result <= 0) {
const err = openssl.SSL_get_error(self.ssl, result);
switch (err) {
Expand All @@ -169,14 +169,14 @@ pub const SslConn = struct {
=> std.debug.panic("SSL_write failed with {d}\n", .{err}),
}
}
return @intCast(usize, result);
return @intCast(result);
}
};

fn streamToCHandle(file: std.net.Stream)
if (builtin.os.tag == .windows) c_int else std.os.socket_t {

if (builtin.os.tag == .windows)
return @intCast(c_int, @ptrToInt(file.handle));
return @intCast(@intFromPtr(file.handle));
return file.handle;
}
2 changes: 1 addition & 1 deletion schannel/ssl_first_attempt.zig
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ fn MsgReader(comptime Reader: type) type { return struct {
try self.readLen();
}

const len = @intCast(u32, try self.reader.read(data[0 .. std.math.min(self.msg_left, data.len)]));
const len = @intCast(u32, try self.reader.read(data[0 .. @min(self.msg_left, data.len)]));
self.msg_left -= len;
return len;
}
Expand Down
4 changes: 2 additions & 2 deletions ziget/request.zig
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ pub fn readHttpResponse(allocator: Allocator, reader: anytype, initialBufferLen:
if (buffer.len >= maxBufferLen)
return error.HttpResponseTooBig;
// TODO: is this right with the errdefer free?
buffer = try allocator.realloc(buffer, std.math.min(maxBufferLen, 2 * buffer.len));
buffer = try allocator.realloc(buffer, @min(maxBufferLen, 2 * buffer.len));
}
var len = try reader.read(buffer[totalRead..]);
if (len == 0) return error.HttpResponseIncomplete;
Expand Down Expand Up @@ -205,7 +205,7 @@ pub fn downloadHttpOrRedirect(httpUrl: Url.Http, writer: anytype, options: Downl

{
const response = try readHttpResponse(options.allocator, stream.reader(),
std.math.min(4096, options.maxHttpResponseHeaders), options.maxHttpResponseHeaders);
@min(4096, options.maxHttpResponseHeaders), options.maxHttpResponseHeaders);
defer options.allocator.free(response.buffer);
const httpResponse = response.getHttpSlice();
options.onHttpResponse(httpResponse);
Expand Down
16 changes: 8 additions & 8 deletions ziget/url.zig
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ pub fn eqlPtr(comptime T: type, a: [*]const T, b: [*]const T, len: usize) bool {


fn matchSkip(ptrRef: *[*]const u8, limit: [*]const u8, needle: []const u8) bool {
if ( (@ptrToInt(limit) - @ptrToInt(ptrRef.*) >= needle.len) and
if ( (@intFromPtr(limit) - @intFromPtr(ptrRef.*) >= needle.len) and
eqlPtr(u8, ptrRef.*, needle.ptr, needle.len)
) {
ptrRef.* = @intToPtr([*]const u8, @ptrToInt(ptrRef.*) + needle.len);
ptrRef.* = @ptrFromInt(@intFromPtr(ptrRef.*) + needle.len);
return true;
}
return false;
Expand Down Expand Up @@ -143,23 +143,23 @@ pub fn parseUrlLimit(start: [*]const u8, limit: [*]const u8) !Url {
port32 += ptr[0] - '0';
if (port32 >= 65535) return error.UrlPortTooHigh;
}
optionalPort = @intCast(u16, port32);
optionalPort = @intCast(port32);
}
var pathOffset = @intCast(u16, @ptrToInt(ptr) - @ptrToInt(start));
var pathOffset: u16 = @intCast(@intFromPtr(ptr) - @intFromPtr(start));
var pathLimit : u16 = undefined;
if (ptr == limit) {
pathLimit = pathOffset;
} else {
std.debug.assert(ptr[0] == '/');
ptr += 1;
// TODO: this won't be correct if there is a query
pathLimit = @intCast(u16, @ptrToInt(limit) - @ptrToInt(start));
pathLimit = @intCast(@intFromPtr(limit) - @intFromPtr(start));
}
return Url { .Http = .{
.str = start[0..@ptrToInt(limit) - @ptrToInt(start)],
.str = start[0..@intFromPtr(limit) - @intFromPtr(start)],
.secure = isHttps,
.hostOffset = @intCast(u8 , @ptrToInt(hostStart) - @ptrToInt(start)),
.hostLimit = @intCast(u16, @ptrToInt(hostLimit) - @ptrToInt(start)),
.hostOffset = @intCast(@intFromPtr(hostStart) - @intFromPtr(start)),
.hostLimit = @intCast(@intFromPtr(hostLimit) - @intFromPtr(start)),
.optionalPort = optionalPort,
.pathOffset = pathOffset,
.pathLimit = pathLimit,
Expand Down

0 comments on commit 15612d2

Please sign in to comment.