Skip to content

Commit

Permalink
Expose TimeTrace::record(timestamp, ...) in the c wrapper.
Browse files Browse the repository at this point in the history
  • Loading branch information
yilongli committed Nov 17, 2018
1 parent 1de07f3 commit b6bce4a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
13 changes: 13 additions & 0 deletions cwrapper/timetrace_wrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,19 @@ timetrace_record(const char* format, uint32_t arg0, uint32_t arg1,
TimeTrace::record(format, arg0, arg1, arg2, arg3);
}

/**
* This function is the wrapper for TimeTrace::record
*
* Since C does not support default value, caller always needs to pass arg0-3.
* Also, we cannot separate definition and declaration of inline function, so
* this function cannot be inline function.
*/
void
timetrace_record_ts(uint64_t timestamp, const char* format, uint32_t arg0,
uint32_t arg1, uint32_t arg2, uint32_t arg3) {
TimeTrace::record(timestamp, format, arg0, arg1, arg2, arg3);
}

/**
* This function is used to set TimeTrace::keepOldEvents
*/
Expand Down
9 changes: 9 additions & 0 deletions cwrapper/timetrace_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ void timetrace_print();
* uint32_t arg2, uint32_t arg3);
*/
void timetrace_record();
/**
* The real signature of this function is the following. The timestamp and the
* format string are mandatory; remaining arguments are only necessary as
* specified by format string.
* void timetrace_record_ts(uint64_t timestamp, const char* format,
* uint32_t arg0, uint32_t arg1, uint32_t arg2,
* uint32_t arg3);
*/
void timetrace_record_ts();
void timetrace_set_keepoldevents(bool keep);

#ifdef __cplusplus
Expand Down
4 changes: 2 additions & 2 deletions src/TimeTrace.cc
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,9 @@ TimeTrace::printInternal(std::vector<TimeTrace::Buffer*>* buffers, string* s) {

if (!printedAnything) {
if (s != NULL) {
s->append("No time trace events to print");
s->append("No time trace events to print\n");
} else {
fprintf(output, "No time trace events to print");
fprintf(output, "No time trace events to print\n");
}
}

Expand Down

0 comments on commit b6bce4a

Please sign in to comment.