Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ OS_Status OS_TimerStart(OS_Timer_t *timer)
OS_Status OS_TimerChangePeriod(OS_Timer_t *timer, OS_Time_t periodMS)
{
rt_err_t ret;
rt_tick_t period_tick = rt_tick_from_millisecond(periodMS);

OS_DBG("%s(), handle %p\n", __func__, timer->handle);
OS_HANDLE_ASSERT(OS_TimerIsValid(timer), timer->handle);
Expand All @@ -139,7 +140,7 @@ OS_Status OS_TimerChangePeriod(OS_Timer_t *timer, OS_Time_t periodMS)
return OS_FAIL;
}
}
ret = rt_timer_control(timer->handle, RT_TIMER_CTRL_SET_TIME, &periodMS);
ret = rt_timer_control(timer->handle, RT_TIMER_CTRL_SET_TIME, &period_tick);
if (ret != RT_EOK) {
OS_ERR("err %"OS_BASETYPE_F"\n", ret);
return OS_FAIL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ static unsigned long event_delays_ns[] = {
static void ehci_enable_event(struct ehci_hcd *ehci, unsigned event,
bool resched)
{
unsigned long *timeout = &ehci->hr_timeouts[event];
unsigned long time_interval = 0;
rt_tick_t *timeout = &ehci->hr_timeouts[event];
rt_tick_t time_interval = 0;

if (resched)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ struct ehci_hcd { /* one per controller */
/* timing support */
enum ehci_hrtimer_event next_hrtimer_event;
unsigned enabled_hrtimer_events;
unsigned long hr_timeouts[EHCI_HRTIMER_NUM_EVENTS];
rt_tick_t hr_timeouts[EHCI_HRTIMER_NUM_EVENTS];
osal_timer_t hrtimer;

int PSS_poll_count;
Expand Down
2 changes: 1 addition & 1 deletion bsp/at91/at91sam9260/drivers/at91_mci.c
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ static void at91_mci_process_next(struct at91_mci *mci)
*/
static void at91_mci_request(struct rt_mmcsd_host *host, struct rt_mmcsd_req *req)
{
rt_uint32_t timeout = RT_TICK_PER_SECOND;
rt_tick_t timeout = RT_TICK_PER_SECOND;
struct at91_mci *mci = host->private_data;
mci->req = req;
mci->current_status = REQ_ST_INIT;
Expand Down
2 changes: 1 addition & 1 deletion bsp/at91/at91sam9g45/drivers/at91_mci.c
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ static void at91_mci_process_next(struct at91_mci *mci)
*/
static void at91_mci_request(struct rt_mmcsd_host *host, struct rt_mmcsd_req *req)
{
rt_uint32_t timeout = RT_TICK_PER_SECOND;
rt_tick_t timeout = RT_TICK_PER_SECOND;
struct at91_mci *mci = host->private_data;
mci->req = req;
mci->current_status = REQ_ST_INIT;
Expand Down
3 changes: 2 additions & 1 deletion components/drivers/ipc/completion_mp.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,11 @@ static rt_err_t _comp_susp_thread(struct rt_completion *completion,
/* 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
Contributor 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
Contributor 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.

我确认了下,没问题

/* reset the timeout of thread timer and start it */
rt_timer_control(&(thread->thread_timer),
RT_TIMER_CTRL_SET_TIME,
&timeout);
&timeout_tick);
rt_timer_start(&(thread->thread_timer));
}

Expand Down
3 changes: 2 additions & 1 deletion components/drivers/ipc/completion_up.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,11 @@ rt_err_t rt_completion_wait_flags(struct rt_completion *completion,
/* 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.

同上

/* reset the timeout of thread timer and start it */
rt_timer_control(&(thread->thread_timer),
RT_TIMER_CTRL_SET_TIME,
&timeout);
&timeout_tick);
rt_timer_start(&(thread->thread_timer));
}
/* enable interrupt */
Expand Down
2 changes: 1 addition & 1 deletion components/drivers/ipc/condvar.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static int _waitq_inqueue(rt_wqueue_t *queue, struct rt_wqueue_node *node,
if (ret == RT_EOK)
{
rt_wqueue_add(queue, node);
if (timeout != RT_WAITING_FOREVER)
if (timeout != (rt_tick_t)RT_WAITING_FOREVER)
{
rt_timer_control(timer, RT_TIMER_CTRL_SET_TIME, &timeout);

Expand Down
6 changes: 4 additions & 2 deletions components/drivers/ipc/dataqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,11 @@ rt_err_t rt_data_queue_push(struct rt_data_queue *queue,
/* 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.

同上,麻烦一并修改

/* reset the timeout of thread timer and start it */
rt_timer_control(&(thread->thread_timer),
RT_TIMER_CTRL_SET_TIME,
&timeout);
&timeout_tick);
rt_timer_start(&(thread->thread_timer));
}

Expand Down Expand Up @@ -247,10 +248,11 @@ rt_err_t rt_data_queue_pop(struct rt_data_queue *queue,
/* start timer */
if (timeout > 0)
{
rt_tick_t timeout_tick = timeout;
/* reset the timeout of thread timer and start it */
rt_timer_control(&(thread->thread_timer),
RT_TIMER_CTRL_SET_TIME,
&timeout);
&timeout_tick);
rt_timer_start(&(thread->thread_timer));
}

Expand Down
4 changes: 2 additions & 2 deletions components/drivers/ipc/waitqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ void rt_wqueue_wakeup_all(rt_wqueue_t *queue, void *key)
*/
static int _rt_wqueue_wait(rt_wqueue_t *queue, int condition, int msec, int suspend_flag)
{
int tick;
rt_tick_t tick;
rt_thread_t tid = rt_thread_self();
rt_timer_t tmr = &(tid->thread_timer);
struct rt_wqueue_node __wait;
Expand Down Expand Up @@ -241,7 +241,7 @@ static int _rt_wqueue_wait(rt_wqueue_t *queue, int condition, int msec, int susp
rt_list_insert_before(&(queue->waiting_list), &(__wait.list));

/* start timer */
if (tick != RT_WAITING_FOREVER)
if (tick != (rt_tick_t)RT_WAITING_FOREVER)
{
rt_timer_control(tmr,
RT_TIMER_CTRL_SET_TIME,
Expand Down
3 changes: 2 additions & 1 deletion components/libc/posix/io/epoll/epoll.c
Original file line number Diff line number Diff line change
Expand Up @@ -700,9 +700,10 @@ static int epoll_wait_timeout(struct rt_eventpoll *ep, int msec)
{
if (timeout > 0)
{
rt_tick_t timeout_tick = timeout;
rt_timer_control(&(thread->thread_timer),
RT_TIMER_CTRL_SET_TIME,
&timeout);
&timeout_tick);
rt_timer_start(&(thread->thread_timer));
}

Expand Down
9 changes: 5 additions & 4 deletions components/libc/posix/io/poll/poll.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
#include "poll.h"


enum rt_poll_status
enum rt_poll_status
{
RT_POLL_STAT_INIT, /**< Poll operation initialization status. */
RT_POLL_STAT_TRIG, /**< Poll operation triggered status. */
RT_POLL_STAT_WAITING /**< Poll operation waiting status. */
};


struct rt_poll_table
struct rt_poll_table
{
rt_pollreq_t req; /**< Poll request. */
enum rt_poll_status status; /**< Status of the poll operation. */
Expand All @@ -40,7 +40,7 @@ struct rt_poll_table
};


struct rt_poll_node
struct rt_poll_node
{
struct rt_wqueue_node wqn; /**< Wait queue node for the poll node. */
struct rt_poll_table *pt; /**< Pointer to the parent poll table. */
Expand Down Expand Up @@ -158,9 +158,10 @@ static int poll_wait_timeout(struct rt_poll_table *pt, int msec)
{
if (timeout > 0)
{
rt_tick_t timeout_tick = timeout;
rt_timer_control(&(thread->thread_timer),
RT_TIMER_CTRL_SET_TIME,
&timeout);
&timeout_tick);
rt_timer_start(&(thread->thread_timer));
rt_set_errno(RT_ETIMEOUT);
}
Expand Down
3 changes: 2 additions & 1 deletion components/libc/posix/pthreads/pthread_cond.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,10 +418,11 @@ rt_err_t _pthread_cond_timedwait(pthread_cond_t *cond,
/* has waiting time, start thread timer */
if (time > 0)
{
rt_tick_t time_tick = time;
/* reset the timeout of thread timer and start it */
rt_timer_control(&(thread->thread_timer),
RT_TIMER_CTRL_SET_TIME,
&time);
&time_tick);
rt_timer_start(&(thread->thread_timer));
}

Expand Down
9 changes: 6 additions & 3 deletions components/lwp/lwp_ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ static rt_err_t _do_send_recv_timeout(rt_channel_t ch, rt_channel_msg_t data, in
rt_thread_wakeup_set(thread_send, wakeup_sender_wait_recv, (void *)ch);
if (time > 0)
{
rt_tick_t time_tick = time;
rt_timer_control(&(thread_send->thread_timer),
RT_TIMER_CTRL_GET_FUNC,
&old_timeout_func);
Expand All @@ -562,7 +563,7 @@ static rt_err_t _do_send_recv_timeout(rt_channel_t ch, rt_channel_msg_t data, in
/* reset the timeout of thread timer and start it */
rt_timer_control(&(thread_send->thread_timer),
RT_TIMER_CTRL_SET_TIME,
&time);
&time_tick);
rt_timer_start(&(thread_send->thread_timer));
}
}
Expand Down Expand Up @@ -597,6 +598,7 @@ static rt_err_t _do_send_recv_timeout(rt_channel_t ch, rt_channel_msg_t data, in
rt_thread_wakeup_set(thread_send, wakeup_sender_wait_reply, (void *)ch);
if (time > 0)
{
rt_tick_t time_tick = time;
rt_timer_control(&(thread_send->thread_timer),
RT_TIMER_CTRL_GET_FUNC,
&old_timeout_func);
Expand All @@ -606,7 +608,7 @@ static rt_err_t _do_send_recv_timeout(rt_channel_t ch, rt_channel_msg_t data, in
/* reset the timeout of thread timer and start it */
rt_timer_control(&(thread_send->thread_timer),
RT_TIMER_CTRL_SET_TIME,
&time);
&time_tick);
rt_timer_start(&(thread_send->thread_timer));
}
}
Expand Down Expand Up @@ -870,6 +872,7 @@ static rt_err_t _rt_raw_channel_recv_timeout(rt_channel_t ch, rt_channel_msg_t d
thread->error = RT_EOK;
if (time > 0)
{
rt_tick_t time_tick = time;
rt_timer_control(&(thread->thread_timer),
RT_TIMER_CTRL_GET_FUNC,
&old_timeout_func);
Expand All @@ -879,7 +882,7 @@ static rt_err_t _rt_raw_channel_recv_timeout(rt_channel_t ch, rt_channel_msg_t d
/* reset the timeout of thread timer and start it */
rt_timer_control(&(thread->thread_timer),
RT_TIMER_CTRL_SET_TIME,
&time);
&time_tick);
rt_timer_start(&(thread->thread_timer));
}
rt_spin_unlock_irqrestore(&ch->slock, level);
Expand Down
6 changes: 3 additions & 3 deletions components/utilities/rt-link/src/rtlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ static rt_err_t rt_link_frame_send(rt_slist_t *slist)
}
else
{
rt_int32_t timeout = RT_LINK_SENT_FRAME_TIMEOUT;
rt_tick_t timeout = RT_LINK_SENT_FRAME_TIMEOUT;
rt_timer_control(&rt_link_scb->sendtimer, RT_TIMER_CTRL_SET_TIME, &timeout);
rt_timer_start(&rt_link_scb->sendtimer);
}
Expand Down Expand Up @@ -536,7 +536,7 @@ static void _long_handle_second(struct rt_link_frame *receive_frame)
}
else if (rt_link_hw_recv_len(rt_link_scb->rx_buffer) < (receive_frame->data_len % RT_LINK_MAX_DATA_LENGTH))
{
rt_int32_t timeout = RT_LINK_LONG_FRAME_TIMEOUT;
rt_tick_t timeout = RT_LINK_LONG_FRAME_TIMEOUT;
rt_timer_control(&rt_link_scb->longframetimer, RT_TIMER_CTRL_SET_TIME, &timeout);
rt_timer_start(&rt_link_scb->longframetimer);
}
Expand Down Expand Up @@ -879,7 +879,7 @@ static void rt_link_send_ready(void)
rt_link_command_frame_send(RT_LINK_SERVICE_RTLINK, seq,
RT_LINK_HANDSHAKE_FRAME, rt_link_scb->rx_record.rx_seq);

rt_int32_t timeout = 50;
rt_tick_t timeout = 50;
rt_timer_control(&rt_link_scb->sendtimer, RT_TIMER_CTRL_SET_TIME, &timeout);
rt_timer_start(&rt_link_scb->sendtimer);
}
Expand Down
3 changes: 2 additions & 1 deletion components/vbus/prio_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,10 @@ rt_err_t rt_prio_queue_pop(struct rt_prio_queue *que,

if (timeout > 0)
{
rt_tick_t timeout_tick = timeout;
rt_timer_control(&(thread->thread_timer),
RT_TIMER_CTRL_SET_TIME,
&timeout);
&timeout_tick);
rt_timer_start(&(thread->thread_timer));
}

Expand Down
3 changes: 2 additions & 1 deletion components/vbus/vbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,10 @@ rt_err_t rt_vbus_post(rt_uint8_t id,
rt_list_insert_after(&_chn_suspended_threads[id], &RT_THREAD_LIST_NODE(thread));
if (timeout > 0)
{
rt_tick_t timeout_tick = timeout;
rt_timer_control(&(thread->thread_timer),
RT_TIMER_CTRL_SET_TIME,
&timeout);
&timeout_tick);
rt_timer_start(&(thread->thread_timer));
}
/* rt_exit_critical will do schedule on need. */
Expand Down
3 changes: 2 additions & 1 deletion components/vbus/watermark_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ rt_inline rt_err_t rt_wm_que_inc(struct rt_watermark_queue *wg,
rt_list_insert_after(&wg->suspended_threads, &RT_THREAD_LIST_NODE(thread));
if (timeout > 0)
{
rt_tick_t timeout_tick = timeout;
rt_timer_control(&(thread->thread_timer),
RT_TIMER_CTRL_SET_TIME,
&timeout);
&timeout_tick);
rt_timer_start(&(thread->thread_timer));
}
rt_hw_interrupt_enable(level);
Expand Down
8 changes: 4 additions & 4 deletions examples/utest/testcases/kernel/timer_tc.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ static void timer_control(void *param)
static void test_static_timer_control(void)
{
rt_err_t result;
int set_data;
int get_data;
rt_tick_t set_data;
rt_tick_t get_data;

timer.callbacks = 0;
timer.is_static = RT_TRUE;
Expand Down Expand Up @@ -473,8 +473,8 @@ static void test_dynamic_timer(void)
static void test_dynamic_timer_control(void)
{
rt_err_t result;
int set_data;
int get_data;
rt_tick_t set_data;
rt_tick_t get_data;

timer.callbacks = 0;
timer.is_static = RT_FALSE;
Expand Down
Loading