Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
relibc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
redox-os
relibc
Commits
8015878a
Commit
8015878a
authored
6 years ago
by
Marat Safin
Browse files
Options
Downloads
Patches
Plain Diff
use static variable for gmtime
parent
2b21dca5
No related branches found
No related tags found
1 merge request
!112
add gmtime and difftime
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/time/src/lib.rs
+18
-19
18 additions, 19 deletions
src/time/src/lib.rs
tests/gmtime.c
+8
-0
8 additions, 0 deletions
tests/gmtime.c
with
26 additions
and
19 deletions
src/time/src/lib.rs
+
18
−
19
View file @
8015878a
//! time implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/time.h.html
#![no_std]
#![feature(const_fn)]
extern
crate
platform
;
...
...
@@ -34,23 +35,22 @@ pub struct tm {
pub
tm_zone
:
*
const
c_char
,
}
impl
Default
for
tm
{
fn
default
()
->
tm
{
tm
{
tm_sec
:
0
,
tm_min
:
0
,
tm_hour
:
0
,
tm_mday
:
0
,
tm_mon
:
0
,
tm_year
:
0
,
tm_wday
:
0
,
tm_yday
:
0
,
tm_isdst
:
0
,
tm_gmtoff
:
0
,
tm_zone
:
UTC
,
}
}
}
unsafe
impl
Sync
for
tm
{}
// The C Standard says that localtime and gmtime return the same pointer.
static
mut
TM
:
tm
=
tm
{
tm_sec
:
0
,
tm_min
:
0
,
tm_hour
:
0
,
tm_mday
:
0
,
tm_mon
:
0
,
tm_year
:
0
,
tm_wday
:
0
,
tm_yday
:
0
,
tm_isdst
:
0
,
tm_gmtoff
:
0
,
tm_zone
:
UTC
,
};
#[repr(C)]
pub
struct
itimerspec
{
...
...
@@ -112,8 +112,7 @@ pub extern "C" fn getdate(string: *const c_char) -> tm {
#[no_mangle]
pub
extern
"C"
fn
gmtime
(
timer
:
*
const
time_t
)
->
*
mut
tm
{
let
mut
result
:
tm
=
Default
::
default
();
return
gmtime_r
(
timer
,
&
mut
result
);
unsafe
{
gmtime_r
(
timer
,
&
mut
TM
)
}
}
#[no_mangle]
...
...
This diff is collapsed.
Click to expand it.
tests/gmtime.c
+
8
−
0
View file @
8015878a
...
...
@@ -9,6 +9,14 @@ int main(int argc, char** argv) {
.
tm_wday
=
4
,
.
tm_yday
=
0
,
.
tm_isdst
=
0
,
.
tm_gmtoff
=
0
,
.
tm_zone
=
"UTC"
};
tm
*
info
=
gmtime
(
&
a
);
if
(
info
->
tm_sec
!=
expected
.
tm_sec
||
info
->
tm_min
!=
expected
.
tm_min
||
info
->
tm_hour
!=
expected
.
tm_hour
||
info
->
tm_mday
!=
expected
.
tm_mday
||
info
->
tm_year
!=
expected
.
tm_year
||
info
->
tm_wday
!=
expected
.
tm_wday
||
info
->
tm_yday
!=
expected
.
tm_yday
||
info
->
tm_isdst
!=
expected
.
tm_isdst
||
info
->
tm_gmtoff
!=
expected
.
tm_gmtoff
||
strcmp
(
info
->
tm_zone
,
expected
.
tm_zone
)
!=
0
)
{
exit
(
1
);
}
if
(
info
->
tm_sec
!=
expected
.
tm_sec
||
info
->
tm_min
!=
expected
.
tm_min
||
info
->
tm_hour
!=
expected
.
tm_hour
||
info
->
tm_mday
!=
expected
.
tm_mday
||
info
->
tm_year
!=
expected
.
tm_year
||
info
->
tm_wday
!=
expected
.
tm_wday
||
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment