![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| undefined symbol: clock_gettime' error | dpa078 | High Level Programming | 4 | 04-09-2008 09:29 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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:
Code:
#include <sys/time.h>
#include <time.h>
int clock_gettime_replacement(struct timespec *now) {
#ifdef HAVE_CLOCK_GETTIME
return clock_gettime(CLOCK_REALTIME, now);
#else
now->tv_sec = time(NULL);
struct timeval tv;
gettimeofday(&tv, NULL);
now->tv_nsec = tv.tv_usec * 1000;
return 0;
#endif
}
|
![]() |
| Bookmarks |
| Tags |
| clock_gettime, gettimeofday |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|