Merge lp:~paul-lucas/zorba/bug-855481 into lp:zorba

Proposed by Paul J. Lucas
Status: Merged
Approved by: Paul J. Lucas
Approved revision: 11215
Merged at revision: 11215
Proposed branch: lp:~paul-lucas/zorba/bug-855481
Merge into: lp:zorba
Diff against target: 130 lines (+25/-17)
4 files modified
ChangeLog (+1/-0)
include/zorba/util/time.h (+22/-15)
include/zorba/util/timer.h (+1/-1)
src/runtime/random/random_impl.cpp (+1/-1)
To merge this branch: bzr merge lp:~paul-lucas/zorba/bug-855481
Reviewer Review Type Date Requested Status
Rodolfo Ochoa Approve
Paul J. Lucas Approve
Review via email: mp+145740@code.launchpad.net

Commit message

Fixed millisecond time for Windows.

Description of the change

Fixed millisecond time for Windows.

To post a comment you must log in.
Revision history for this message
Paul J. Lucas (paul-lucas) :
review: Approve
Revision history for this message
Paul J. Lucas (paul-lucas) wrote :

Add bug fix to ChangeLog.

review: Needs Fixing
lp:~paul-lucas/zorba/bug-855481 updated
11215. By Paul J. Lucas

Added fix line.

Revision history for this message
Paul J. Lucas (paul-lucas) :
review: Approve
Revision history for this message
Rodolfo Ochoa (rodolfo-ochoa) :
review: Approve
Revision history for this message
Rodolfo Ochoa (rodolfo-ochoa) wrote :

I tested this branch on Windows, and worked fine.

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bug-855481-2013-01-31T19-21-30.845Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ChangeLog'
2--- ChangeLog 2013-01-30 05:26:46 +0000
3+++ ChangeLog 2013-01-31 05:10:27 +0000
4@@ -13,6 +13,7 @@
5 Bug Fixes/Other Changes:
6 * Fixed bug #1095889 (Improve error message for xml-parsing error).
7 * NaN items are considered equal to each other during grouping
8+ * Fixed bug #855481 (Too small time types on Windows).
9
10
11 version 2.9
12
13=== modified file 'include/zorba/util/time.h'
14--- include/zorba/util/time.h 2012-09-19 21:16:15 +0000
15+++ include/zorba/util/time.h 2013-01-31 05:10:27 +0000
16@@ -17,6 +17,8 @@
17 #ifndef ZORBA_UTIL_TIME_H
18 #define ZORBA_UTIL_TIME_H
19
20+#include <zorba/config.h>
21+
22 /**
23 * This header includes utility functions for certain timing-related
24 * operations, namely getting current wall-clock time and current
25@@ -53,6 +55,13 @@
26 namespace time
27 {
28
29+ // Large enough to hold number of milliseconds since epoch.
30+#if ZORBA_SIZEOF_LONG <= 4
31+ typedef long long msec_type;
32+#else
33+ typedef long msec_type;
34+#endif /* ZORBA_SIZEOF_LONG */
35+
36 //
37 //
38 // Types and functions for CPU time
39@@ -139,12 +148,12 @@
40 clock_gettime(CLOCK_MONOTONIC, &t);
41 #else
42 clock_gettime(CLOCK_REALTIME, &t);
43-#endif
44+#endif /* _POSIX_MONOTONIC_CLOCK */
45 }
46
47- inline long get_walltime_in_millis(const walltime& t)
48+ inline msec_type get_walltime_in_millis(const walltime& t)
49 {
50- return t.tv_sec * 1000 + t.tv_nsec / 1000000;
51+ return t.tv_sec * (msec_type)1000 + t.tv_nsec / 1000000;
52 }
53
54 #elif defined(WIN32)
55@@ -160,7 +169,7 @@
56 typedef struct timeb walltime;
57 #else
58 typedef struct _timeb walltime;
59-#endif
60+#endif /* WINCE */
61
62 inline double get_walltime_elapsed (const walltime& t0, const walltime& t1)
63 {
64@@ -173,12 +182,12 @@
65 ftime(&t);
66 #else
67 _ftime_s(&t);
68-#endif
69+#endif /* WINCE */
70 }
71
72- inline long get_walltime_in_millis(const walltime& t)
73+ inline msec_type get_walltime_in_millis(const walltime& t)
74 {
75- return (long)(t.time * 1000 + t.millitm);
76+ return t.time * (msec_type)1000 + t.millitm;
77 }
78
79 #else /* not Windows, and no clock_gettime() */
80@@ -199,19 +208,17 @@
81 gettimeofday(&t, NULL);
82 }
83
84- inline long get_walltime_in_millis(const walltime& t)
85+ inline msec_type get_walltime_in_millis(const walltime& t)
86 {
87- return t.tv_sec * 1000 + t.tv_usec / 1000;
88+ return t.tv_sec * (msec_type)1000 + t.tv_usec / 1000;
89 }
90
91 #endif /* ZORBA_HAVE_CLOCKGETTIME_FUNCTION */
92
93- } // ::time
94-
95-} // ::zorba
96-
97-#endif
98-
99+ } // namespace time
100+} // namesace zorba
101+
102+#endif /* ZORBA_UTIL_TIME_H */
103 /*
104 * Local variables:
105 * mode: c++
106
107=== modified file 'include/zorba/util/timer.h'
108--- include/zorba/util/timer.h 2012-09-19 21:16:15 +0000
109+++ include/zorba/util/timer.h 2013-01-31 05:10:27 +0000
110@@ -37,7 +37,7 @@
111 return get_walltime_elapsed(theStart, lEnd);
112 }
113
114- long getStart() const {
115+ time::msec_type getStart() const {
116 return get_walltime_in_millis(theStart);
117 }
118
119
120=== modified file 'src/runtime/random/random_impl.cpp'
121--- src/runtime/random/random_impl.cpp 2012-10-08 12:09:36 +0000
122+++ src/runtime/random/random_impl.cpp 2013-01-31 05:10:27 +0000
123@@ -105,7 +105,7 @@
124 {
125 store::Item_t num;
126 unsigned int int_seed;
127- long walltime_millis;
128+ time::msec_type walltime_millis;
129 uint32_t time_low;
130 zstring ltmp;
131

Subscribers

People subscribed via source and target branches