Skip to content

Conversation

lygstate
Copy link

@lygstate lygstate commented Sep 21, 2025

Pass rt_tick_t for RT_TIMER_CTRL_SET_TIME and RT_TIMER_CTRL_GET_TIME

为什么提交这份PR (why to submit this PR)

RT_TIMER_CTRL_SET_TIME and RT_TIMER_CTRL_GET_TIME only accept rt_tick_t, but the current code base pass int/rt_int32_t
randomly.

你的解决方案是什么 (what is your solution)

Check all place that use RT_TIMER_CTRL_SET_TIME /RT_TIMER_CTRL_GET_TIME and fixes it accordingly

当前拉取/合并请求的状态 Intent for your PR

必须选择一项 Choose one (Mandatory):

  • 本拉取/合并请求是一个成熟版本 This PR is mature, and ready to be integrated into the repo

代码质量 Code Quality:

我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:

  • 已经仔细查看过代码改动的对比 Already check the difference between PR and old code
  • 代码风格正确,包括缩进空格,命名及其他风格 Style guide is adhered to, including spacing, naming and other styles
  • 没有垃圾代码,代码尽量精简,不包含#if 0代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up
  • 所有变更均有原因及合理的,并且不会影响到其他软件组件代码或BSP All modifications are justified and not affect other components or BSP
  • 对难懂代码均提供对应的注释 I've commented appropriately where code is tricky
  • 代码是高质量的 Code in this PR is of high quality
  • 已经使用formatting 等源码格式化工具确保格式符合RT-Thread代码规范 This PR complies with RT-Thread code specification

@CLAassistant
Copy link

CLAassistant commented Sep 21, 2025

CLA assistant check
All committers have signed the CLA.

Copy link

github-actions bot commented Sep 21, 2025

📌 Code Review Assignment

🏷️ Tag: components

Reviewers: Maihuanyi

Changed Files (Click to expand)
  • components/drivers/ipc/completion_mp.c
  • components/drivers/ipc/completion_up.c
  • components/drivers/ipc/condvar.c
  • components/drivers/ipc/dataqueue.c
  • components/drivers/ipc/waitqueue.c
  • components/libc/posix/io/epoll/epoll.c
  • components/libc/posix/io/poll/poll.c
  • components/libc/posix/pthreads/pthread_cond.c
  • components/lwp/lwp_ipc.c
  • components/utilities/rt-link/src/rtlink.c
  • components/vbus/prio_queue.c
  • components/vbus/vbus.c
  • components/vbus/watermark_queue.h

🏷️ Tag: components_libc

Reviewers: GorrayLi mysterywolf

Changed Files (Click to expand)
  • components/libc/posix/io/epoll/epoll.c
  • components/libc/posix/io/poll/poll.c
  • components/libc/posix/pthreads/pthread_cond.c

🏷️ Tag: components_lwp

Reviewers: xu18838022837

Changed Files (Click to expand)
  • components/lwp/lwp_ipc.c

🏷️ Tag: kernel

Reviewers: GorrayLi ReviewSun hamburger-os lianux-mm wdfk-prog xu18838022837

Changed Files (Click to expand)
  • src/ipc.c
  • src/mempool.c
  • src/signal.c

📊 Current Review Status (Last Updated: 2025-09-23 13:59 CST)

  • GorrayLi Pending Review
  • Maihuanyi Pending Review
  • ReviewSun Pending Review
  • hamburger-os Pending Review
  • lianux-mm Pending Review
  • mysterywolf Pending Review
  • wdfk-prog Pending Review
  • xu18838022837 Pending Review

📝 Review Instructions

  1. 维护者可以通过单击此处来刷新审查状态: 🔄 刷新状态
    Maintainers can refresh the review status by clicking here: 🔄 Refresh Status

  2. 确认审核通过后评论 LGTM/lgtm
    Comment LGTM/lgtm after confirming approval

  3. PR合并前需至少一位维护者确认
    PR must be confirmed by at least one maintainer before merging

ℹ️ 刷新CI状态操作需要具备仓库写入权限。
ℹ️ Refresh CI status operation requires repository Write permission.

@Rbb666 Rbb666 requested a review from Copilot September 21, 2025 23:22
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Standardize timer control APIs to use rt_tick_t for RT_TIMER_CTRL_SET_TIME/GET_TIME and fix unit mismatches.

  • Replace int/rt_int32_t timeout arguments with rt_tick_t when calling rt_timer_control for SET_TIME across kernel, drivers, and components.
  • Update tests to use rt_tick_t for timer control.
  • Fix OSAL timer period change to convert milliseconds to ticks before RT_TIMER_CTRL_SET_TIME.

