Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linux: avoid using CLOCK_SGI_CYCLE #123

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

soundart
Copy link

@soundart soundart commented Jan 5, 2018

The call clock_gettime(CLOCK_SGI_CYCLE, &t) from function getticks() fails with EINVAL.
See : http://elixir.free-electrons.com/linux/latest/source/include/uapi/linux/time.h#L62 - "The driver implementing this got removed. The clock ID is kept as a place holder. Do not reuse!"

See #122

The call clock_gettime(CLOCK_SGI_CYCLE, &t) from function getticks() fails with EINVAL.
See : http://elixir.free-electrons.com/linux/latest/source/include/uapi/linux/time.h#L62 - "The driver implementing this got removed. The clock ID is kept as a place holder. Do not reuse!"
soundart referenced this pull request Jan 5, 2018
The Android headers defines CLOCK_SGI_CYCLE but the call fails at
runtime as it's not implemented. Combined with getticks() not
checking the return value of clock_gettime() this causes bogus
values to be returned from getticks().
@soundart
Copy link
Author

Hi I updated the patch, because:

  • I forgot to use the CLOCK_XXX/METHOD parameter
  • It made problems on linux amd64 because there the X86-64 cycle counter was used with a conflicting definition of ticks

@soundart
Copy link
Author

Hi,

yes I think too, but it is difficult to judge without an android build for testing.

I guess the android build uses one of these:

#if defined(HAVE_ARMV7A_CNTVCT)
or
#if defined(HAVE_ARMV7A_PMCCNTR)
or
#if defined(aarch64) && defined(HAVE_ARMV8_CNTVCT_EL0) && !defined(HAVE_ARMV8_PMCCNTR_EL0)
or
#if defined(aarch64) && defined(HAVE_ARMV8_PMCCNTR_EL0)

and I think these defines should move upwards in cycle.h, so that they appear before the more generic clock_gettime()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants