Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
红岛
rt-thread
提交
71f48266
R
rt-thread
项目概览
红岛
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
71f48266
编写于
9月 18, 2021
作者:
mysterywolf
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[libc][time] 修复数据类型报警
上级
163c0597
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
31 addition
and
29 deletion
+31
-29
components/libc/compilers/common/sys/time.h
components/libc/compilers/common/sys/time.h
+21
-18
components/libc/compilers/common/time.c
components/libc/compilers/common/time.c
+10
-11
未找到文件。
components/libc/compilers/common/sys/time.h
浏览文件 @
71f48266
...
@@ -12,7 +12,8 @@
...
@@ -12,7 +12,8 @@
#define __SYS_TIME_H__
#define __SYS_TIME_H__
#include <rtconfig.h>
#include <rtconfig.h>
#include <rtdef.h>
#include <sys/types.h>
#include <stdint.h>
#include <time.h>
#include <time.h>
#ifdef __cplusplus
#ifdef __cplusplus
...
@@ -32,22 +33,19 @@ extern "C" {
...
@@ -32,22 +33,19 @@ extern "C" {
#define DST_TUR 9
/* Turkey */
#define DST_TUR 9
/* Turkey */
#define DST_AUSTALT 10
/* Australian style with shift in 1986 */
#define DST_AUSTALT 10
/* Australian style with shift in 1986 */
struct
timezone
{
struct
timezone
int
tz_minuteswest
;
/* minutes west of Greenwich */
{
int
tz_dsttime
;
/* type of dst correction */
int
tz_minuteswest
;
/* minutes west of Greenwich */
int
tz_dsttime
;
/* type of dst correction */
};
};
void
rt_tz_set
(
rt_int8_t
tz
);
rt_int8_t
rt_tz_get
(
void
);
rt_int8_t
rt_tz_is_dst
(
void
);
/*
/*
* Structure returned by gettimeofday(2) system call,
* Structure returned by gettimeofday(2) system call,
* and used in other calls.
* and used in other calls.
*/
*/
#ifndef _TIMEVAL_DEFINED
#ifndef _TIMEVAL_DEFINED
#define _TIMEVAL_DEFINED
#define _TIMEVAL_DEFINED
#if !
(defined(_WIN32)
)
#if !
defined(_WIN32
)
struct
timeval
struct
timeval
{
{
time_t
tv_sec
;
/* seconds */
time_t
tv_sec
;
/* seconds */
...
@@ -56,6 +54,16 @@ struct timeval
...
@@ -56,6 +54,16 @@ struct timeval
#endif
#endif
#endif
/* _TIMEVAL_DEFINED */
#endif
/* _TIMEVAL_DEFINED */
#if !(defined(__GNUC__) && !defined(__ARMCC_VERSION)
/*GCC*/
) && \
!(defined(__ICCARM__) && (__VER__ >= 8010001)) && \
!defined(_WIN32)
struct
timespec
{
time_t
tv_sec
;
/* seconds */
long
tv_nsec
;
/* and nanoseconds */
};
#endif
int
stime
(
const
time_t
*
t
);
int
stime
(
const
time_t
*
t
);
time_t
timegm
(
struct
tm
*
const
t
);
time_t
timegm
(
struct
tm
*
const
t
);
int
gettimeofday
(
struct
timeval
*
tv
,
struct
timezone
*
tz
);
int
gettimeofday
(
struct
timeval
*
tv
,
struct
timezone
*
tz
);
...
@@ -65,15 +73,6 @@ struct tm *gmtime_r(const time_t *timep, struct tm *r);
...
@@ -65,15 +73,6 @@ struct tm *gmtime_r(const time_t *timep, struct tm *r);
#endif
#endif
#ifdef RT_USING_POSIX
#ifdef RT_USING_POSIX
#include <sys/types.h>
#if !(defined(__GNUC__) && !defined(__ARMCC_VERSION)
/*GCC*/
) && !(defined(__ICCARM__) && (__VER__ >= 8010001)) && !defined(_WIN32)
struct
timespec
{
time_t
tv_sec
;
/* seconds */
long
tv_nsec
;
/* and nanoseconds */
};
#endif
/* POSIX clock and timer */
/* POSIX clock and timer */
#define MILLISECOND_PER_SECOND 1000UL
#define MILLISECOND_PER_SECOND 1000UL
#define MICROSECOND_PER_SECOND 1000000UL
#define MICROSECOND_PER_SECOND 1000000UL
...
@@ -106,6 +105,10 @@ int clock_settime (clockid_t clockid, const struct timespec *tp);
...
@@ -106,6 +105,10 @@ int clock_settime (clockid_t clockid, const struct timespec *tp);
int
rt_timespec_to_tick
(
const
struct
timespec
*
time
);
int
rt_timespec_to_tick
(
const
struct
timespec
*
time
);
#endif
/* RT_USING_POSIX */
#endif
/* RT_USING_POSIX */
void
tz_set
(
int8_t
tz
);
int8_t
tz_get
(
void
);
int8_t
tz_is_dst
(
void
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
components/libc/compilers/common/time.c
浏览文件 @
71f48266
...
@@ -199,7 +199,7 @@ struct tm *gmtime_r(const time_t *timep, struct tm *r)
...
@@ -199,7 +199,7 @@ struct tm *gmtime_r(const time_t *timep, struct tm *r)
r
->
tm_mon
=
i
;
r
->
tm_mon
=
i
;
r
->
tm_mday
+=
work
-
__spm
[
i
];
r
->
tm_mday
+=
work
-
__spm
[
i
];
r
->
tm_isdst
=
rt_
tz_is_dst
();
r
->
tm_isdst
=
tz_is_dst
();
return
r
;
return
r
;
}
}
RTM_EXPORT
(
gmtime_r
);
RTM_EXPORT
(
gmtime_r
);
...
@@ -215,7 +215,7 @@ struct tm* localtime_r(const time_t* t, struct tm* r)
...
@@ -215,7 +215,7 @@ struct tm* localtime_r(const time_t* t, struct tm* r)
{
{
time_t
local_tz
;
time_t
local_tz
;
local_tz
=
*
t
+
rt_
tz_get
()
*
3600
;
local_tz
=
*
t
+
tz_get
()
*
3600
;
return
gmtime_r
(
&
local_tz
,
r
);
return
gmtime_r
(
&
local_tz
,
r
);
}
}
RTM_EXPORT
(
localtime_r
);
RTM_EXPORT
(
localtime_r
);
...
@@ -232,7 +232,7 @@ time_t mktime(struct tm * const t)
...
@@ -232,7 +232,7 @@ time_t mktime(struct tm * const t)
time_t
timestamp
;
time_t
timestamp
;
timestamp
=
timegm
(
t
);
timestamp
=
timegm
(
t
);
timestamp
=
timestamp
-
3600
*
rt_
tz_get
();
timestamp
=
timestamp
-
3600
*
tz_get
();
return
timestamp
;
return
timestamp
;
}
}
RTM_EXPORT
(
mktime
);
RTM_EXPORT
(
mktime
);
...
@@ -423,7 +423,7 @@ int gettimeofday(struct timeval *tv, struct timezone *tz)
...
@@ -423,7 +423,7 @@ int gettimeofday(struct timeval *tv, struct timezone *tz)
if
(
tz
!=
RT_NULL
)
if
(
tz
!=
RT_NULL
)
{
{
tz
->
tz_dsttime
=
DST_NONE
;
tz
->
tz_dsttime
=
DST_NONE
;
tz
->
tz_minuteswest
=
-
(
rt_
tz_get
()
*
60
);
tz
->
tz_minuteswest
=
-
(
tz_get
()
*
60
);
}
}
if
(
tv
!=
RT_NULL
&&
get_timeval
(
tv
)
==
RT_EOK
)
if
(
tv
!=
RT_NULL
&&
get_timeval
(
tv
)
==
RT_EOK
)
...
@@ -446,7 +446,6 @@ int settimeofday(const struct timeval *tv, const struct timezone *tz)
...
@@ -446,7 +446,6 @@ int settimeofday(const struct timeval *tv, const struct timezone *tz)
* Thus, the following is purely of historic interest.
* Thus, the following is purely of historic interest.
*/
*/
if
(
tv
!=
RT_NULL
if
(
tv
!=
RT_NULL
&&
tv
->
tv_sec
>=
0
&&
tv
->
tv_usec
>=
0
&&
tv
->
tv_usec
>=
0
&&
set_timeval
((
struct
timeval
*
)
tv
)
==
RT_EOK
)
&&
set_timeval
((
struct
timeval
*
)
tv
)
==
RT_EOK
)
{
{
...
@@ -676,22 +675,22 @@ RTM_EXPORT(rt_timespec_to_tick);
...
@@ -676,22 +675,22 @@ RTM_EXPORT(rt_timespec_to_tick);
#define RT_LIBC_DEFAULT_TIMEZONE 8
#define RT_LIBC_DEFAULT_TIMEZONE 8
#endif
#endif
static
volatile
rt_int8_t
rt
_current_timezone
=
RT_LIBC_DEFAULT_TIMEZONE
;
static
volatile
int8_t
_current_timezone
=
RT_LIBC_DEFAULT_TIMEZONE
;
void
rt_tz_set
(
rt_
int8_t
tz
)
void
tz_set
(
int8_t
tz
)
{
{
register
rt_base_t
level
;
register
rt_base_t
level
;
level
=
rt_hw_interrupt_disable
();
level
=
rt_hw_interrupt_disable
();
rt
_current_timezone
=
tz
;
_current_timezone
=
tz
;
rt_hw_interrupt_enable
(
level
);
rt_hw_interrupt_enable
(
level
);
}
}
rt_int8_t
rt_
tz_get
(
void
)
int8_t
tz_get
(
void
)
{
{
return
rt
_current_timezone
;
return
_current_timezone
;
}
}
rt_int8_t
rt_
tz_is_dst
(
void
)
int8_t
tz_is_dst
(
void
)
{
{
return
0
;
return
0
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录