-
Notifications
You must be signed in to change notification settings - Fork 5.4k
improve libc time and MSVC simulator #5775
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a11d85b
23a1a1c
84cdbab
b219b1b
a9b085d
e985ead
ff8cda9
a8a3b62
f929c1b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| Because of the history issue, flags in fcntl.h, such as O_CREAT, have difference types of value. Some OS use hex flags and others use octal flags. | ||
|
|
||
| In terms of RT-Thread, Keil, IAR and MSVC use octal flags, which is located in the `tcntl/octal` folder; newlib uses hex flags; musl uses octal flags. | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # RT-Thread building script for bridge | ||
|
|
||
| import os | ||
| from building import * | ||
|
|
||
| cwd = GetCurrentDir() | ||
| objs = [] | ||
| list = os.listdir(cwd) | ||
|
|
||
| for d in list: | ||
| path = os.path.join(cwd, d) | ||
| if os.path.isfile(os.path.join(path, 'SConscript')): | ||
| objs = objs + SConscript(os.path.join(d, 'SConscript')) | ||
|
|
||
| Return('objs') |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| from building import * | ||
| Import('rtconfig') | ||
|
|
||
| src = [] | ||
| cwd = GetCurrentDir() | ||
| CPPPATH = [cwd] | ||
| group = [] | ||
|
|
||
| if rtconfig.PLATFORM == 'armcc' or\ | ||
| rtconfig.PLATFORM == 'armclang' or\ | ||
| rtconfig.PLATFORM == 'iar' or\ | ||
| rtconfig.CROSS_TOOL == 'msvc': | ||
| group = DefineGroup('Compiler', src, depend = [''], CPPPATH = CPPPATH) | ||
| Return('group') |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,7 +18,9 @@ | |
| #include <time.h> | ||
| #ifdef _WIN32 | ||
| #include <winsock.h> /* for struct timeval */ | ||
| #endif | ||
| #include <corecrt.h> /* for __time64_t */ | ||
| typedef __time64_t time_t; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个地方要留意 get_timeval 和 set_timeval 里面有这样一段代码 static int set_timeval(struct timeval *tv)
{
rst = rt_device_control(device, RT_DEVICE_CTRL_RTC_SET_TIME, &tv->tv_sec);
rt_device_control(device, RT_DEVICE_CTRL_RTC_SET_TIMEVAL, tv);
}vs 上 // 这种形式会写穿 tv_usec,不致命
struct timeval {
long tv_sec; /* seconds */
long tv_usec; /* and microseconds */
};
// 这种形式会写穿后面的内存,致命
struct timeval {
long tv_usec; /* and microseconds */
long tv_sec; /* seconds */
};
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这种倒过来的形式在newlib vs都没有 都是正着的
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 看来2038的问题不只是time_t 32改64这么简单,相关的时间结构体 long都得改成longlong |
||
| #endif /* _WIN32 */ | ||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
|
|
@@ -50,17 +52,17 @@ struct timeval | |
| time_t tv_sec; /* seconds */ | ||
| suseconds_t tv_usec; /* and microseconds */ | ||
| }; | ||
| #endif | ||
| #endif /* !defined(_TIMEVAL_DEFINED) && !defined(_WIN32) */ | ||
|
|
||
| #if !(defined(__GNUC__) && !defined(__ARMCC_VERSION)/*GCC*/) && \ | ||
| !(defined(__ICCARM__) && (__VER__ >= 8010001)) && \ | ||
|
mysterywolf marked this conversation as resolved.
|
||
| !defined(_WIN32) | ||
| #if defined(__ARMCC_VERSION) || defined(_WIN32) || (defined(__ICCARM__) && (__VER__ >= 8010001)) | ||
| struct timespec | ||
| { | ||
| time_t tv_sec; /* seconds */ | ||
| long tv_nsec; /* and nanoseconds */ | ||
| }; | ||
| #endif /* defined(__ARMCC_VERSION) || defined(_WIN32) || (defined(__ICCARM__) && (__VER__ >= 8010001)) */ | ||
|
|
||
| #if !(defined(__GNUC__) && !defined(__ARMCC_VERSION)/*GCC*/) | ||
| /* | ||
| * Structure defined by POSIX.1b to be like a itimerval, but with | ||
| * timespecs. Used in the timer_*() system calls. | ||
|
|
@@ -70,7 +72,7 @@ struct itimerspec | |
| struct timespec it_interval; | ||
| struct timespec it_value; | ||
| }; | ||
| #endif | ||
| #endif /* !(defined(__GNUC__) && !defined(__ARMCC_VERSION)) */ | ||
|
|
||
| int stime(const time_t *t); | ||
| time_t timegm(struct tm * const t); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.