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
d0593825
Commit
d0593825
authored
Oct 17, 2019
by
Mart Lubbers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix nsTime on 64 bit windows machines
parent
8d549114
Pipeline
#31486
passed with stage
in 3 minutes and 3 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
12 deletions
+25
-12
src/libraries/OS-Windows/System/Time.icl
src/libraries/OS-Windows/System/Time.icl
+25
-12
No files found.
src/libraries/OS-Windows/System/Time.icl
View file @
d0593825
implementation
module
System
.
Time
implementation
module
System
.
Time
import
Std
String
,
StdArray
,
StdClass
,
StdOverloaded
,
StdInt
,
StdMisc
,
StdBool
import
Std
Env
import
System
.
_Pointer
import
System
.
_Pointer
import
System
.
_WinBase
import
System
.
_WinBase
import
Data
.
Integer
import
Data
.
Integer
...
@@ -166,18 +166,31 @@ packTm32 tm = { tm.sec
...
@@ -166,18 +166,31 @@ packTm32 tm = { tm.sec
,
tm
.
yday
,
tm
.
yday
,
tm
.
isdst
,
tm
.
isdst
}
}
//Number of ticks difference between the windows and linux epoch
TICKSDIFF
:==
{
integer_s
=
0
,
integer_a
={
-1240428288
,
2
}}
*
TICKSPERSEC
//Number of 100ns ticks difference between the windows and linux epoch
//Number of ticks per second on windows machines
TICKSDIFF32
=:
toInteger
"11644473600"
*
TICKSPERSEC32
TICKSPERSEC
:==
{
integer_s
=
10000000
,
integer_a
={}}
TICKSDIFF64
=:
11644473600
*
TICKSPERSEC64
BIGTWO
:==
{
integer_s
=
2
,
integer_a
={}}
//Number of ticks per second (100 ns ticks)
TICKSPERSEC32
=:
toInteger
10000000
TICKSPERSEC64
=:
10000000
/*
* On windows GetSystemTimeAsFileTime returns a struct containing 2 32bit unsigned integers.
* On 64 bit we therefore use an array of length 1, on 32 bit of length two.
* On 64 bit we can use native integers, on windows we use bigints.
*/
nsTime
::
!*
World
->
(!
Timespec
,
!*
World
)
nsTime
::
!*
World
->
(!
Timespec
,
!*
World
)
nsTime
w
nsTime
w
=
IF_INT_64_OR_32
nsTime64
nsTime32
w
#
(
is
,
w
)
=
GetSystemTimeAsFileTime
(
createArray
2
0
)
w
where
#
ticks
=
uintToInt
is
.[
0
]
+
foldr
($)
(
uintToInt
is
.[
1
])
(
repeatn
32
((*)
BIGTWO
))
-
TICKSDIFF
nsTime64
w
=
({
Timespec
|
tv_sec
=
toInt
(
ticks
/
TICKSPERSEC
),
tv_nsec
=
toInt
(
ticks
rem
TICKSPERSEC
)
*
100
},
w
)
#
(
is
,
w
)
=
GetSystemTimeAsFileTime
{
0
}
w
=
({
tv_sec
=(
is
.[
0
]
-
TICKSDIFF64
)
/
TICKSPERSEC64
,
tv_nsec
=(
is
.[
0
]
rem
TICKSPERSEC64
)
*
100
},
w
)
nsTime32
w
#
(
is
,
w
)
=
GetSystemTimeAsFileTime
{
0
,
0
}
w
#
ticks
=
uintToInt
is
.[
0
]
+
foldr
($)
(
uintToInt
is
.[
1
])
(
repeatn
32
((*)
(
toInteger
2
)))
-
TICKSDIFF32
=
({
tv_sec
=
toInt
(
ticks
/
TICKSPERSEC32
),
tv_nsec
=
toInt
(
ticks
rem
TICKSPERSEC32
)
*
100
},
w
)
uintToInt
::
Int
->
Integer
uintToInt
::
Int
->
Integer
uintToInt
i
uintToInt
i
...
...
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