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
20 changes: 10 additions & 10 deletions src/kernel/log.zig
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ fn logCallback(context: void, str: []const u8) LoggingError!usize {
/// whether it is filtered.
/// IN comptime format: []const u8 - The message format. Uses the standard format specification
/// options.
/// IN args: var - A struct of the parameters for the format string.
/// IN args: anytype - A struct of the parameters for the format string.
///
pub fn log(comptime level: Level, comptime format: []const u8, args: var) void {
pub fn log(comptime level: Level, comptime format: []const u8, args: anytype) void {
fmt.format(OutStream{ .context = {} }, "[" ++ @tagName(level) ++ "] " ++ format, args) catch unreachable;
}

Expand All @@ -58,9 +58,9 @@ pub fn log(comptime level: Level, comptime format: []const u8, args: var) void {
/// Arguments:
/// IN comptime format: []const u8 - The message format. Uses the standard format specification
/// options.
/// IN args: var - A struct of the parameters for the format string.
/// IN args: anytype - A struct of the parameters for the format string.
///
pub fn logInfo(comptime format: []const u8, args: var) void {
pub fn logInfo(comptime format: []const u8, args: anytype) void {
log(Level.INFO, format, args);
}

Expand All @@ -70,9 +70,9 @@ pub fn logInfo(comptime format: []const u8, args: var) void {
/// Arguments:
/// IN comptime format: []const u8 - The message format. Uses the standard format specification
/// options.
/// IN args: var - A struct of the parameters for the format string.
/// IN args: anytype - A struct of the parameters for the format string.
///
pub fn logDebug(comptime format: []const u8, args: var) void {
pub fn logDebug(comptime format: []const u8, args: anytype) void {
log(Level.DEBUG, format, args);
}

Expand All @@ -82,9 +82,9 @@ pub fn logDebug(comptime format: []const u8, args: var) void {
/// Arguments:
/// IN comptime format: []const u8 - The message format. Uses the standard format specification
/// options.
/// IN args: var - A struct of the parameters for the format string.
/// IN args: anytype - A struct of the parameters for the format string.
///
pub fn logWarning(comptime format: []const u8, args: var) void {
pub fn logWarning(comptime format: []const u8, args: anytype) void {
log(Level.WARNING, format, args);
}

Expand All @@ -94,9 +94,9 @@ pub fn logWarning(comptime format: []const u8, args: var) void {
/// Arguments:
/// IN comptime format: []const u8 - The message format. Uses the standard format specification
/// options.
/// IN args: var - A struct of the parameters for the format string.
/// IN args: anytype - A struct of the parameters for the format string.
///
pub fn logError(comptime format: []const u8, args: var) void {
pub fn logError(comptime format: []const u8, args: anytype) void {
log(Level.ERROR, format, args);
}

Expand Down
8 changes: 4 additions & 4 deletions src/kernel/mem.zig
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ pub var ADDR_OFFSET: usize = undefined;
/// Convert a virtual address to its physical counterpart by subtracting the kernel virtual offset from the virtual address.
///
/// Arguments:
/// IN virt: var - The virtual address to covert. Either an integer or pointer.
/// IN virt: anytype - The virtual address to covert. Either an integer or pointer.
///
/// Return: @TypeOf(virt)
/// The physical address.
///
pub fn virtToPhys(virt: var) @TypeOf(virt) {
pub fn virtToPhys(virt: anytype) @TypeOf(virt) {
const T = @TypeOf(virt);
return switch (@typeInfo(T)) {
.Pointer => @intToPtr(T, @ptrToInt(virt) - ADDR_OFFSET),
Expand All @@ -83,12 +83,12 @@ pub fn virtToPhys(virt: var) @TypeOf(virt) {
/// Convert a physical address to its virtual counterpart by adding the kernel virtual offset to the physical address.
///
/// Arguments:
/// IN phys: var - The physical address to covert. Either an integer or pointer.
/// IN phys: anytype - The physical address to covert. Either an integer or pointer.
///
/// Return: @TypeOf(virt)
/// The virtual address.
///
pub fn physToVirt(phys: var) @TypeOf(phys) {
pub fn physToVirt(phys: anytype) @TypeOf(phys) {
const T = @TypeOf(phys);
return switch (@typeInfo(T)) {
.Pointer => @intToPtr(T, @ptrToInt(phys) + ADDR_OFFSET),
Expand Down
2 changes: 1 addition & 1 deletion src/kernel/panic.zig
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ fn logTraceAddress(addr: usize) void {
log.logError("{x}: {}\n", .{ addr, str });
}

pub fn panic(trace: ?*builtin.StackTrace, comptime format: []const u8, args: var) noreturn {
pub fn panic(trace: ?*builtin.StackTrace, comptime format: []const u8, args: anytype) noreturn {
@setCold(true);
log.logError("Kernel panic: " ++ format ++ "\n", args);
if (trace) |trc| {
Expand Down
4 changes: 2 additions & 2 deletions src/kernel/tty.zig
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ fn printCallback(ctx: void, str: []const u8) !usize {
///
/// Arguments:
/// IN comptime format: []const u8 - The format string to print
/// IN args: var - The arguments to be used in the formatted string
/// IN args: anytype - The arguments to be used in the formatted string
///
pub fn print(comptime format: []const u8, args: var) void {
pub fn print(comptime format: []const u8, args: anytype) void {
// Printing can't error because of the scrolling, if it does, we have a big problem
fmt.format(OutStream{ .context = {} }, format, args) catch |e| {
log.logError("TTY: Error printing. Error: {}\n", .{e});
Expand Down
2 changes: 1 addition & 1 deletion src/kernel/vfs.zig
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ const TestFS = struct {
self.allocator.destroy(self.fs);
}

fn getTreeNode(test_fs: *Self, node: var) Allocator.Error!?*TreeNode {
fn getTreeNode(test_fs: *Self, node: anytype) Allocator.Error!?*TreeNode {
switch (@TypeOf(node)) {
*const Node, *const FileNode, *const DirNode => {},
else => @compileError("Node is of type " ++ @typeName(@TypeOf(node)) ++ ". Only *const Node, *const FileNode and *const DirNode are supported"),
Expand Down
10 changes: 5 additions & 5 deletions test/mock/kernel/log_mock.zig
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ pub const Level = enum {
ERROR,
};

pub fn log(comptime level: Level, comptime format: []const u8, args: var) void {
pub fn log(comptime level: Level, comptime format: []const u8, args: anytype) void {
//return mock_framework.performAction("log", void, level, format, args);
}

pub fn logInfo(comptime format: []const u8, args: var) void {
pub fn logInfo(comptime format: []const u8, args: anytype) void {
//return mock_framework.performAction("logInfo", void, format, args);
}

pub fn logDebug(comptime format: []const u8, args: var) void {
pub fn logDebug(comptime format: []const u8, args: anytype) void {
//return mock_framework.performAction("logDebug", void, format, args);
}

pub fn logWarning(comptime format: []const u8, args: var) void {
pub fn logWarning(comptime format: []const u8, args: anytype) void {
//return mock_framework.performAction("logWarning", void, format, args);
}

pub fn logError(comptime format: []const u8, args: var) void {
pub fn logError(comptime format: []const u8, args: anytype) void {
//return mock_framework.performAction("logError", void, format, args);
}
4 changes: 2 additions & 2 deletions test/mock/kernel/mem_mock.zig
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub const MemProfile = struct {
// The size of the fixed allocator used before the heap is set up. Set to 1MiB.
const FIXED_ALLOC_SIZE = 1024 * 1024;

pub fn virtToPhys(virt: var) @TypeOf(virt) {
pub fn virtToPhys(virt: anytype) @TypeOf(virt) {
const T = @TypeOf(virt);
return switch (@typeInfo(T)) {
.Pointer => @intToPtr(T, @ptrToInt(virt) - KERNEL_ADDR_OFFSET),
Expand All @@ -40,7 +40,7 @@ pub fn virtToPhys(virt: var) @TypeOf(virt) {
};
}

pub fn physToVirt(phys: var) @TypeOf(phys) {
pub fn physToVirt(phys: anytype) @TypeOf(phys) {
const T = @TypeOf(phys);
return switch (@typeInfo(T)) {
.Pointer => @intToPtr(T, @ptrToInt(phys) + KERNEL_ADDR_OFFSET),
Expand Down
32 changes: 16 additions & 16 deletions test/mock/kernel/mock_framework.zig
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,12 @@ fn Mock() type {
/// to have a list of different types.
///
/// Arguments:
/// IN arg: var - The data, this can be a function or basic type value.
/// IN arg: anytype - The data, this can be a function or basic type value.
///
/// Return: DataElement
/// A DataElement with the data wrapped.
///
fn createDataElement(arg: var) DataElement {
fn createDataElement(arg: anytype) DataElement {
return switch (@TypeOf(arg)) {
bool => DataElement{ .BOOL = arg },
u4 => DataElement{ .U4 = arg },
Expand Down Expand Up @@ -306,12 +306,12 @@ fn Mock() type {
///
/// Arguments:
/// IN RetType: type - The return type of the function.
/// IN params: var - The argument list for the function.
/// IN params: anytype - The argument list for the function.
///
/// Return: type
/// A function type that represents the return type and its arguments.
///
fn getFunctionType(comptime RetType: type, params: var) type {
fn getFunctionType(comptime RetType: type, params: anytype) type {
return switch (params.len) {
0 => fn () RetType,
1 => fn (@TypeOf(params[0])) RetType,
Expand Down Expand Up @@ -387,10 +387,10 @@ fn Mock() type {
/// IN/OUT self: *Self - Self. This is the mocking object to be modified to add
/// the test data.
/// IN fun_name: []const u8 - The function name to add the test parameters to.
/// IN data: var - The data to add.
/// IN data: anytype - The data to add.
/// IN action_type: ActionType - The action type to add.
///
pub fn addAction(self: *Self, comptime fun_name: []const u8, data: var, action_type: ActionType) void {
pub fn addAction(self: *Self, comptime fun_name: []const u8, data: anytype, action_type: ActionType) void {
// Add a new mapping if one doesn't exist.
if (!self.named_actions.contains(fun_name)) {
self.named_actions.put(fun_name, TailQueue(Action).init()) catch unreachable;
Expand Down Expand Up @@ -422,12 +422,12 @@ fn Mock() type {
/// perform a action.
/// IN fun_name: []const u8 - The function name to act on.
/// IN RetType: type - The return type of the function being mocked.
/// IN params: var - The list of parameters of the mocked function.
/// IN params: anytype - The list of parameters of the mocked function.
///
/// Return: RetType
/// The return value of the mocked function. This can be void.
///
pub fn performAction(self: *Self, comptime fun_name: []const u8, comptime RetType: type, params: var) RetType {
pub fn performAction(self: *Self, comptime fun_name: []const u8, comptime RetType: type, params: anytype) RetType {
if (self.named_actions.getEntry(fun_name)) |kv_actions_list| {
var action_list = kv_actions_list.value;
// Peak the first action to test the action type
Expand Down Expand Up @@ -655,9 +655,9 @@ pub fn freeTest() void {
/// IN/OUT self: *Self - Self. This is the mocking object to be modified to add
/// the test parameters.
/// IN fun_name: []const u8 - The function name to add the test parameters to.
/// IN params: var - The parameters to add.
/// IN params: anytype - The parameters to add.
///
pub fn addTestParams(comptime fun_name: []const u8, params: var) void {
pub fn addTestParams(comptime fun_name: []const u8, params: anytype) void {
var mock_obj = getMockObject();
comptime var i = 0;
inline while (i < params.len) : (i += 1) {
Expand All @@ -671,9 +671,9 @@ pub fn addTestParams(comptime fun_name: []const u8, params: var) void {
///
/// Arguments:
/// IN fun_name: []const u8 - The function name to add the function to.
/// IN function: var - The function to add.
/// IN function: anytype - The function to add.
///
pub fn addConsumeFunction(comptime fun_name: []const u8, function: var) void {
pub fn addConsumeFunction(comptime fun_name: []const u8, function: anytype) void {
getMockObject().addAction(fun_name, function, ActionType.ConsumeFunctionCall);
}

Expand All @@ -683,9 +683,9 @@ pub fn addConsumeFunction(comptime fun_name: []const u8, function: var) void {
///
/// Arguments:
/// IN fun_name: []const u8 - The function name to add the function to.
/// IN function: var - The function to add.
/// IN function: anytype - The function to add.
///
pub fn addRepeatFunction(comptime fun_name: []const u8, function: var) void {
pub fn addRepeatFunction(comptime fun_name: []const u8, function: anytype) void {
getMockObject().addAction(fun_name, function, ActionType.RepeatFunctionCall);
}

Expand All @@ -695,11 +695,11 @@ pub fn addRepeatFunction(comptime fun_name: []const u8, function: var) void {
/// Arguments:
/// IN fun_name: []const u8 - The function name to act on.
/// IN RetType: type - The return type of the function being mocked.
/// IN params: var - The list of parameters of the mocked function.
/// IN params: anytype - The list of parameters of the mocked function.
///
/// Return: RetType
/// The return value of the mocked function. This can be void.
///
pub fn performAction(comptime fun_name: []const u8, comptime RetType: type, params: var) RetType {
pub fn performAction(comptime fun_name: []const u8, comptime RetType: type, params: anytype) RetType {
return getMockObject().performAction(fun_name, RetType, params);
}
2 changes: 1 addition & 1 deletion test/mock/kernel/panic_mock.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const builtin = @import("builtin");
const std = @import("std");
const MemProfile = @import("mem_mock.zig").MemProfile;

pub fn panic(trace: ?*builtin.StackTrace, comptime format: []const u8, args: var) noreturn {
pub fn panic(trace: ?*builtin.StackTrace, comptime format: []const u8, args: anytype) noreturn {
@setCold(true);
std.debug.panic(format, args);
}
Expand Down