Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose TimeTrace::record(timestamp, ...) in the c wrapper. #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does the comment in the CC file say that caller always needs to pass arg0-3 when this header clearly allows fewer arguments to be passed?

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