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
=== modified file 'ChangeLog'
--- ChangeLog 2013-01-30 05:26:46 +0000
+++ ChangeLog 2013-01-31 05:10:27 +0000
@@ -13,6 +13,7 @@
13Bug Fixes/Other Changes:13Bug Fixes/Other Changes:
14 * Fixed bug #1095889 (Improve error message for xml-parsing error).14 * Fixed bug #1095889 (Improve error message for xml-parsing error).
15 * NaN items are considered equal to each other during grouping15 * NaN items are considered equal to each other during grouping
16 * Fixed bug #855481 (Too small time types on Windows).
1617
1718
18version 2.919version 2.9
1920
=== modified file 'include/zorba/util/time.h'
--- include/zorba/util/time.h 2012-09-19 21:16:15 +0000
+++ include/zorba/util/time.h 2013-01-31 05:10:27 +0000
@@ -17,6 +17,8 @@
17#ifndef ZORBA_UTIL_TIME_H17#ifndef ZORBA_UTIL_TIME_H
18#define ZORBA_UTIL_TIME_H18#define ZORBA_UTIL_TIME_H
1919
20#include <zorba/config.h>
21
20/**22/**
21 * This header includes utility functions for certain timing-related23 * This header includes utility functions for certain timing-related
22 * operations, namely getting current wall-clock time and current24 * operations, namely getting current wall-clock time and current
@@ -53,6 +55,13 @@
53 namespace time55 namespace time
54 {56 {
5557
58 // Large enough to hold number of milliseconds since epoch.
59#if ZORBA_SIZEOF_LONG <= 4
60 typedef long long msec_type;
61#else
62 typedef long msec_type;
63#endif /* ZORBA_SIZEOF_LONG */
64
56 //65 //
57 //66 //
58 // Types and functions for CPU time67 // Types and functions for CPU time
@@ -139,12 +148,12 @@
139 clock_gettime(CLOCK_MONOTONIC, &t);148 clock_gettime(CLOCK_MONOTONIC, &t);
140#else149#else
141 clock_gettime(CLOCK_REALTIME, &t);150 clock_gettime(CLOCK_REALTIME, &t);
142#endif151#endif /* _POSIX_MONOTONIC_CLOCK */
143 }152 }
144153
145 inline long get_walltime_in_millis(const walltime& t)154 inline msec_type get_walltime_in_millis(const walltime& t)
146 {155 {
147 return t.tv_sec * 1000 + t.tv_nsec / 1000000;156 return t.tv_sec * (msec_type)1000 + t.tv_nsec / 1000000;
148 }157 }
149158
150#elif defined(WIN32)159#elif defined(WIN32)
@@ -160,7 +169,7 @@
160 typedef struct timeb walltime;169 typedef struct timeb walltime;
161#else170#else
162 typedef struct _timeb walltime;171 typedef struct _timeb walltime;
163#endif172#endif /* WINCE */
164173
165 inline double get_walltime_elapsed (const walltime& t0, const walltime& t1) 174 inline double get_walltime_elapsed (const walltime& t0, const walltime& t1)
166 {175 {
@@ -173,12 +182,12 @@
173 ftime(&t);182 ftime(&t);
174#else183#else
175 _ftime_s(&t);184 _ftime_s(&t);
176#endif185#endif /* WINCE */
177 }186 }
178 187
179 inline long get_walltime_in_millis(const walltime& t)188 inline msec_type get_walltime_in_millis(const walltime& t)
180 {189 {
181 return (long)(t.time * 1000 + t.millitm);190 return t.time * (msec_type)1000 + t.millitm;
182 }191 }
183192
184#else /* not Windows, and no clock_gettime() */193#else /* not Windows, and no clock_gettime() */
@@ -199,19 +208,17 @@
199 gettimeofday(&t, NULL);208 gettimeofday(&t, NULL);
200 }209 }
201 210
202 inline long get_walltime_in_millis(const walltime& t)211 inline msec_type get_walltime_in_millis(const walltime& t)
203 {212 {
204 return t.tv_sec * 1000 + t.tv_usec / 1000;213 return t.tv_sec * (msec_type)1000 + t.tv_usec / 1000;
205 }214 }
206215
207#endif /* ZORBA_HAVE_CLOCKGETTIME_FUNCTION */216#endif /* ZORBA_HAVE_CLOCKGETTIME_FUNCTION */
208217
209 } // ::time218 } // namespace time
210219} // namesace zorba
211} // ::zorba220
212221#endif /* ZORBA_UTIL_TIME_H */
213#endif
214
215/*222/*
216 * Local variables:223 * Local variables:
217 * mode: c++224 * mode: c++
218225
=== modified file 'include/zorba/util/timer.h'
--- include/zorba/util/timer.h 2012-09-19 21:16:15 +0000
+++ include/zorba/util/timer.h 2013-01-31 05:10:27 +0000
@@ -37,7 +37,7 @@
37 return get_walltime_elapsed(theStart, lEnd);37 return get_walltime_elapsed(theStart, lEnd);
38 }38 }
3939
40 long getStart() const {40 time::msec_type getStart() const {
41 return get_walltime_in_millis(theStart);41 return get_walltime_in_millis(theStart);
42 }42 }
4343
4444
=== modified file 'src/runtime/random/random_impl.cpp'
--- src/runtime/random/random_impl.cpp 2012-10-08 12:09:36 +0000
+++ src/runtime/random/random_impl.cpp 2013-01-31 05:10:27 +0000
@@ -105,7 +105,7 @@
105{105{
106 store::Item_t num;106 store::Item_t num;
107 unsigned int int_seed;107 unsigned int int_seed;
108 long walltime_millis;108 time::msec_type walltime_millis;
109 uint32_t time_low;109 uint32_t time_low;
110 zstring ltmp;110 zstring ltmp;
111111

Subscribers

People subscribed via source and target branches