Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ static const char *get_host_os(void) {
return "linux";
#elif defined(__FreeBSD__)
return "freebsd";
#elif defined(__HAIKU__)
return "haiku";
#else
panic("unknown host os, specify with ZIG_HOST_TARGET_OS");
#endif
Expand Down
30 changes: 19 additions & 11 deletions lib/std/Build/Cache.zig
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ pub const Manifest = struct {
break :f file;
}
const gop = try self.files.getOrPutAdapted(gpa, prefixed_path, FilesAdapter{});
errdefer assert(self.files.popOrNull() != null);
errdefer _ = self.files.pop();
if (!gop.found_existing) {
gop.key_ptr.* = .{
.prefixed_path = .{
Expand Down Expand Up @@ -633,10 +633,10 @@ pub const Manifest = struct {
self.hash.hasher.update(&bin_digest);

// Remove files not in the initial hash.
for (self.files.keys()[input_file_count..]) |*file| {
file.deinit(self.cache.gpa);
while (self.files.count() != input_file_count) {
var file = self.files.pop();
file.key.deinit(self.cache.gpa);
}
self.files.shrinkRetainingCapacity(input_file_count);

for (self.files.keys()) |file| {
self.hash.hasher.update(&file.bin_digest);
Expand Down Expand Up @@ -736,19 +736,27 @@ pub const Manifest = struct {
const prefixed_path = try self.cache.findPrefix(file_path);
errdefer gpa.free(prefixed_path.sub_path);

const new_ch_file = try self.files.addOne(gpa);
new_ch_file.* = .{
const gop = try self.files.getOrPutAdapted(gpa, prefixed_path, FilesAdapter{});
errdefer _ = self.files.pop();

if (gop.found_existing) {
gpa.free(prefixed_path.sub_path);
return gop.key_ptr.contents.?;
}

gop.key_ptr.* = .{
.prefixed_path = prefixed_path,
.max_file_size = max_file_size,
.stat = undefined,
.bin_digest = undefined,
.contents = null,
};
errdefer self.files.shrinkRetainingCapacity(self.files.entries.len - 1);

try self.populateFileHash(new_ch_file);
self.files.lockPointers();
defer self.files.unlockPointers();

return new_ch_file.contents.?;
try self.populateFileHash(gop.key_ptr);
return gop.key_ptr.contents.?;
}

/// Add a file as a dependency of process being cached, after the initial hash has been
Expand All @@ -765,7 +773,7 @@ pub const Manifest = struct {
errdefer gpa.free(prefixed_path.sub_path);

const gop = try self.files.getOrPutAdapted(gpa, prefixed_path, FilesAdapter{});
errdefer assert(self.files.popOrNull() != null);
errdefer _ = self.files.pop();

if (gop.found_existing) {
gpa.free(prefixed_path.sub_path);
Expand Down Expand Up @@ -801,7 +809,7 @@ pub const Manifest = struct {
errdefer gpa.free(prefixed_path.sub_path);

const gop = try self.files.getOrPutAdapted(gpa, prefixed_path, FilesAdapter{});
errdefer assert(self.files.popOrNull() != null);
errdefer _ = self.files.pop();

if (gop.found_existing) {
gpa.free(prefixed_path.sub_path);
Expand Down
4 changes: 2 additions & 2 deletions lib/std/c.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1687,8 +1687,8 @@ pub extern "c" fn getpeername(sockfd: c.fd_t, noalias addr: *c.sockaddr, noalias
pub extern "c" fn connect(sockfd: c.fd_t, sock_addr: *const c.sockaddr, addrlen: c.socklen_t) c_int;
pub extern "c" fn accept(sockfd: c.fd_t, noalias addr: ?*c.sockaddr, noalias addrlen: ?*c.socklen_t) c_int;
pub extern "c" fn accept4(sockfd: c.fd_t, noalias addr: ?*c.sockaddr, noalias addrlen: ?*c.socklen_t, flags: c_uint) c_int;
pub extern "c" fn getsockopt(sockfd: c.fd_t, level: u32, optname: u32, noalias optval: ?*anyopaque, noalias optlen: *c.socklen_t) c_int;
pub extern "c" fn setsockopt(sockfd: c.fd_t, level: u32, optname: u32, optval: ?*const anyopaque, optlen: c.socklen_t) c_int;
pub extern "c" fn getsockopt(sockfd: c.fd_t, level: i32, optname: u32, noalias optval: ?*anyopaque, noalias optlen: *c.socklen_t) c_int;
pub extern "c" fn setsockopt(sockfd: c.fd_t, level: i32, optname: u32, optval: ?*const anyopaque, optlen: c.socklen_t) c_int;
pub extern "c" fn send(sockfd: c.fd_t, buf: *const anyopaque, len: usize, flags: u32) isize;
pub extern "c" fn sendto(
sockfd: c.fd_t,
Expand Down
4 changes: 2 additions & 2 deletions lib/std/c/darwin.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,7 @@ pub const siginfo_t = extern struct {
pid: pid_t,
uid: uid_t,
status: c_int,
addr: *anyopaque,
addr: *allowzero anyopaque,
value: extern union {
int: c_int,
ptr: *anyopaque,
Expand All @@ -1151,7 +1151,7 @@ pub const siginfo_t = extern struct {
/// Renamed from `sigaction` to `Sigaction` to avoid conflict with function name.
pub const Sigaction = extern struct {
pub const handler_fn = *align(1) const fn (c_int) callconv(.C) void;
pub const sigaction_fn = *const fn (c_int, *const siginfo_t, ?*const anyopaque) callconv(.C) void;
pub const sigaction_fn = *const fn (c_int, *const siginfo_t, ?*anyopaque) callconv(.C) void;

handler: extern union {
handler: ?handler_fn,
Expand Down
4 changes: 2 additions & 2 deletions lib/std/c/dragonfly.zig
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ pub const siginfo_t = extern struct {
pid: c_int,
uid: uid_t,
status: c_int,
addr: ?*anyopaque,
addr: *allowzero anyopaque,
value: sigval,
band: c_long,
__spare__: [7]c_int,
Expand All @@ -691,7 +691,7 @@ pub const sig_atomic_t = c_int;

pub const Sigaction = extern struct {
pub const handler_fn = *align(1) const fn (c_int) callconv(.C) void;
pub const sigaction_fn = *const fn (c_int, *const siginfo_t, ?*const anyopaque) callconv(.C) void;
pub const sigaction_fn = *const fn (c_int, *const siginfo_t, ?*anyopaque) callconv(.C) void;

/// signal handler
handler: extern union {
Expand Down
4 changes: 2 additions & 2 deletions lib/std/c/freebsd.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1172,7 +1172,7 @@ const NSIG = 32;
/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
pub const Sigaction = extern struct {
pub const handler_fn = *align(1) const fn (c_int) callconv(.C) void;
pub const sigaction_fn = *const fn (c_int, *const siginfo_t, ?*const anyopaque) callconv(.C) void;
pub const sigaction_fn = *const fn (c_int, *const siginfo_t, ?*anyopaque) callconv(.C) void;

/// signal handler
handler: extern union {
Expand Down Expand Up @@ -1206,7 +1206,7 @@ pub const siginfo_t = extern struct {
/// Exit value.
status: c_int,
/// Faulting instruction.
addr: ?*anyopaque,
addr: *allowzero anyopaque,
/// Signal value.
value: sigval,
reason: extern union {
Expand Down
Loading