Reviewed Changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/signal.c Use rt_tick_t when setting thread timer timeout.
src/mempool.c Use rt_tick_t for memory pool allocation timeout timer.
src/ipc.c Use rt_tick_t for sem/mutex/event/mailbox/message queue timeout timers.
examples/utest/testcases/kernel/timer_tc.c Update test variables to rt_tick_t for timer control.
components/vbus/watermark_queue.h Use rt_tick_t for watermark queue timeout.
components/vbus/vbus.c Use rt_tick_t for vbus post timeout.
components/vbus/prio_queue.c Use rt_tick_t for priority queue pop timeout.
components/utilities/rt-link/src/rtlink.c Use rt_tick_t for multiple RT-Link timeouts.
components/lwp/lwp_ipc.c Use rt_tick_t for LWP IPC timeouts and pass to RT_TIMER_CTRL_SET_TIME.
components/libc/posix/pthreads/pthread_cond.c Use rt_tick_t for pthread_cond timed wait.
components/libc/posix/io/poll/poll.c Use rt_tick_t for poll timeout.
components/libc/posix/io/epoll/epoll.c Use rt_tick_t for epoll timeout.
components/drivers/ipc/waitqueue.c Use rt_tick_t for internal waitqueue ticks and compare against RT_WAITING_FOREVER with cast.
components/drivers/ipc/dataqueue.c Use rt_tick_t for dataqueue push/pop timeouts.
components/drivers/ipc/condvar.c Compare timeout against (rt_tick_t)RT_WAITING_FOREVER before starting timer.
components/drivers/ipc/completion_up.c Use rt_tick_t for completion wait timeout.
components/drivers/ipc/completion_mp.c Use rt_tick_t for completion timeout in MP variant.
bsp/at91/at91sam9g45/drivers/at91_mci.c Use rt_tick_t for request timeout.
bsp/at91/at91sam9260/drivers/at91_mci.c Use rt_tick_t for request timeout.
bsp/allwinner/libraries/sunxi-hal/hal/source/usb/host/ehci.h Change hr_timeouts[] to rt_tick_t.
bsp/allwinner/libraries/sunxi-hal/hal/source/usb/host/ehci-timer.c Update local timeout variables to rt_tick_t.
bsp/allwinner/libraries/sunxi-hal/hal/source/sdmmc/osal/os/RT-Thread/os_timer.c Convert ms to ticks and pass rt_tick_t to RT_TIMER_CTRL_SET_TIME.

@lygstate lygstate force-pushed the use_rt_tick_t branch 2 times, most recently from 4d90295 to 3e2e1d7 Compare September 23, 2025 04:32
@lygstate
Copy link
Author

@Rbb666
Copy link
Member

Rbb666 commented Sep 23, 2025

https://github.com/RT-Thread/rt-thread/actions/runs/17906689817/job/50948392945?pr=10717 错误没看懂

需要在文件结尾加一个换行:

image

/* start timer */
if (timeout > 0)
{
rt_tick_t timeout_tick = timeout;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

涉及到内核相关的,尽量不要用c99的语法吧。局部变量的声明需要放在函数的开头。

Copy link
Author

@lygstate lygstate Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这也是C89语法,C89语法的意思就是,变量声明必须在{之后的第一行,不一定非要在函数的第一行,有CI保证C89语法吗?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://stackoverflow.com/a/9513651/321938
你可以用C89编译器试一下一下代码

include <stdio.h>
int main()
{
    int i = 22;
    printf("%d\n", i);
    {
        int j = 42;
        printf("%d\n", j);
    }
    return 0;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我确认了下,没问题

/* start timer */
if (timeout > 0)
{
rt_tick_t timeout_tick = timeout;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上

/* start timer */
if (timeout > 0)
{
rt_tick_t timeout_tick = timeout;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上,麻烦一并修改

…hread/os_timer.c call to RT_TIMER_CTRL_SET_TIME

RT_TIMER_CTRL_SET_TIME expects a pointer to rt_tick_t (ticks).
period_tick is derived from periodMS (milliseconds) via rt_tick_from_millisecond
to ensure correct units are passed.
/* start timer */
if (timeout > 0)
{
rt_tick_t timeout_tick = timeout;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我确认了下,没问题

@Rbb666 Rbb666 added this to the v5.2.2 milestone Sep 23, 2025
@Rbb666
Copy link
Member

Rbb666 commented Sep 23, 2025

@lygstate 这个PR需要rebase方式合并好一些?

@lygstate
Copy link
Author

@lygstate 这个PR需要rebase方式合并好一些?

我看到你把ci修正了,所以rebase一下来通过ci

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants