Project

General

Profile

Support #907

Why does CLOCKS_PER_SEC equal 128 in CrystaX (mangled-time.h)?

Added by Violet Giraffe about 4 years ago. Updated almost 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Target version:
Start date:
03/19/2015
Due date:
% Done:

100%

Estimated time:
CPU Architecture:
arm
Host OS:
Windows
Toolchain:
gcc-4.9
Android version:
4.2 (android-17)
CrystaX Version:

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.

History

#1 Updated by Dmitry Moskalchuk about 4 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.

#2 Updated by Dmitry Moskalchuk about 4 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

#3 Updated by Violet Giraffe about 4 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?

#4 Updated by Dmitry Moskalchuk about 4 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.

#5 Updated by Dmitry Moskalchuk almost 4 years ago

  • Target version set to 10.2.0

Also available in: Atom PDF