Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
GHC
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
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
Tobias Decking
GHC
Commits
598ee1ad
Commit
598ee1ad
authored
Jul 31, 2012
by
Simon Marlow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #7087 (integer overflow in getDelayTarget())
parent
9e7acbe7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
3 deletions
+14
-3
includes/Rts.h
includes/Rts.h
+2
-0
rts/posix/Select.c
rts/posix/Select.c
+12
-3
No files found.
includes/Rts.h
View file @
598ee1ad
...
...
@@ -156,6 +156,8 @@ void _assertFail(const char *filename, unsigned int linenum)
#define TIME_RESOLUTION 1000000000
typedef
StgInt64
Time
;
#define TIME_MAX HS_INT64_MAX
#if TIME_RESOLUTION == 1000000000
// I'm being lazy, but it's awkward to define fully general versions of these
#define TimeToUS(t) ((t) / 1000)
...
...
rts/posix/Select.c
View file @
598ee1ad
...
...
@@ -67,9 +67,18 @@ static LowResTime getLowResTimeOfDay(void)
*/
LowResTime
getDelayTarget
(
HsInt
us
)
{
// round up the target time, because we never want to sleep *less*
// than the desired amount.
return
TimeToLowResTimeRoundUp
(
getProcessElapsedTime
()
+
USToTime
(
us
));
Time
elapsed
;
elapsed
=
getProcessElapsedTime
();
// If the desired target would be larger than the maximum Time,
// default to the maximum Time. (#7087)
if
(
us
>
TimeToUS
(
TIME_MAX
-
elapsed
))
{
return
TimeToLowResTimeRoundDown
(
TIME_MAX
);
}
else
{
// round up the target time, because we never want to sleep *less*
// than the desired amount.
return
TimeToLowResTimeRoundUp
(
elapsed
+
USToTime
(
us
));
}
}
/* There's a clever trick here to avoid problems when the time wraps
...
...
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