Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
clean-platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
15
Issues
15
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
clean-and-itasks
clean-platform
Commits
3f52e4ad
Commit
3f52e4ad
authored
Jan 11, 2018
by
Mart Lubbers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add arithmetic operations to timespec
parent
77b02c8b
Pipeline
#8855
passed with stage
in 1 minute and 26 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
69 additions
and
0 deletions
+69
-0
src/libraries/OS-Posix/System/Time.dcl
src/libraries/OS-Posix/System/Time.dcl
+7
-0
src/libraries/OS-Posix/System/Time.icl
src/libraries/OS-Posix/System/Time.icl
+27
-0
src/libraries/OS-Windows/System/Time.dcl
src/libraries/OS-Windows/System/Time.dcl
+8
-0
src/libraries/OS-Windows/System/Time.icl
src/libraries/OS-Windows/System/Time.icl
+27
-0
No files found.
src/libraries/OS-Posix/System/Time.dcl
View file @
3f52e4ad
...
...
@@ -90,3 +90,10 @@ toGmTime :: !Timestamp -> Tm
*/
nsTime
::
!*
World
->
(!
Timespec
,
!*
World
)
::
Timespec
=
{
tv_sec
::
!
Int
,
tv_nsec
::
!
Int
}
timespecToStamp
::
!
Timespec
->
Timestamp
timestampToSpec
::
!
Timestamp
->
Timespec
instance
<
Timespec
instance
+
Timespec
instance
-
Timespec
src/libraries/OS-Posix/System/Time.icl
View file @
3f52e4ad
...
...
@@ -176,3 +176,30 @@ nsTime w
#
(
tv_sec
,
p
)
=
readIntP
p
0
#
(
tv_nsec
,
p
)
=
readIntP
p
8
=
({
Timespec
|
tv_sec
=
tv_sec
,
tv_nsec
=
tv_nsec
},
freeSt
p
w
)
timespecToStamp
::
!
Timespec
->
Timestamp
timespecToStamp
t
=
Timestamp
t
.
tv_sec
timestampToSpec
::
!
Timestamp
->
Timespec
timestampToSpec
(
Timestamp
t
)
=
{
tv_sec
=
t
,
tv_nsec
=
0
}
instance
<
Timespec
where
(<)
t1
t2
|
t1
.
tv_sec
==
t2
.
tv_sec
=
t1
.
tv_nsec
<
t2
.
tv_nsec
=
t1
.
tv_sec
<
t2
.
tv_sec
instance
+
Timespec
where
(+)
t1
t2
=
let
tv_nsec
=
t1
.
tv_nsec
+
t2
.
tv_nsec
in
{
tv_sec
=
t1
.
tv_sec
+
t2
.
tv_sec
+
tv_nsec
/
1000000000
,
tv_nsec
=
tv_nsec
rem
1000000000
}
instance
-
Timespec
where
(-)
t1
t2
#
tv_nsec
=
t1
.
tv_nsec
-
t2
.
tv_nsec
|
tv_nsec
<
0
=
{
tv_sec
=
t1
.
tv_sec
-
t2
.
tv_sec
-
1
,
tv_nsec
=
1000000000
-
tv_nsec
}
=
{
tv_sec
=
t1
.
tv_sec
-
t2
.
tv_sec
-
1
,
tv_nsec
=
tv_nsec
}
src/libraries/OS-Windows/System/Time.dcl
View file @
3f52e4ad
...
...
@@ -94,3 +94,11 @@ gmTimeC :: !{#Int} -> Int
*/
nsTime
::
!*
World
->
(!
Timespec
,
!*
World
)
::
Timespec
=
{
tv_sec
::
!
Int
,
tv_nsec
::
!
Int
}
timespecToStamp
::
!
Timespec
->
Timestamp
timestampToSpec
::
!
Timestamp
->
Timespec
instance
<
Timespec
instance
+
Timespec
instance
-
Timespec
src/libraries/OS-Windows/System/Time.icl
View file @
3f52e4ad
...
...
@@ -180,3 +180,30 @@ uintToInt :: Int -> Integer
uintToInt
i
|
i
<
0
=
toInteger
i
+
{
integer_s
=
0
,
integer_a
={
0
,
1
}}
=
toInteger
i
timespecToStamp
::
!
Timespec
->
Timestamp
timespecToStamp
t
=
Timestamp
t
.
tv_sec
timestampToSpec
::
!
Timestamp
->
Timespec
timestampToSpec
(
Timestamp
t
)
=
{
tv_sec
=
t
,
tv_nsec
=
0
}
instance
<
Timespec
where
(<)
t1
t2
|
t1
.
tv_sec
==
t2
.
tv_sec
=
t1
.
tv_nsec
<
t2
.
tv_nsec
=
t1
.
tv_sec
<
t2
.
tv_sec
instance
+
Timespec
where
(+)
t1
t2
=
let
tv_nsec
=
t1
.
tv_nsec
+
t2
.
tv_nsec
in
{
tv_sec
=
t1
.
tv_sec
+
t2
.
tv_sec
+
tv_nsec
/
1000000000
,
tv_nsec
=
tv_nsec
rem
1000000000
}
instance
-
Timespec
where
(-)
t1
t2
#
tv_nsec
=
t1
.
tv_nsec
-
t2
.
tv_nsec
|
tv_nsec
<
0
=
{
tv_sec
=
t1
.
tv_sec
-
t2
.
tv_sec
-
1
,
tv_nsec
=
1000000000
-
tv_nsec
}
=
{
tv_sec
=
t1
.
tv_sec
-
t2
.
tv_sec
-
1
,
tv_nsec
=
tv_nsec
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment