sysconf(_SC_MONOTONIC_CLOCK) problem

Will Wagner will_wagner at carallon.com
Thu Jun 12 18:35:59 UTC 2008


Hello,

I am using uclicb 0.9.29 on Arm built with buildroot

I want to use monotonic clock support and to test that that 
functionality exists I try the following bit of code:

     long x = sysconf(_SC_MONOTONIC_CLOCK);
     bool hasMonotonic = x >= 200112L;

However when I run this sysconf return -1.

Looking at the code it appears this happens if __NR_clock_getres is not 
defined. However looking at the kernel headers I think it is defined as:

#define __NR_clock_getres		(__NR_SYSCALL_BASE+264)

in unistd.h

If I run this code:

     if (syscall(__NR_clock_getres, CLOCK_MONOTONIC, NULL) < 0)
     {
         printf("syscall failed %d", errno);
         return 0;
     }

     if (clock_getres(CLOCK_MONOTONIC, NULL) < 0)
     {
         printf("clock_getres failed %d", errno);
         return 0;
     }

Then both calls succeed so the kernel supports this.

 From this I assume that uclibc is compiled as if __NR_clock_getres is 
not defined. Does that sound right?

I have looked for configuration options and can not find any for this. 
How can I enable this?


Thanks,

Will.

-- 
------------------------------------------------------------------------
Will Wagner                                     will_wagner at carallon.com
Senior Project Engineer                  Office Tel: +44 (0)20 7371 2032
Carallon Ltd, Studio G20, Shepherds Building, Rockley Rd, London W14 0DA
------------------------------------------------------------------------





More information about the uClibc mailing list