Skip to content
Open
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
10 changes: 6 additions & 4 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ pub fn build(b: *Build) void {
.exclude_dirs = &.{b.path("tools/sorcerer")},
});
builder.addRule(.{ .builtin = .no_hidden_allocations }, .{});
builder.addRule(.{ .builtin = .no_deprecated }, .{});
builder.addRule(.{ .builtin = .no_literal_only_bool_expression }, .{});
builder.addRule(.{ .builtin = .require_fmt }, .{});
break :step builder.build();
});
Expand Down Expand Up @@ -161,7 +163,7 @@ pub fn MicroBuild(port_select: PortSelect) type {

var field_names: [count][]const u8 = undefined;
var field_types: [count]type = undefined;
var field_attrs: [count]std.builtin.Type.Struct.FieldAttributes = undefined;
var field_attrs: [count]std.lang.Type.Struct.FieldAttributes = undefined;

if (count > 0) {
var i: usize = 0;
Expand Down Expand Up @@ -238,7 +240,7 @@ pub fn MicroBuild(port_select: PortSelect) type {

/// The optimization level that should be used. Usually `ReleaseSmall` or `Debug` is a good choice.
/// Also using `std.Build.standardOptimizeOption` is a good idea.
optimize: std.builtin.OptimizeMode,
optimize: std.lang.Optimize,

/// The root source file for the application. This is your `src/main.zig` file.
root_source_file: LazyPath,
Expand Down Expand Up @@ -286,7 +288,7 @@ pub fn MicroBuild(port_select: PortSelect) type {
strip_unused_symbols: bool = true,

/// Unwind tables option for the firmware executable.
unwind_tables: ?std.builtin.UnwindTables = null,
unwind_tables: ?std.lang.UnwindTables = null,

/// Error tracing option for the firmware executable.
error_tracing: ?bool = null,
Expand Down Expand Up @@ -759,7 +761,7 @@ pub fn MicroBuild(port_select: PortSelect) type {
},
}) catch @panic("OOM"),
};
} else if (target.cpu.arch.isRISCV() and target.ptrBitWidth() == 32) {
} else if (target.cpu.arch.isRiscv() and target.ptrBitWidth() == 32) {
return .{
.name = "riscv32",
.root_source_file = mb.core_dep.namedLazyPath("cpu_riscv32"),
Expand Down
12 changes: 6 additions & 6 deletions core/src/allocator.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1273,7 +1273,7 @@ test "oom - near exhaustion still works" {
const a = alloc.allocator();

// Allocate until near exhaustion
var allocations: std.ArrayListUnmanaged([]u8) = .empty;
var allocations: std.ArrayList([]u8) = .empty;
defer allocations.deinit(testing.allocator);

while (true) {
Expand Down Expand Up @@ -1467,7 +1467,7 @@ test "stress - random alloc/free pattern" {
var prng = std.Random.DefaultPrng.init(12345);
const random = prng.random();

var allocations: std.ArrayListUnmanaged([]u8) = .empty;
var allocations: std.ArrayList([]u8) = .empty;
defer allocations.deinit(testing.allocator);

// Perform random operations
Expand Down Expand Up @@ -1520,7 +1520,7 @@ test "stress - many small allocations" {
var alloc = try Alloc.init_with_buffer(&buffer);
const a = alloc.allocator();

var allocations: std.ArrayListUnmanaged([]u8) = .empty;
var allocations: std.ArrayList([]u8) = .empty;
defer allocations.deinit(testing.allocator);

// Allocate many small chunks
Expand Down Expand Up @@ -1556,7 +1556,7 @@ test "fallback - allocation delegates when primary exhausted" {
const a = alloc1.allocator();

// Exhaust primary
var primary_allocations: std.ArrayListUnmanaged([]u8) = .empty;
var primary_allocations: std.ArrayList([]u8) = .empty;
defer primary_allocations.deinit(testing.allocator);

while (true) {
Expand Down Expand Up @@ -1588,7 +1588,7 @@ test "fallback - free delegates correctly" {
const mem1 = try a.alloc(u8, 32);

// Exhaust primary to force fallback use
var temp_allocs: std.ArrayListUnmanaged([]u8) = .empty;
var temp_allocs: std.ArrayList([]u8) = .empty;
defer temp_allocs.deinit(testing.allocator);

while (true) {
Expand Down Expand Up @@ -1621,7 +1621,7 @@ test "fallback - chain of allocators" {

const a = alloc1.allocator();

var all_allocations: std.ArrayListUnmanaged([]u8) = .empty;
var all_allocations: std.ArrayList([]u8) = .empty;
defer all_allocations.deinit(testing.allocator);

// Should be able to allocate from all three buffers
Expand Down
6 changes: 3 additions & 3 deletions core/src/core/usb.zig
Original file line number Diff line number Diff line change
Expand Up @@ -270,14 +270,14 @@ pub fn DeviceController(config: Config, driver_args: config.DriverArgs()) type {
var size = @sizeOf(descriptor.Configuration);
var field_names: [driver_info.field_names.len][:0]const u8 = undefined;
var field_types: [driver_info.field_names.len]type = undefined;
var field_attrs: [driver_info.field_names.len]std.builtin.Type.Struct.FieldAttributes = undefined;
var field_attrs: [driver_info.field_names.len]std.lang.Type.Struct.FieldAttributes = undefined;
var ep_handler_types: [2][16]type = @splat(@splat(void));
var ep_handler_names: [2][16][:0]const u8 = undefined;
var ep_handler_drivers: [2][16]?usize = @splat(@splat(null));
var itf_handlers: []const DriverEnum = &.{};
var driver_alloc_names: []const [:0]const u8 = &.{};
var driver_alloc_types: []const type = &.{};
var driver_alloc_attrs: []const std.builtin.Type.Struct.FieldAttributes = &.{};
var driver_alloc_attrs: []const std.lang.Type.Struct.FieldAttributes = &.{};

for (driver_info.field_names, driver_info.field_types, 0..) |driver_field_name, driver_field_type, drv_id| {
// Get descriptor type for the current driver
Expand All @@ -291,7 +291,7 @@ pub fn DeviceController(config: Config, driver_args: config.DriverArgs()) type {
if (result.alloc_bytes) |len| {
driver_alloc_names = driver_alloc_names ++ &[_][:0]const u8{driver_field_name};
driver_alloc_types = driver_alloc_types ++ &[_]type{[len]u8};
driver_alloc_attrs = driver_alloc_attrs ++ &[_]std.builtin.Type.Struct.FieldAttributes{.{ .@"align" = result.alloc_align }};
driver_alloc_attrs = driver_alloc_attrs ++ &[_]std.lang.Type.Struct.FieldAttributes{.{ .@"align" = result.alloc_align }};
} else {
assert(result.alloc_align == null);
}
Expand Down
12 changes: 6 additions & 6 deletions core/src/cpus/cortex_m.zig
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ pub const atomic = struct {
}

/// Atomic load
pub fn load(comptime T: type, ptr: *const T, comptime ordering: std.builtin.AtomicOrder) T {
pub fn load(comptime T: type, ptr: *const T, comptime ordering: std.lang.AtomicOrder) T {
if (has_native_atomics) {
return @atomicLoad(T, ptr, ordering);
} else {
Expand All @@ -575,7 +575,7 @@ pub const atomic = struct {
}

/// Atomic store
pub fn store(comptime T: type, ptr: *T, value: T, comptime ordering: std.builtin.AtomicOrder) void {
pub fn store(comptime T: type, ptr: *T, value: T, comptime ordering: std.lang.AtomicOrder) void {
if (has_native_atomics) {
@atomicStore(T, ptr, value, ordering);
} else {
Expand All @@ -592,8 +592,8 @@ pub const atomic = struct {
ptr: *T,
expected_value: T,
new_value: T,
comptime success_ordering: std.builtin.AtomicOrder,
comptime failure_ordering: std.builtin.AtomicOrder,
comptime success_ordering: std.lang.AtomicOrder,
comptime failure_ordering: std.lang.AtomicOrder,
) ?T {
if (has_native_atomics) {
return @cmpxchgWeak(T, ptr, expected_value, new_value, success_ordering, failure_ordering);
Expand All @@ -614,9 +614,9 @@ pub const atomic = struct {
pub fn rmw(
comptime T: type,
ptr: *T,
comptime op: std.builtin.AtomicRmwOp,
comptime op: std.lang.AtomicRmwOp,
operand: T,
comptime ordering: std.builtin.AtomicOrder,
comptime ordering: std.lang.AtomicOrder,
) T {
if (has_native_atomics) {
return @atomicRmw(T, ptr, op, operand, ordering);
Expand Down
2 changes: 1 addition & 1 deletion core/src/microzig.zig
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ fn microzig_main() callconv(.c) noreturn {
};

var buf: [msg_base.len + max_error_size]u8 = undefined;
const msg = std.fmt.bufPrint(&buf, "{s}{s}", .{ msg_base, @errorName(err) }) catch @panic(msg_base);
const msg = std.mem.print(&buf, "{s}{s}", .{ msg_base, @errorName(err) }) catch @panic(msg_base);
@panic(msg);
} else {
@panic(msg_base);
Expand Down
2 changes: 1 addition & 1 deletion core/test/backings.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const std = @import("std");
const microzig = @import("../build.zig");

fn root_dir() []const u8 {
return std.fs.path.dirname(@src().file) orelse unreachable;
return std.Io.Dir.path.dirname(@src().file) orelse unreachable;
}

const cpu = microzig.Cpu{
Expand Down
4 changes: 2 additions & 2 deletions drivers/src/base/DatagramDevice.zig
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ pub const VTable = struct {
/// A device implementation that can be used to write unit tests for datagram devices.
pub const TestDevice = struct {
arena: std.heap.ArenaAllocator,
packets: std.array_list.Managed([]u8),
packets: std.array_list.Managed([]u8), // zlinter-disable-current-line no_deprecated

// If empty, reads are supported, but don't yield data.
// If `null`, reads are not supported.
Expand All @@ -164,7 +164,7 @@ pub const TestDevice = struct {
pub fn init(input: ?[]const []const u8, write_enabled: bool) TestDevice {
return TestDevice{
.arena = std.heap.ArenaAllocator.init(std.testing.allocator),
.packets = std.array_list.Managed([]u8).init(std.testing.allocator),
.packets = .init(std.testing.allocator),

.input_sequence = input,
.input_sequence_pos = 0,
Expand Down
4 changes: 2 additions & 2 deletions drivers/src/base/I2C_Device.zig
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ pub const VTable = struct {
/// A device implementation that can be used to write unit tests for datagram devices.
pub const TestDevice = struct {
arena: std.heap.ArenaAllocator,
packets: std.array_list.Managed([]u8),
packets: std.array_list.Managed([]u8), // zlinter-disable-current-line no_deprecated

// If empty, reads are supported, but don't yield data.
// If `null`, reads are not supported.
Expand All @@ -152,7 +152,7 @@ pub const TestDevice = struct {
pub fn init(input: ?[]const []const u8, write_enabled: bool) TestDevice {
return TestDevice{
.arena = std.heap.ArenaAllocator.init(std.testing.allocator),
.packets = std.array_list.Managed([]u8).init(std.testing.allocator),
.packets = .init(std.testing.allocator),

.input_sequence = input,
.input_sequence_pos = 0,
Expand Down
4 changes: 2 additions & 2 deletions drivers/src/base/StreamDevice.zig
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ pub const Reader = struct {
/// A device implementation that can be used to write unit tests for datagram devices.
pub const TestDevice = struct {
input: ?std.Io.Reader,
output: ?std.array_list.Managed(u8),
output: ?std.array_list.Managed(u8), // zlinter-disable-current-line no_deprecated

connected: bool,

Expand All @@ -189,7 +189,7 @@ pub const TestDevice = struct {

.input = if (input) |bytes| .fixed(bytes) else null,
.output = if (write_enabled)
std.array_list.Managed(u8).init(std.testing.allocator)
std.array_list.Managed(u8).init(std.testing.allocator) // zlinter-disable-current-line no_deprecated
else
null,
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/src/display/colors.zig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub const BlackWhite = enum(u1) {
white = 1,
};

pub fn RGB565_Generic(desired_endianness: std.builtin.Endian) type {
pub fn RGB565_Generic(desired_endianness: std.lang.Endian) type {
return struct {
const Self = @This();

Expand Down
2 changes: 1 addition & 1 deletion drivers/src/input/keyboard_matrix.zig
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub fn KeyboardMatrix(comptime options: Options) type {

/// A set that can store if each key is set or not.
pub const Set = struct {
pressed: std.StaticBitSet(key_count) = .empty,
pressed: std.bit_set.Static(key_count) = .empty,

/// Adds a key to the set.
pub fn add(set: *Set, key: Key) void {
Expand Down
2 changes: 1 addition & 1 deletion drivers/src/wireless/cyw43439/ioctl.zig
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ pub const Response = struct {
}
var evt: EventPacket = undefined;
@memcpy(std.mem.asBytes(&evt), buf[0..@sizeOf(EventPacket)]);
std.mem.byteSwapAllFields(EventPacket, &evt);
std.mem.byteSwap(EventPacket, &evt);

if (evt.eth.ether_type != 0x886c) return null;
if (!mem.eql(u8, &evt.hdr.oui, &.{ 0x00, 0x10, 0x18 })) return null;
Expand Down
2 changes: 1 addition & 1 deletion examples/nordic/nrf5x/src/usb_cdc.zig
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ var usb_tx_buff: [1024]u8 = undefined;
/// NOTE: After each USB chunk transfer, we have to call the USB task so that bus TX events can be
/// handled
pub fn usb_cdc_write(serial: *USB_Serial, comptime fmt: []const u8, args: anytype) void {
var tx = std.fmt.bufPrint(&usb_tx_buff, fmt, args) catch &.{};
var tx = std.mem.print(&usb_tx_buff, fmt, args) catch &.{};

while (tx.len > 0) {
tx = tx[serial.write(tx)..];
Expand Down
14 changes: 7 additions & 7 deletions examples/raspberrypi/rp2xxx/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -107,25 +107,25 @@ pub fn build(b: *std.Build) void {
.{ .name = "flash-program", .file = "src/flash_program.zig" },
};

var available_examples: std.array_list.Managed(Example) = .init(b.allocator);
available_examples.appendSlice(specific_examples) catch @panic("out of memory");
var available_examples: std.ArrayList(Example) = .empty;
available_examples.appendSlice(b.allocator, specific_examples) catch @panic("out of memory");
for (chip_agnostic_examples) |example| {
available_examples.append(.{
available_examples.append(b.allocator, .{
.target = raspberrypi.pico,
.name = b.fmt("pico_{s}", .{example.name}),
.file = example.file,
.imports = example.imports,
}) catch @panic("out of memory");

available_examples.append(.{
available_examples.append(b.allocator, .{
.target = raspberrypi.pico2_arm,
.name = b.fmt("pico2_arm_{s}", .{example.name}),
.file = example.file,
.imports = example.imports,
}) catch @panic("out of memory");

if (example.works_with_riscv) {
available_examples.append(.{
available_examples.append(b.allocator, .{
.target = raspberrypi.pico2_riscv,
.name = b.fmt("pico2_riscv_{s}", .{example.name}),
.file = example.file,
Expand Down Expand Up @@ -154,7 +154,7 @@ pub fn build(b: *std.Build) void {
});

// Import net module for some examples
if (std.mem.indexOf(u8, example.name, "_net-") != null) {
if (std.mem.find(u8, example.name, "_net-") != null) {
const net_dep = b.dependency("net", .{
.target = b.resolveTargetQuery(fw.target.zig_target),
.optimize = optimize,
Expand All @@ -170,7 +170,7 @@ pub fn build(b: *std.Build) void {

// Import freertos module for some examples, kind of a hack
// probably list of required modules should be specified in each example independently
if (std.mem.indexOf(u8, example.name, "_freertos-") != null) {
if (std.mem.find(u8, example.name, "_freertos-") != null) {
var port_name: []const u8 = "Unknown";

// FIXME: hacky way to select port based on target name (it doesn't take RP2350_RISCV into account)
Expand Down
2 changes: 1 addition & 1 deletion examples/raspberrypi/rp2xxx/src/board_id.zig
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ comptime {
_ = microzig.export_startup();
}

pub fn panic(message: []const u8, _: ?*std.builtin.StackTrace, _: ?usize) noreturn {
pub fn panic(message: []const u8, _: ?*std.lang.StackTrace, _: ?usize) noreturn {
std.log.err("panic: {s}", .{message});
@breakpoint();
while (true) {}
Expand Down
2 changes: 1 addition & 1 deletion examples/raspberrypi/rp2xxx/src/dma.zig
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ comptime {
_ = microzig.export_startup();
}

pub fn panic(message: []const u8, _: ?*std.builtin.StackTrace, _: ?usize) noreturn {
pub fn panic(message: []const u8, _: ?*std.lang.StackTrace, _: ?usize) noreturn {
std.log.err("panic: {s}", .{message});
@breakpoint();
while (true) {}
Expand Down
2 changes: 1 addition & 1 deletion examples/raspberrypi/rp2xxx/src/flash_program.zig
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ comptime {
_ = microzig.export_startup();
}

pub fn panic(message: []const u8, _: ?*std.builtin.StackTrace, _: ?usize) noreturn {
pub fn panic(message: []const u8, _: ?*std.lang.StackTrace, _: ?usize) noreturn {
std.log.err("panic: {s}", .{message});
@breakpoint();
while (true) {}
Expand Down
2 changes: 1 addition & 1 deletion examples/raspberrypi/rp2xxx/src/net/tcp_client.zig
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ const Client = struct {
// ref: https://github.com/lwip-tcpip/lwip/blob/6ca936f6b588cee702c638eee75c2436e6cf75de/src/include/lwip/opt.h#L1310
var buf: [net.lwip.TCP_SND_BUF + 128]u8 = @splat('-');
// add some header to the buf
_ = std.fmt.bufPrint(
_ = std.mem.print(
&buf,
"hello from rpi pi pico {}",
.{self.send_count},
Expand Down
2 changes: 1 addition & 1 deletion examples/raspberrypi/rp2xxx/src/rp2040_only/random.zig
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ comptime {
_ = microzig.export_startup();
}

pub fn panic(message: []const u8, _: ?*std.builtin.StackTrace, _: ?usize) noreturn {
pub fn panic(message: []const u8, _: ?*std.lang.StackTrace, _: ?usize) noreturn {
std.log.err("panic: {s}", .{message});
@breakpoint();
while (true) {}
Expand Down
2 changes: 1 addition & 1 deletion examples/raspberrypi/rp2xxx/src/ssd1306_oled.zig
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub fn main() void {
var aa = std.heap.ArenaAllocator.init(fba.allocator());
defer aa.deinit();
var temp_buf: [7]u8 = undefined;
const str = std.fmt.bufPrint(&temp_buf, "Try #{}", .{i}) catch unreachable;
const str = std.mem.print(&temp_buf, "Try #{}", .{i}) catch unreachable;
var counter_buf: [80]u8 = undefined;
const text_centered = center_to_screen(&counter_buf, str);

Expand Down
2 changes: 1 addition & 1 deletion examples/raspberrypi/rp2xxx/src/stepper_driver.zig
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ comptime {
_ = microzig.export_startup();
}

pub fn panic(message: []const u8, _: ?*std.builtin.StackTrace, _: ?usize) noreturn {
pub fn panic(message: []const u8, _: ?*std.lang.StackTrace, _: ?usize) noreturn {
std.log.err("panic: {s}", .{message});
@breakpoint();
while (true) {}
Expand Down
2 changes: 1 addition & 1 deletion examples/raspberrypi/rp2xxx/src/stepper_driver_dumb.zig
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ comptime {
_ = microzig.export_startup();
}

pub fn panic(message: []const u8, _: ?*std.builtin.StackTrace, _: ?usize) noreturn {
pub fn panic(message: []const u8, _: ?*std.lang.StackTrace, _: ?usize) noreturn {
std.log.err("panic: {s}", .{message});
@breakpoint();
while (true) {}
Expand Down
Loading
Loading