Support #907
closedWhy does CLOCKS_PER_SEC equal 128 in CrystaX (mangled-time.h)?
100%
Description
CLOCKS_PER_SEC usually equals 1000 on Windows, and 1000000 on Unix systems (Linux / Mac OS X / Android). While I realize it can be an arbitrary value, I've never worked on a non-Windows system where it doesn't equal 1000000. Why is it 128 in CrystaX? That creates bugs like division by zero:
time_t start = clock();
Logger() << "Loaded in " << int(clock() - start) / (CLOCKS_PER_SEC / 1000) << " msec";
Here, integer division of CLOCKS_PER_SEC by 1000 results in 0 - completely unexpectedly.
P. S. Sorry for abusing the bug tracker - there don't seem to be any kind of a forum, and this is the only way I've found to ask a question.
Updated by Dmitry M. over 9 years ago
Violet Giraffe wrote:
CLOCKS_PER_SEC usually equals 1000 on Windows, and 1000000 on Unix systems (Linux / Mac OS X / Android). While I realize it can be an arbitrary value, I've never worked on a non-Windows system where it doesn't equal 1000000. Why is it 128 in CrystaX?
This is bug, which is already fixed in "this commit":https://github.com/crystax/android-platform-ndk/commit/13f89409e8c0a5dd19853eb736f07c23ce498aed. It was caused initially by using FreeBSD's time.h, where CLOCKS_PER_SEC is defined as 128. This fix will be included in next release.
P. S. Sorry for abusing the bug tracker - there don't seem to be any kind of a forum, and this is the only way I've found to ask a question.
This is OK - you've reported bug so it's 100% proper usage of the tracker. We're going to launch forum soon though. In the meantime, feel free to file tickets as this one or "contact us directly":https://www.crystax.net/contact.
Updated by Dmitry M. over 9 years ago
- Status changed from Open to Completed
- % Done changed from 0 to 100
Updated by Violet G. over 9 years ago
Dmitry Moskalchuk wrote:
This is bug, which is already fixed in "this commit":https://github.com/crystax/android-platform-ndk/commit/13f89409e8c0a5dd19853eb736f07c23ce498aed.
Thank you!
Is it safe to simply replace the value with 1000000 in the header file in 10.1 release downloaded from your site, and build a production version of the app with it? Or do I need to wait until Crystax is completely re-built?
Updated by Dmitry M. over 9 years ago
Violet Giraffe wrote:
Is it safe to simply replace the value with 1000000 in the header file in 10.1 release downloaded from your site, and build a production version of the app with it? Or do I need to wait until Crystax is completely re-built?
Should be safe. At least, all our tests were passed with this change. Anyway, if something will be wrong, feel free to report us, we'd be happy to help and fix it.