fix casting functions, add some tests
This commit is contained in:
@@ -10,17 +10,6 @@ const StringContext = std.hash_map.StringContext;
|
||||
pub const MaxShells = 63;
|
||||
pub const MaxShellLen = 64;
|
||||
|
||||
// ShellIndex is an index to the shell strings. As shell can be up to 64 bytes
|
||||
// (1<<6), maximum number of shells is 63 (1<<6-1), the maximum location offset
|
||||
// is 1<<12. To make location resolvable in 10 bits, all shells will be padded
|
||||
// to 4 bytes.
|
||||
// The actual shell length is len+1: we don't allow empty shells, and the real
|
||||
// length of the shell is 1-64 bytes.
|
||||
const ShellIndex = struct {
|
||||
offset: u10,
|
||||
len: u6,
|
||||
};
|
||||
|
||||
// ShellReader interprets "Shell Index" and "Shell Blob" sections.
|
||||
pub const ShellReader = struct {
|
||||
sectionIndex: []const ShellIndex,
|
||||
@@ -81,7 +70,7 @@ pub const ShellWriter = struct {
|
||||
const padding = roundUp4Padding(fullOffset);
|
||||
fullOffset += padding;
|
||||
//const stderr = std.io.getStdErr().writer();
|
||||
//try stderr.print("\n", .{});
|
||||
//stderr.print("\n", .{}) catch unreachable;
|
||||
try self.blob.appendNTimes(0, padding);
|
||||
idx += 1;
|
||||
}
|
||||
@@ -181,6 +170,17 @@ inline fn roundUp4Padding(n: u12) u12 {
|
||||
return ((n + 3) & ~@intCast(u12, 3)) - n;
|
||||
}
|
||||
|
||||
// ShellIndex is an index to the shell strings. As shell can be up to 64 bytes
|
||||
// (1<<6), maximum number of shells is 63 (1<<6-1), the maximum location offset
|
||||
// is 1<<12. To make location resolvable in 10 bits, all shells will be padded
|
||||
// to 4 bytes.
|
||||
// The actual shell length is len+1: we don't allow empty shells, and the real
|
||||
// length of the shell is 1-64 bytes.
|
||||
const ShellIndex = struct {
|
||||
offset: u10,
|
||||
len: u6,
|
||||
};
|
||||
|
||||
const testing = std.testing;
|
||||
|
||||
test "basic shellpopcon" {
|
||||
|
||||
Reference in New Issue
Block a user