How use pthread_cond_timedwait without clock_gettime?

Thread Tools Search this Thread
Top Forums Programming How use pthread_cond_timedwait without clock_gettime?
# 1  
Old 10-04-2009
How use pthread_cond_timedwait without clock_gettime?

I need to use pthread_cond_timedwait, which is available in my old embedded Linux for PPC. But I don't have clock_gettime... So, I build this replacement for clock_gettime, and it seems to work:

#include <sys/time.h>
#include <time.h>

int clock_gettime_replacement(struct timespec *now) {
    return clock_gettime(CLOCK_REALTIME, now);
    now->tv_sec = time(NULL);
    struct timeval tv;
    gettimeofday(&tv, NULL);
    now->tv_nsec = tv.tv_usec * 1000;
    return 0;

But I'm afraid of issues related with daylight saving and timezone. Do you know where I can get sources of clock_gettime, so I can build it on my own using other system calls?
# 2  
Old 10-05-2009
Do a web search for "clock_gettime.c" and you will find source code for a number of implementations.
Login or Register to Ask a Question

Previous Thread | Next Thread

2 More Discussions You Might Find Interesting

1. Programming

pthread_cond_timedwait relocks forever

looking in pthread's source code I can see that as an epilogue both pthread_cond_timedwait and pthread_cond_wait will try to relock the mutex by means of __pthread_mutex_cond_lock. Does this mean that any of them both could eventually block forever if the mutex is never again available after... (4 Replies)
Discussion started by: ramestica
4 Replies

2. Programming

undefined symbol: clock_gettime' error

Hi, i've compiled my app on x86_64 with -m32 gcc option. Can anybody tell me what is/would typically cause the 'undefined symbol: clock_gettime' error?? -1 k){0N!x y} '/home/da71336/simon/mkvfh/ undefined symbol: clock_gettime @ "q" "subr:mkv 2:`subr,3; subc:mkv 2:`subc,1;... (4 Replies)
Discussion started by: dpa078
4 Replies
Login or Register to Ask a Question