Title: Convert GetTickCount() vxWorks to Linux
Tags: c++;linux;vxworks
Question: I am porting some vxWorks code to Linux.
I looked at this answer and it recommends CLOCK_MONOTONIC. Is that a suitable replacement for the following define:
#define GetTickCount()    ((1000.0 * (double)tickGet())/((double)sysClkRateGet())))

Here is the accepted answer: GetTickCount is a windows API described thus:
Retrieves the number of milliseconds that have elapsed since the system was started, up to 49.7 days
Yes, CLOCK_MONOTONIC is the correct POSIX clock to use. Here is untested code for you:
double GetTickCount(void)
struct timespec now;
if (clock_gettime(CLOCK_MONOTONIC, &amp;now))
return 0;
return now.tv_sec * 1000.0 + now.tv_nsec / 1000000.0;


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2011:00:10/11/11', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<c++><linux><vxworks>', 'Title': 'Convert GetTickCount() vxWorks to Linux', 'ViewCount': 10358, 'id': 7729686, 'user_AboutMe': None, 'user_AccountId': None, 'user_DisplayName': None, 'user_Reputation': None, 'user_Views': None, 'user_id': None}}