Flash 38 lines
// `callconv` in function types: `fn(…) callconv(.c) R` in type position makes
// a C-ABI function pointer spellable as a field type — the v-table shape. The
// convention sits between the parameter list and the return, exactly as on a
// declaration signature; parameters cross as ptr+len because callconv(.c)
// forbids slices. One field carries a default, so a table constructed with it
// omitted falls back to the stub.
//
// Lives in examples/register/ (post-v0.5 grammar — the frozen stage0
// bootstrap compiler cannot parse it; gated by `zig build fixpoint`).
pub const SuperBlock = struct {
_handle u8,
}
pub const File = struct {
_handle u8,
}
pub const BlockDev = extern struct {
read_fn ?*fn(u32, *mut [512]u8) callconv(.c) i32,
write_fn ?*fn(u32, *[512]u8) callconv(.c) i32,
}
pub const VfsOps = extern struct {
open *fn(*mut SuperBlock, [*]u8, usize) callconv(.c) c_int,
read *fn(*mut SuperBlock, *mut File, [*]mut u8, u64) callconv(.c) i64,
close *fn(*mut SuperBlock, *mut File) callconv(.c),
readdir *fn(*mut SuperBlock, [*]u8, usize, u64) callconv(.c) c_int = defaultReaddir,
}
fn defaultReaddir(sb *mut SuperBlock, path_ptr [*]u8, path_len usize, index u64) callconv(.c) c_int {
_ = sb
_ = path_ptr
_ = path_len
_ = index
return -1
}