The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



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

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-04-2009
fcolombo fcolombo is offline
Registered User
  
 

Join Date: Oct 2009
Posts: 1
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
}
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 (permalink)  
Old 10-05-2009
fpmurphy's Avatar
fpmurphy fpmurphy is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2003
Location: Florida
Posts: 1,915
Do a web search for "clock_gettime.c" and you will find source code for a number of implementations.
Reply

Bookmarks

Tags
clock_gettime, gettimeofday

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:27 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0