Skip to content

Commit

Permalink
Fix #363: Linux implementation of MDD_getTimeMS(...)
Browse files Browse the repository at this point in the history
  • Loading branch information
bernhard-thiele committed Oct 6, 2022
1 parent 0467736 commit 8048db4
Showing 1 changed file with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -814,18 +814,14 @@ DllExport double MDD_sampledRealtimeSynchronize(void* rtSyncObj, double simTime,
return deltaTime;
}

double MDD_getTimeMS(double dummy) {
DllExport double MDD_getTimeMS(double dummy) {
struct timespec ts;
int ret, ms;

ret = clock_gettime(CLOCK_MONOTONIC, &ts);
int ret = clock_gettime(CLOCK_MONOTONIC, &ts);
if (ret) {
ModelicaFormatError("MDDRealtimeSynchronize.h: clock_gettime failed (%s)\n", strerror(errno));
}

ms = ts.tv_sec*1000 + floor( (double)ts.tv_nsec/1000.0 + 0.5);

return (double)ms;
double epoch_ms = (double)ts.tv_sec*1000.0 + floor( (double)ts.tv_nsec/1e6 + 0.5);
return epoch_ms;
}

/******************************************************/
Expand Down

0 comments on commit 8048db4

Please sign in to comment.