Update for the new zig version
All checks were successful
PikaOS Package Build & Release (amd64-v3) / build (push) Successful in 26s
All checks were successful
PikaOS Package Build & Release (amd64-v3) / build (push) Successful in 26s
This commit is contained in:
parent
a2c3d34fb2
commit
2b15cbede4
2
.github/release-nest-v3
vendored
2
.github/release-nest-v3
vendored
@ -1 +1 @@
|
||||
1
|
||||
2
|
@ -4,13 +4,17 @@ pub fn build(b: *std.Build) void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
const exe = b.addExecutable(.{
|
||||
.name = "falcond",
|
||||
const main_module = b.createModule(.{
|
||||
.root_source_file = .{ .cwd_relative = "src/main.zig" },
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
|
||||
const exe = b.addExecutable(.{
|
||||
.name = "falcond",
|
||||
.root_module = main_module,
|
||||
});
|
||||
|
||||
exe.bundle_compiler_rt = true;
|
||||
|
||||
b.installArtifact(exe);
|
||||
|
@ -6,12 +6,12 @@
|
||||
//
|
||||
// It is redundant to include "zig" in this name because it is already
|
||||
// within the Zig package namespace.
|
||||
.name = "falcond",
|
||||
.name = .falcond,
|
||||
|
||||
// This is a [Semantic Version](https://semver.org/).
|
||||
// In a future version of Zig it will be used for package deduplication.
|
||||
.version = "0.1.0",
|
||||
|
||||
.fingerprint = 0x31d9d78a54cab47b,
|
||||
// This field is optional.
|
||||
// This is currently advisory only; Zig does not yet do anything
|
||||
// with this value.
|
||||
|
@ -1,3 +1,9 @@
|
||||
falcond (1.1.1-101pika1) pika; urgency=low
|
||||
|
||||
* Update to support latest zig
|
||||
|
||||
-- ferreo <ferreo@pika-os.com> Sun, 12 Jan 2025 13:48:00 +0300
|
||||
|
||||
falcond (1.1.0-101pika1) pika; urgency=low
|
||||
|
||||
* Fix memory leak on error, fix power ppd being required for falcond to launch.
|
||||
|
@ -1,6 +1,6 @@
|
||||
const std = @import("std");
|
||||
const Daemon = @import("daemon.zig").Daemon;
|
||||
|
||||
const builtin = @import("builtin");
|
||||
pub const std_options = std.Options{
|
||||
.log_level = .debug,
|
||||
.log_scope_levels = &[_]std.log.ScopeLevel{
|
||||
@ -29,19 +29,25 @@ const AllocTracker = struct {
|
||||
const config_path: []const u8 = "/etc/falcond/config.conf";
|
||||
const system_conf_path: []const u8 = "/usr/share/falcond/system.conf";
|
||||
|
||||
fn alloc(ctx: *anyopaque, len: usize, ptr_align: u8, ret_addr: usize) ?[*]u8 {
|
||||
fn alloc(ctx: *anyopaque, len: usize, ptr_align: std.mem.Alignment, ret_addr: usize) ?[*]u8 {
|
||||
var t: *AllocTracker = @ptrCast(@alignCast(ctx));
|
||||
t.trackAlloc();
|
||||
return gpa_vtable.alloc(gpa_ptr, len, ptr_align, ret_addr);
|
||||
}
|
||||
|
||||
fn resize(ctx: *anyopaque, buf: []u8, log2_buf_align: u8, new_len: usize, ret_addr: usize) bool {
|
||||
fn resize(ctx: *anyopaque, buf: []u8, log2_buf_align: std.mem.Alignment, new_len: usize, ret_addr: usize) bool {
|
||||
var t: *AllocTracker = @ptrCast(@alignCast(ctx));
|
||||
t.trackResize();
|
||||
return gpa_vtable.resize(gpa_ptr, buf, log2_buf_align, new_len, ret_addr);
|
||||
}
|
||||
|
||||
fn free(ctx: *anyopaque, buf: []u8, log2_buf_align: u8, ret_addr: usize) void {
|
||||
fn remap(ctx: *anyopaque, buf: []u8, log2_buf_align: std.mem.Alignment, new_len: usize, ret_addr: usize) ?[*]u8 {
|
||||
var t: *AllocTracker = @ptrCast(@alignCast(ctx));
|
||||
t.trackResize();
|
||||
return gpa_vtable.remap(gpa_ptr, buf, log2_buf_align, new_len, ret_addr);
|
||||
}
|
||||
|
||||
fn free(ctx: *anyopaque, buf: []u8, log2_buf_align: std.mem.Alignment, ret_addr: usize) void {
|
||||
var t: *AllocTracker = @ptrCast(@alignCast(ctx));
|
||||
t.trackDealloc();
|
||||
gpa_vtable.free(gpa_ptr, buf, log2_buf_align, ret_addr);
|
||||
@ -49,16 +55,20 @@ fn free(ctx: *anyopaque, buf: []u8, log2_buf_align: u8, ret_addr: usize) void {
|
||||
|
||||
var gpa_vtable: *const std.mem.Allocator.VTable = undefined;
|
||||
var gpa_ptr: *anyopaque = undefined;
|
||||
var debug_allocator: std.heap.DebugAllocator(.{}) = .init;
|
||||
pub fn main() !void {
|
||||
std.log.info("Starting falcond...", .{});
|
||||
|
||||
var allocator: std.mem.Allocator = undefined;
|
||||
var tracker = AllocTracker{};
|
||||
var gpa = std.heap.GeneralPurposeAllocator(.{
|
||||
.verbose_log = false,
|
||||
.enable_memory_limit = true,
|
||||
}){};
|
||||
defer {
|
||||
const leaked = gpa.deinit();
|
||||
const gpa, const is_debug = gpa: {
|
||||
break :gpa switch (builtin.mode) {
|
||||
.Debug, .ReleaseSafe => .{ debug_allocator.allocator(), true },
|
||||
.ReleaseFast, .ReleaseSmall => .{ std.heap.smp_allocator, false },
|
||||
};
|
||||
};
|
||||
allocator = gpa;
|
||||
defer if (is_debug) {
|
||||
const leaked = debug_allocator.deinit();
|
||||
if (leaked == .leak) {
|
||||
std.log.err("Memory leaks detected!", .{});
|
||||
}
|
||||
@ -67,18 +77,20 @@ pub fn main() !void {
|
||||
tracker.deallocs,
|
||||
tracker.resizes,
|
||||
});
|
||||
}
|
||||
|
||||
gpa_vtable = gpa.allocator().vtable;
|
||||
gpa_ptr = gpa.allocator().ptr;
|
||||
const allocator = std.mem.Allocator{
|
||||
.ptr = &tracker,
|
||||
.vtable = &std.mem.Allocator.VTable{
|
||||
.alloc = alloc,
|
||||
.resize = resize,
|
||||
.free = free,
|
||||
},
|
||||
};
|
||||
if (is_debug) {
|
||||
gpa_vtable = gpa.vtable;
|
||||
gpa_ptr = gpa.ptr;
|
||||
allocator = std.mem.Allocator{
|
||||
.ptr = &tracker,
|
||||
.vtable = &std.mem.Allocator.VTable{
|
||||
.alloc = alloc,
|
||||
.resize = resize,
|
||||
.free = free,
|
||||
.remap = remap,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const args = try std.process.argsAlloc(allocator);
|
||||
defer std.process.argsFree(allocator, args);
|
||||
|
Loading…
x
Reference in New Issue
Block a user