Following the new Zig std.

This commit is contained in:
Philippe Pittoli 2023-05-03 03:21:30 +02:00
parent 2f369adfef
commit 527049ed3d
4 changed files with 14 additions and 13 deletions

View File

@ -33,7 +33,7 @@ pub fn build(b: *std.Build) void {
// This declares intent for the library to be installed into the standard
// location when the user invokes the "install" step (the default step when
// running `zig build`).
static_lib.install();
b.installArtifact(static_lib);
const shared_lib = b.addSharedLibrary(.{
.name = "ipc",
@ -43,7 +43,7 @@ pub fn build(b: *std.Build) void {
.optimize = optimize,
});
shared_lib.linkLibC();
shared_lib.install();
b.installArtifact(shared_lib);
// Creates a step for unit testing.
const main_tests = b.addTest(.{

View File

@ -3,9 +3,10 @@ all: build
help:
@echo "usage: make [build|install|doc|serve-doc]"
ZIGOPTS ?=
ZIGOPTIM ?= ReleaseSafe
build:
zig build -Doptimize=$(ZIGOPTIM)
zig build -Doptimize=$(ZIGOPTIM) $(ZIGOPTS)
PREFIX ?= /usr/local
LIBDIR ?= $(PREFIX)/lib

View File

@ -218,7 +218,7 @@ pub const Context = struct {
// net.StreamServer
var serverfd = self.pollfd.items[server_index].fd;
var path = self.connections.items[server_index].path orelse return error.ServerWithNoPath;
var server = net.StreamServer{ .sockfd = serverfd, .kernel_backlog = 100, .reuse_address = false, .listen_address = try net.Address.initUnix(path) };
var server = net.StreamServer{ .sockfd = serverfd, .kernel_backlog = 100, .reuse_address = false, .reuse_port = false, .listen_address = try net.Address.initUnix(path) };
var client = try server.accept(); // net.StreamServer.Connection
const newfd = client.stream.handle;
@ -403,7 +403,7 @@ pub const Context = struct {
// handle messages
// => loop over self.pollfd.items
for (self.pollfd.items) |*fd, i| {
for (self.pollfd.items, 0..) |*fd, i| {
// .revents is POLLIN
if (fd.revents & std.os.linux.POLL.IN > 0) {
// SERVER = new connection
@ -470,7 +470,7 @@ pub const Context = struct {
fd.events &= ~@as(i16, std.os.linux.POLL.OUT);
var index: usize = undefined;
for (self.tx.items) |m, index_| {
for (self.tx.items, 0..) |m, index_| {
if (m.fd == self.pollfd.items[i].fd) {
index = index_;
break;

View File

@ -52,7 +52,7 @@ pub const SwitchDB = struct {
}
pub fn format(self: Self, comptime _: []const u8, _: fmt.FormatOptions, out_stream: anytype) !void {
for (self.db.keys()) |k, i| {
for (self.db.keys(), 0..) |k, i| {
try fmt.format(out_stream, "({},{})", .{ k, self.db.values()[i].dest });
}
}