Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
智驾
rt-thread
提交
f52095d2
R
rt-thread
项目概览
智驾
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
f52095d2
编写于
7月 21, 2023
作者:
mysterywolf
提交者:
mysterywolf
7月 21, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[libc][time] cleanup code
上级
c985f318
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
13 addition
and
20 deletion
+13
-20
components/libc/compilers/common/ctime.c
components/libc/compilers/common/ctime.c
+13
-20
未找到文件。
components/libc/compilers/common/ctime.c
浏览文件 @
f52095d2
...
@@ -26,21 +26,18 @@
...
@@ -26,21 +26,18 @@
#include "sys/time.h"
#include "sys/time.h"
#include <rthw.h>
#include <rthw.h>
#include <rtthread.h>
#include <rtdevice.h>
#include <drivers/rtc.h>
#include <sys/errno.h>
#include <sys/errno.h>
#include <unistd.h>
#include <unistd.h>
#include "drivers/rtc.h"
#ifdef RT_USING_SMART
#ifdef RT_USING_SMART
#include
"lwp.h"
#include
<lwp.h>
#endif
#endif
#ifdef RT_USING_POSIX_DELAY
#ifdef RT_USING_POSIX_DELAY
#include <delay.h>
#include <delay.h>
#endif
#endif
#if defined( RT_USING_RTC ) || defined( RT_USING_CPUTIME)
#include <rtdevice.h>
#endif
#ifdef RT_USING_KTIME
#ifdef RT_USING_KTIME
#include
"ktime.h"
#include
<ktime.h>
#endif
#endif
#define DBG_TAG "time"
#define DBG_TAG "time"
...
@@ -49,9 +46,6 @@
...
@@ -49,9 +46,6 @@
#define _WARNING_NO_RTC "Cannot find a RTC device!"
#define _WARNING_NO_RTC "Cannot find a RTC device!"
/* seconds per day */
#define SPD 24*60*60
/* days per month -- nonleap! */
/* days per month -- nonleap! */
static
const
short
__spm
[
13
]
=
static
const
short
__spm
[
13
]
=
{
{
...
@@ -70,8 +64,8 @@ static const short __spm[13] =
...
@@ -70,8 +64,8 @@ static const short __spm[13] =
(
31
+
28
+
31
+
30
+
31
+
30
+
31
+
31
+
30
+
31
+
30
+
31
),
(
31
+
28
+
31
+
30
+
31
+
30
+
31
+
31
+
30
+
31
+
30
+
31
),
};
};
rt_align
(
4
)
static
const
char
*
days
=
"Sun Mon Tue Wed Thu Fri Sat "
;
rt_align
(
RT_ALIGN_SIZE
)
static
const
char
*
days
=
"Sun Mon Tue Wed Thu Fri Sat "
;
rt_align
(
4
)
static
const
char
*
months
=
"Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec "
;
rt_align
(
RT_ALIGN_SIZE
)
static
const
char
*
months
=
"Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec "
;
#ifndef __isleap
#ifndef __isleap
static
int
__isleap
(
int
year
)
static
int
__isleap
(
int
year
)
...
@@ -134,12 +128,12 @@ struct tm *gmtime_r(const time_t *timep, struct tm *r)
...
@@ -134,12 +128,12 @@ struct tm *gmtime_r(const time_t *timep, struct tm *r)
rt_memset
(
r
,
RT_NULL
,
sizeof
(
struct
tm
));
rt_memset
(
r
,
RT_NULL
,
sizeof
(
struct
tm
));
work
=
*
timep
%
(
SPD
);
work
=
*
timep
%
(
24
*
60
*
60
);
r
->
tm_sec
=
work
%
60
;
r
->
tm_sec
=
work
%
60
;
work
/=
60
;
work
/=
60
;
r
->
tm_min
=
work
%
60
;
r
->
tm_min
=
work
%
60
;
r
->
tm_hour
=
work
/
60
;
r
->
tm_hour
=
work
/
60
;
work
=
(
int
)(
*
timep
/
(
SPD
));
work
=
(
int
)(
*
timep
/
(
24
*
60
*
60
));
r
->
tm_wday
=
(
4
+
work
)
%
7
;
r
->
tm_wday
=
(
4
+
work
)
%
7
;
for
(
i
=
1970
;;
++
i
)
for
(
i
=
1970
;;
++
i
)
{
{
...
@@ -257,7 +251,7 @@ char* asctime_r(const struct tm *t, char *buf)
...
@@ -257,7 +251,7 @@ char* asctime_r(const struct tm *t, char *buf)
}
}
RTM_EXPORT
(
asctime_r
);
RTM_EXPORT
(
asctime_r
);
char
*
asctime
(
const
struct
tm
*
timeptr
)
char
*
asctime
(
const
struct
tm
*
timeptr
)
{
{
static
char
buf
[
26
];
static
char
buf
[
26
];
return
asctime_r
(
timeptr
,
buf
);
return
asctime_r
(
timeptr
,
buf
);
...
@@ -271,7 +265,7 @@ char *ctime_r(const time_t * tim_p, char * result)
...
@@ -271,7 +265,7 @@ char *ctime_r(const time_t * tim_p, char * result)
}
}
RTM_EXPORT
(
ctime_r
);
RTM_EXPORT
(
ctime_r
);
char
*
ctime
(
const
time_t
*
tim_p
)
char
*
ctime
(
const
time_t
*
tim_p
)
{
{
return
asctime
(
localtime
(
tim_p
));
return
asctime
(
localtime
(
tim_p
));
}
}
...
@@ -303,7 +297,7 @@ rt_weak time_t time(time_t *t)
...
@@ -303,7 +297,7 @@ rt_weak time_t time(time_t *t)
if
(
_control_rtc
(
RT_DEVICE_CTRL_RTC_GET_TIME
,
&
_t
)
!=
RT_EOK
)
if
(
_control_rtc
(
RT_DEVICE_CTRL_RTC_GET_TIME
,
&
_t
)
!=
RT_EOK
)
{
{
rt_set_errno
(
EFAULT
);
rt_set_errno
(
EFAULT
);
return
-
1
;
return
(
time_t
)
-
1
;
}
}
if
(
t
)
if
(
t
)
...
@@ -809,7 +803,7 @@ static void rtthread_timer_wrapper(void *timerobj)
...
@@ -809,7 +803,7 @@ static void rtthread_timer_wrapper(void *timerobj)
{
{
(
timer
->
sigev_notify_function
)(
timer
->
val
);
(
timer
->
sigev_notify_function
)(
timer
->
val
);
}
}
#endif
#endif
/* RT_USING_SMART */
}
}
#define TIMER_ID_MAX 50
#define TIMER_ID_MAX 50
...
@@ -890,8 +884,7 @@ int timer_create(clockid_t clockid, struct sigevent *evp, timer_t *timerid)
...
@@ -890,8 +884,7 @@ int timer_create(clockid_t clockid, struct sigevent *evp, timer_t *timerid)
}
}
timer
->
work
=
work
;
timer
->
work
=
work
;
#endif
/* RT_USING_SMART */
#endif
timer
->
sigev_notify_function
=
evp
->
sigev_notify_function
;
timer
->
sigev_notify_function
=
evp
->
sigev_notify_function
;
timer
->
val
=
evp
->
sigev_value
;
timer
->
val
=
evp
->
sigev_value
;
timer
->
interval
.
tv_sec
=
0
;
timer
->
interval
.
tv_sec
=
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录