Skip to content

Commit

Permalink
Optionally remove dependency on gettimeofday
Browse files Browse the repository at this point in the history
  • Loading branch information
Sympatron committed Oct 30, 2024
1 parent 82eeb9b commit 3780b77
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,26 @@ int add_iso8601_utc_datetime(char *buf, size_t size)
return strftime(buf, size, "%Y-%m-%dT%H:%M:%SZ", &timeinfo);
}

#elif defined(NO_OS)

int add_iso8601_utc_datetime(char *buf, size_t size)
{
//TODO: Timestamp Generation
ARG_UNUSED(buf);
ARG_UNUSED(size);
return 0;
}

// Expect user to provide this function
extern int64_t usec_now();

#else

#error Platform test failed

#endif

#if !defined(NO_OS)
int64_t usec_now()
{
int64_t usec;
Expand All @@ -173,6 +187,7 @@ void get_time(uint32_t *seconds, uint32_t *micro_seconds)
*seconds = tv.tv_sec;
*micro_seconds = tv.tv_usec;
}
#endif

int64_t usec_since(int64_t last)
{
Expand Down Expand Up @@ -205,6 +220,10 @@ void dump_trace(void)
puts("");
free(strings);
}
#elif defined(NO_OS)
void dump_trace(void)
{
}
#else
void dump_trace(void)
{
Expand Down

0 comments on commit 3780b77

Please sign in to comment.