Hi !!
I have tried to compile the next example under tiny core , 4.6.2 version under INTEL Pentium Desk top board.
My compilation has "undefined reference to XXXX" errors for clock_settime, clock_getres and clock_gettime functions...
The function nanosleep works fine with no errors on compilation when it is the only instruction enabled...
I wonder what is going wrong as the time.h extern references are under the same nanosleep section of the header.
Any hint
?
Thanks
Sal...
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <sys/io.h>
#include <fcntl.h>
#include <sys/signal.h>
#include <sys/types.h>
#include <termios.h>
#include <unistd.h>
#include "rs232.h"
#include "timer.h"
#include "time.h"
#define BILLION 1000000000L
uint64_t diff;
int main(void)
/****************************/
{
// USING TINY CORE VERSION 4.6.2 GCC COMPILER , STRAIGHT
struct timespec tim,tim2;
tim.tv_sec=1;
tim.tv_nsec=500;
clock_settime(CLOCK_MONOTONIC,&tim); <--- this function call has "undefined reference to clock_settime
clock_getres(CLOCK_MONOTONIC,&tim); <--- this function call has "undefined reference to clock_getres
nanosleep(&tim,&tim2); <<<--- this function has no problems...
clock_gettime(CLOCK_MONOTONIC,&tim); <--- this function call has "undefined reference to clock_gettime
sleep(1);
clock_gettime(CLOCK_MONOTONIC,&tim2); <--- this function call has "undefined reference to clock_gettime
diff=BILLION*(tim2.tv_sec-tim.tv_sec)+(tim2.tv_nsec-tim.tv_nsec);
printf(" tiempo transcurrido = %11u nanosegundos\n",(long long unsigned int diff));
if ( nanosleep(&tim,&tim2) < 0)
{
printf("nano sleep fallo\n");
}
printf("exito !!!\n");
}
the time.h has the next
#iddef __USE_POSIX199309
extern int nanosleep(__const struct timespec *__requested_time, struct timespec *__remaining);
extern int clock_getres( clockid_t__clock_id, struct timespec *__res)__THROW;
extern int clock_getime( clockid_t__clock_id, struct timespec *__tp)__THROW;
extern int clock_settime( clockid_t__clock_id, struct timespec *__tp)__THROW;
#ifdef __USE_XOPEN2K
.....
#endif