I'm trying to use the POSIX clock functions in the kernel but the compiler keeps giving me the error: error: implicit declaration of function ‘clock_gettime’
long __timer_end(struct timespec start_time) { struct timespec end_time; clock_gettime(CLOCK_REALTIME_COARSE, &end_time); return(end_time.tv_nsec - start_time.tv_nsec); } struct timespec __timer_start(void) { struct timespec start_time; clock_gettime(CLOCK_REALTIME_COARSE, &start_time); return start_time; } The functions are defined in <linux/posix_clock.h> as part of structure called posix_clock_operations and there are a pair of functions, posix_clock_register() and posix_clock_unregister(). The comments lead one to believe that these functions will populate the posix_clock_operations structure. I've implemented both in my init and exit functions hoping that their presence would magically make the forward declarations for clock_gettime() appear, but it doesn't.
Does anyone know what I need to do to make this one function work? Do I really need to define all my own functions an populate posix clock_operations?
Thanks in advance,
Pete
clock_gettime()is defined intime.h. Are you referring to this, or to the actualclock_get_time()(web.mit.edu/darwin/src/modules/xnu/osfmk/man/…) ?<linux/time.h>the functions are not declared, just the structures and IDs etc.time.h, notlinux/time.h. The former actually definesextern int clock_gettime (clockid_t __clock_id, struct timespec *__tp).current_kernel_time()which is a nsec granularity timer.