Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Idea: Convert APIs that takes addresses in HALs to take `anytype`.

オープン
#446 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
15/100
issue の種類
リファクタリング
明瞭さ
おおむね明確
活発さ
停滞
領域
embedded-iot

調査の方向性

Start with the trigger_transfer function on the DMA Channel enum shown in the diff, and with the call sites that pass @intFromPtr(...) values. Survey which HAL functions take raw addresses as u32 or usize, and check how callers pass them. The issue is a proposal, not a settled change, so done means agreeing on the API direction with maintainers first. Only then would you add pointer checks and update the callers.

索引モデルが issue の本文から書いたものです。

説明

We have a bunch of functions that take addresses in our various HALs, but the type is often u32 or usize.

We should evaluate how they are used, and see if people tend to call them with points (e.g. by providing a slice or array) or an actual int.

In the former case, they'd have to do something like @intFromPtr, which is fine, but a bit annoying.

We can improve the ergonomics of these APIs (if we find that usage common) by having the type be anytype, and make type checks to ensure it is a pointer or appropriate type.

@@ -95,14 +95,16 @@ pub const Channel = enum(u4) {
 
     pub fn trigger_transfer(
         chan: Channel,
-        write_addr: u32,
-        read_addr: u32,
+        write_addr: anytype,
+        read_addr: anytype,
         count: u32,
         config: TransferConfig,
     ) void {
+        comptime if (@typeInfo(@TypeOf(write_addr)) != .pointer) @compileError("write_addr must be a pointer");
+        comptime if (@typeInfo(@TypeOf(read_addr)) != .pointer) @compileError("read_addr must be a pointer");
         const regs = chan.get_regs();
-        regs.read_addr = read_addr;
-        regs.write_addr = write_addr;
+        regs.read_addr = @intFromPtr(read_addr);
+        regs.write_addr = @intFromPtr(write_addr);
         regs.trans_count = count;
         regs.ctrl_trig.modify(.{
             .EN = @intFromBool(config.enable),

This allows the client to have a cleaner call:

     channel.?.trigger_transfer(
-        @intFromPtr(dst[0..dst.len].ptr),
-        @intFromPtr(hello[0..src.len].ptr),
+        dst[0..dst.len].ptr,
+        src[0..hello.len].ptr,
         src.len,
         .{

Of course, we can allow ints of the appropriate size as well, and we can write a helper to verify the type.

主要言語
Zig
スター
2.3k
フォーク
198
平均マージ
1日 8時間
マージ済み PR(30日)
37

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

ZigEmbeddedGroup/microzig のほかの issue

ZigEmbeddedGroup/microzig の issue をすべて見る

似ている issue

Embedded & IoT の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。