projects
/
haskell-directory.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(from parent 1:
c5a5a31
)
fix to getUSecOfDay(): arithmetic was overflowing
author
Simon Marlow
<simonmar@microsoft.com>
Wed, 14 Feb 2007 16:17:19 +0000
(16:17 +0000)
committer
Simon Marlow
<simonmar@microsoft.com>
Wed, 14 Feb 2007 16:17:19 +0000
(16:17 +0000)
include/HsBase.h
patch
|
blob
|
history
diff --git
a/include/HsBase.h
b/include/HsBase.h
index
09693cb
..
45e2d39
100644
(file)
--- a/
include/HsBase.h
+++ b/
include/HsBase.h
@@
-724,7
+724,10
@@
INLINE HsWord64 getUSecOfDay(void)
{
struct timeval tv;
gettimeofday(&tv, (struct timezone *) NULL);
- return (tv.tv_sec * 1000000 + tv.tv_usec);
+ // Don't forget to cast *before* doing the arithmetic, otherwise
+ // the arithmetic happens at the type of tv_sec, which is probably
+ // only 'int'.
+ return ((HsWord64)tv.tv_sec * 1000000 + (HsWord64)tv.tv_usec);
}
INLINE void setTimevalTicks(struct timeval *p, HsWord64 usecs)