Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2301_76519099
rt-thread
提交
4ce39dd7
R
rt-thread
项目概览
2301_76519099
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
3
Star
1
Fork
1
代码
文件
提交
分支
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,发现更多精彩内容 >>
提交
4ce39dd7
编写于
12月 29, 2022
作者:
mysterywolf
提交者:
mysterywolf
12月 29, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[libc][time] 修正POSIX 时间相关函数返回值错误
上级
76b5d0df
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
37 addition
and
37 deletion
+37
-37
components/libc/compilers/common/ctime.c
components/libc/compilers/common/ctime.c
+37
-37
未找到文件。
components/libc/compilers/common/ctime.c
浏览文件 @
4ce39dd7
...
...
@@ -379,7 +379,7 @@ int stime(const time_t *t)
if
(
t
==
RT_NULL
)
{
rt_set_errno
(
EFAULT
);
return
-
RT_ERROR
;
return
-
1
;
}
tv
.
tv_sec
=
*
t
;
...
...
@@ -390,7 +390,7 @@ int stime(const time_t *t)
else
{
rt_set_errno
(
EFAULT
);
return
-
RT_ERROR
;
return
-
1
;
}
}
RTM_EXPORT
(
stime
);
...
...
@@ -404,7 +404,7 @@ time_t timegm(struct tm * const t)
if
(
t
==
RT_NULL
)
{
rt_set_errno
(
EFAULT
);
return
(
time_t
)
-
RT_ERROR
;
return
(
time_t
)
-
1
;
}
years
=
(
time_t
)
t
->
tm_year
-
70
;
...
...
@@ -446,7 +446,7 @@ time_t timegm(struct tm * const t)
if
(
t
->
tm_year
<
70
)
{
rt_set_errno
(
EINVAL
);
return
(
time_t
)
-
RT_ERROR
;
return
(
time_t
)
-
1
;
}
/* Days since 1970 is 365 * number of years + number of leap years since 1970 */
...
...
@@ -500,7 +500,7 @@ int gettimeofday(struct timeval *tv, struct timezone *tz)
else
{
rt_set_errno
(
EINVAL
);
return
-
RT_ERROR
;
return
-
1
;
}
}
RTM_EXPORT
(
gettimeofday
);
...
...
@@ -521,7 +521,7 @@ int settimeofday(const struct timeval *tv, const struct timezone *tz)
else
{
rt_set_errno
(
EINVAL
);
return
-
RT_ERROR
;
return
-
1
;
}
}
RTM_EXPORT
(
settimeofday
);
...
...
@@ -532,7 +532,7 @@ int nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
if
(
rqtp
->
tv_sec
<
0
||
rqtp
->
tv_nsec
<
0
||
rqtp
->
tv_nsec
>=
NANOSECOND_PER_SECOND
)
{
rt_set_errno
(
EINVAL
);
return
-
RT_ERROR
;
return
-
1
;
}
#ifdef RT_USING_CPUTIME
uint64_t
cpu_tick
,
cpu_tick_old
;
...
...
@@ -553,7 +553,7 @@ int nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
rmtp
->
tv_nsec
=
((
int
)(
rmtp_cpu_tick
*
unit
))
%
NANOSECOND_PER_SECOND
;
}
rt_set_errno
(
EINTR
);
return
-
RT_ERROR
;
return
-
1
;
}
else
while
(
clock_cpu_gettime
()
-
cpu_tick_old
<
cpu_tick
);
...
...
@@ -572,7 +572,7 @@ int nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
rmtp
->
tv_nsec
=
(
tick
%
RT_TICK_PER_SECOND
)
*
(
NANOSECOND_PER_SECOND
/
RT_TICK_PER_SECOND
);
}
rt_set_errno
(
EINTR
);
return
-
RT_ERROR
;
return
-
1
;
}
#endif
return
0
;
...
...
@@ -610,7 +610,7 @@ static int _rt_clock_time_system_init(void)
_timevalue
.
tv_sec
=
0
;
rt_hw_interrupt_enable
(
level
);
return
-
RT_ERROR
;
return
-
1
;
}
INIT_COMPONENT_EXPORT
(
_rt_clock_time_system_init
);
#endif
/* RT_USING_RTC */
...
...
@@ -619,14 +619,14 @@ int clock_getres(clockid_t clockid, struct timespec *res)
{
#ifndef RT_USING_RTC
LOG_W
(
_WARNING_NO_RTC
);
return
-
RT_ERROR
;
return
-
1
;
#else
int
ret
=
0
;
if
(
res
==
RT_NULL
)
{
rt_set_errno
(
EFAULT
);
return
-
RT_ERROR
;
return
-
1
;
}
switch
(
clockid
)
...
...
@@ -646,7 +646,7 @@ int clock_getres(clockid_t clockid, struct timespec *res)
default:
res
->
tv_sec
=
0
;
res
->
tv_nsec
=
0
;
ret
=
-
RT_ERROR
;
ret
=
-
1
;
rt_set_errno
(
EINVAL
);
break
;
}
...
...
@@ -660,14 +660,14 @@ int clock_gettime(clockid_t clockid, struct timespec *tp)
{
#ifndef RT_USING_RTC
LOG_W
(
_WARNING_NO_RTC
);
return
-
RT_ERROR
;
return
-
1
;
#else
int
ret
=
0
;
if
(
tp
==
RT_NULL
)
{
rt_set_errno
(
EFAULT
);
return
-
RT_ERROR
;
return
-
1
;
}
switch
(
clockid
)
...
...
@@ -703,7 +703,7 @@ int clock_gettime(clockid_t clockid, struct timespec *tp)
tp
->
tv_sec
=
0
;
tp
->
tv_nsec
=
0
;
rt_set_errno
(
EINVAL
);
ret
=
-
RT_ERROR
;
ret
=
-
1
;
}
return
ret
;
...
...
@@ -715,12 +715,12 @@ int clock_nanosleep(clockid_t clockid, int flags, const struct timespec *rqtp, s
{
#ifndef RT_USING_RTC
LOG_W
(
_WARNING_NO_RTC
);
return
-
RT_ERROR
;
return
-
1
;
#else
if
(
rqtp
->
tv_sec
<
0
||
rqtp
->
tv_nsec
<
0
||
rqtp
->
tv_nsec
>=
NANOSECOND_PER_SECOND
)
{
rt_set_errno
(
EINVAL
);
return
-
RT_ERROR
;
return
-
1
;
}
switch
(
clockid
)
{
...
...
@@ -748,7 +748,7 @@ int clock_nanosleep(clockid_t clockid, int flags, const struct timespec *rqtp, s
rmtp
->
tv_nsec
=
(
tick
%
RT_TICK_PER_SECOND
)
*
(
NANOSECOND_PER_SECOND
/
RT_TICK_PER_SECOND
);
}
rt_set_errno
(
EINTR
);
return
-
RT_ERROR
;
return
-
1
;
}
}
break
;
...
...
@@ -777,7 +777,7 @@ int clock_nanosleep(clockid_t clockid, int flags, const struct timespec *rqtp, s
rmtp
->
tv_nsec
=
((
int
)(
rmtp_cpu_tick
*
unit
))
%
NANOSECOND_PER_SECOND
;
}
rt_set_errno
(
EINTR
);
return
-
RT_ERROR
;
return
-
1
;
}
else
while
(
clock_cpu_gettime
()
-
cpu_tick_old
<
cpu_tick
);
...
...
@@ -786,7 +786,7 @@ int clock_nanosleep(clockid_t clockid, int flags, const struct timespec *rqtp, s
#endif
default:
rt_set_errno
(
EINVAL
);
return
-
RT_ERROR
;
return
-
1
;
}
return
0
;
#endif
...
...
@@ -797,7 +797,7 @@ int clock_settime(clockid_t clockid, const struct timespec *tp)
{
#ifndef RT_USING_RTC
LOG_W
(
_WARNING_NO_RTC
);
return
-
RT_ERROR
;
return
-
1
;
#else
rt_base_t
level
;
int
second
;
...
...
@@ -807,7 +807,7 @@ int clock_settime(clockid_t clockid, const struct timespec *tp)
if
((
clockid
!=
CLOCK_REALTIME
)
||
(
tp
==
RT_NULL
))
{
rt_set_errno
(
EFAULT
);
return
-
RT_ERROR
;
return
-
1
;
}
/* get second */
...
...
@@ -831,7 +831,7 @@ int clock_settime(clockid_t clockid, const struct timespec *tp)
}
}
return
-
RT_ERROR
;
return
-
1
;
#endif
/* RT_USING_RTC */
}
RTM_EXPORT
(
clock_settime
);
...
...
@@ -935,14 +935,14 @@ int timer_create(clockid_t clockid, struct sigevent *evp, timer_t *timerid)
evp
->
sigev_notify
!=
SIGEV_SIGNAL
))
{
rt_set_errno
(
EINVAL
);
return
-
RT_ERROR
;
return
-
1
;
}
timer
=
rt_malloc
(
sizeof
(
struct
timer_obj
));
if
(
timer
==
RT_NULL
)
{
rt_set_errno
(
ENOMEM
);
return
-
RT_ENOMEM
;
return
-
1
;
}
rt_snprintf
(
timername
,
RT_NAME_MAX
,
"psx_tm%02d"
,
num
++
);
...
...
@@ -969,7 +969,7 @@ int timer_create(clockid_t clockid, struct sigevent *evp, timer_t *timerid)
*
timerid
=
(
timer_t
)((
uintptr_t
)
timer
>>
1
);
return
RT_EOK
;
return
0
;
}
RTM_EXPORT
(
timer_create
);
...
...
@@ -985,7 +985,7 @@ int timer_delete(timer_t timerid)
if
(
timer
==
RT_NULL
||
rt_object_get_type
(
&
timer
->
timer
.
parent
)
!=
RT_Object_Class_Timer
)
{
rt_set_errno
(
EINVAL
);
return
-
RT_ERROR
;
return
-
1
;
}
if
(
timer
->
status
==
ACTIVE
)
...
...
@@ -996,7 +996,7 @@ int timer_delete(timer_t timerid)
rt_timer_detach
(
&
timer
->
timer
);
rt_free
(
timer
);
return
RT_EOK
;
return
0
;
}
RTM_EXPORT
(
timer_delete
);
...
...
@@ -1008,7 +1008,7 @@ RTM_EXPORT(timer_delete);
int
timer_getoverrun
(
timer_t
timerid
)
{
rt_set_errno
(
ENOSYS
);
return
-
RT_ERROR
;
return
-
1
;
}
/**
...
...
@@ -1025,13 +1025,13 @@ int timer_gettime(timer_t timerid, struct itimerspec *its)
if
(
timer
==
NULL
||
rt_object_get_type
(
&
timer
->
timer
.
parent
)
!=
RT_Object_Class_Timer
)
{
rt_set_errno
(
EINVAL
);
return
-
RT_ERROR
;
return
-
1
;
}
if
(
its
==
NULL
)
{
rt_set_errno
(
EFAULT
);
return
-
RT_ERROR
;
return
-
1
;
}
if
(
timer
->
status
==
ACTIVE
)
...
...
@@ -1073,7 +1073,7 @@ int timer_gettime(timer_t timerid, struct itimerspec *its)
/* The interval last set by timer_settime() */
its
->
it_interval
=
timer
->
interval
;
return
RT_EOK
;
return
0
;
}
RTM_EXPORT
(
timer_gettime
);
...
...
@@ -1096,7 +1096,7 @@ int timer_settime(timer_t timerid, int flags, const struct itimerspec *value,
value
->
it_value
.
tv_sec
<
0
)
{
rt_set_errno
(
EINVAL
);
return
-
RT_ERROR
;
return
-
1
;
}
/* Save time to expire and old reload value. */
...
...
@@ -1114,7 +1114,7 @@ int timer_settime(timer_t timerid, int flags, const struct itimerspec *value,
}
timer
->
status
=
NOT_ACTIVE
;
return
RT_EOK
;
return
0
;
}
/* calculate timer period(tick); To avoid lost of accuracy, because "RT_TICK_PER_SECOND" maybe 100, 1000, 1024 and so on.
...
...
@@ -1128,7 +1128,7 @@ int timer_settime(timer_t timerid, int flags, const struct itimerspec *value,
{
#ifndef RT_USING_RTC
LOG_W
(
_WARNING_NO_RTC
);
return
-
RT_ERROR
;
return
-
1
;
#else
rt_int64_t
ts
=
((
value
->
it_value
.
tv_sec
-
_timevalue
.
tv_sec
)
*
RT_TICK_PER_SECOND
);
rt_int64_t
tns
=
(
value
->
it_value
.
tv_nsec
-
_timevalue
.
tv_usec
)
*
(
RT_TICK_PER_SECOND
/
NANOSECOND_PER_SECOND
);
...
...
@@ -1159,7 +1159,7 @@ int timer_settime(timer_t timerid, int flags, const struct itimerspec *value,
rt_timer_control
(
&
timer
->
timer
,
RT_TIMER_CTRL_SET_TIME
,
&
(
timer
->
reload
));
rt_timer_start
(
&
timer
->
timer
);
return
RT_EOK
;
return
0
;
}
RTM_EXPORT
(
timer_settime
);
#endif
/* RT_USING_POSIX_TIMER */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录