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

Include a c wrapper function for TimeTrace::record(timestamp, ...)? #15

Open
yilongli opened this issue Nov 16, 2018 · 0 comments
Open

Comments

@yilongli
Copy link
Member

TimeTrace::record(timestamp, ...) is quite useful for adding a timetrace entry conditionally based on some value that is available only after the timetrace statement.

diff --git a/cwrapper/timetrace_wrapper.cc b/cwrapper/timetrace_wrapper.cc
index 0a03e8e..dd56626 100644
--- a/cwrapper/timetrace_wrapper.cc
+++ b/cwrapper/timetrace_wrapper.cc
@@ -53,6 +53,19 @@ timetrace_record(const char* format, uint32_t arg0, uint32_t arg1,
 }
 
 /**
+ * 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
  */
 void
diff --git a/cwrapper/timetrace_wrapper.h b/cwrapper/timetrace_wrapper.h
index 598317d..3c84567 100644
--- a/cwrapper/timetrace_wrapper.h
+++ b/cwrapper/timetrace_wrapper.h
@@ -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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant