Skip to content

Commit b6bce4a

Browse files
committed
Expose TimeTrace::record(timestamp, ...) in the c wrapper.
1 parent 1de07f3 commit b6bce4a

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

cwrapper/timetrace_wrapper.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,19 @@ timetrace_record(const char* format, uint32_t arg0, uint32_t arg1,
5252
TimeTrace::record(format, arg0, arg1, arg2, arg3);
5353
}
5454

55+
/**
56+
* This function is the wrapper for TimeTrace::record
57+
*
58+
* Since C does not support default value, caller always needs to pass arg0-3.
59+
* Also, we cannot separate definition and declaration of inline function, so
60+
* this function cannot be inline function.
61+
*/
62+
void
63+
timetrace_record_ts(uint64_t timestamp, const char* format, uint32_t arg0,
64+
uint32_t arg1, uint32_t arg2, uint32_t arg3) {
65+
TimeTrace::record(timestamp, format, arg0, arg1, arg2, arg3);
66+
}
67+
5568
/**
5669
* This function is used to set TimeTrace::keepOldEvents
5770
*/

cwrapper/timetrace_wrapper.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ void timetrace_print();
3535
* uint32_t arg2, uint32_t arg3);
3636
*/
3737
void timetrace_record();
38+
/**
39+
* The real signature of this function is the following. The timestamp and the
40+
* format string are mandatory; remaining arguments are only necessary as
41+
* specified by format string.
42+
* void timetrace_record_ts(uint64_t timestamp, const char* format,
43+
* uint32_t arg0, uint32_t arg1, uint32_t arg2,
44+
* uint32_t arg3);
45+
*/
46+
void timetrace_record_ts();
3847
void timetrace_set_keepoldevents(bool keep);
3948

4049
#ifdef __cplusplus

src/TimeTrace.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,9 @@ TimeTrace::printInternal(std::vector<TimeTrace::Buffer*>* buffers, string* s) {
348348

349349
if (!printedAnything) {
350350
if (s != NULL) {
351-
s->append("No time trace events to print");
351+
s->append("No time trace events to print\n");
352352
} else {
353-
fprintf(output, "No time trace events to print");
353+
fprintf(output, "No time trace events to print\n");
354354
}
355355
}
356356

0 commit comments

Comments
 (0)