Project

General

Profile

Actions

Support #907

closed

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

Added by Violet G. almost 10 years ago. Updated over 9 years ago.

Status:
Completed
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 NDK 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.

Actions #1

Updated by Dmitry M. almost 10 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.

Actions #2

Updated by Dmitry M. almost 10 years ago

  • Status changed from Open to Completed
  • % Done changed from 0 to 100
Actions #3

Updated by Violet G. almost 10 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?

Actions #4

Updated by Dmitry M. almost 10 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.

Actions #5

Updated by Dmitry M. over 9 years ago

  • Target version set to 10.2.0
Actions

Also available in: Atom PDF