mirror of
https://github.com/ion232/reticulum-zig.git
synced 2025-12-22 06:37:05 +00:00
app: add initial files
This commit is contained in:
2
app/driver.zig
Normal file
2
app/driver.zig
Normal file
@@ -0,0 +1,2 @@
|
||||
pub const Default = LinkLocal;
|
||||
pub const LinkLocal = @import("driver/LinkLocal.zig");
|
||||
1
app/driver/LinkLocal.zig
Normal file
1
app/driver/LinkLocal.zig
Normal file
@@ -0,0 +1 @@
|
||||
// TODO: Implement.
|
||||
1
app/main.zig
Normal file
1
app/main.zig
Normal file
@@ -0,0 +1 @@
|
||||
// TODO: Implement.
|
||||
25
app/os/Clock.zig
Normal file
25
app/os/Clock.zig
Normal file
@@ -0,0 +1,25 @@
|
||||
const std = @import("std");
|
||||
const Timer = std.time.Timer;
|
||||
const Clock = @import("../Clock.zig");
|
||||
|
||||
const Self = @This();
|
||||
|
||||
timer: Timer,
|
||||
|
||||
pub fn init() Timer.Error!Self {
|
||||
return .{
|
||||
.timer = try Timer.start(),
|
||||
};
|
||||
}
|
||||
|
||||
pub fn monotonicMicros(ptr: *anyopaque) u64 {
|
||||
const self: *Self = @ptrCast(@alignCast(ptr));
|
||||
return self.timer.read();
|
||||
}
|
||||
|
||||
pub fn clock(self: *Self) Clock {
|
||||
return .{
|
||||
.ptr = self,
|
||||
.monotonicMicrosFn = monotonicMicros,
|
||||
};
|
||||
}
|
||||
25
app/os/Os.zig
Normal file
25
app/os/Os.zig
Normal file
@@ -0,0 +1,25 @@
|
||||
const std = @import("std");
|
||||
const Timer = std.time.Timer;
|
||||
const System = @import("../System.zig");
|
||||
|
||||
pub const Clock = @import("os/Clock.zig");
|
||||
pub const Rng = @import("os/Rng.zig");
|
||||
|
||||
const Self = @This();
|
||||
|
||||
clock: Clock,
|
||||
rng: Rng,
|
||||
|
||||
pub fn init() Timer.Error!Self {
|
||||
return Self{
|
||||
.clock = try Clock.init(),
|
||||
.rng = Rng.init(),
|
||||
};
|
||||
}
|
||||
|
||||
pub fn system(self: *Self) System {
|
||||
return System{
|
||||
.clock = self.clock.clock(),
|
||||
.rng = self.rng.rng(),
|
||||
};
|
||||
}
|
||||
13
app/os/Rng.zig
Normal file
13
app/os/Rng.zig
Normal file
@@ -0,0 +1,13 @@
|
||||
const std = @import("std");
|
||||
const Rng = @import("../../System.zig").Rng;
|
||||
|
||||
const Self = @This();
|
||||
|
||||
pub fn init() Self {
|
||||
return .{};
|
||||
}
|
||||
|
||||
pub fn rng(self: *Self) Rng {
|
||||
_ = self;
|
||||
return std.crypto.random;
|
||||
}
|
||||
Reference in New Issue
Block a user