diff mbox

[14/16] gcc: Add CTIMER_PUSH/POP to gcc's copy of libiberty

Message ID 1433192664-50156-15-git-send-email-dmalcolm@redhat.com
State New
Headers show

Commit Message

David Malcolm June 1, 2015, 9:04 p.m. UTC
include/ChangeLog:
	* libiberty.h (struct ctimer): New.
	(CTIMER_PUSH): New.
	(CTIMER_POP): New.
---
 include/libiberty.h | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

Comments

DJ Delorie June 1, 2015, 9:33 p.m. UTC | #1
This is the same patch as 09/16.  There is only one libiberty master,
controlled by gcc, it is not neccessary to submit separate patches for
each copy of it.

The convention is: Any libiberty patch approved by gcc maintainers is
auto-approved for the other repos.
diff mbox

Patch

diff --git a/include/libiberty.h b/include/libiberty.h
index b33dd65..a2c73ae 100644
--- a/include/libiberty.h
+++ b/include/libiberty.h
@@ -731,6 +731,38 @@  extern unsigned long libiberty_len;
    (char *) memcpy (libiberty_nptr, libiberty_optr, libiberty_len))
 #endif
 
+/* Support for hooking into gcc's timing mechanism
+   (class timer), from a pure C API, withough needing to link
+   against any symbols. */
+
+struct ctimer
+{
+   void (*push) (struct ctimer *t, const char *item_name);
+   void (*pop) (struct ctimer *t);
+};
+
+/* Macros for pushing/popping named timing items, so we can write e.g.:
+
+     CTIMER_PUSH (some_timer, "init");
+     init ();
+     CTIMER_POP ();
+
+   and have it redirected into GCC's timing mechanism.
+
+   Typically, CTIMER is NULL, and this does nothing.  */
+
+#define CTIMER_PUSH(CTIMER, ITEM_NAME)          \
+  do {                                          \
+    if (CTIMER)                                 \
+      (CTIMER)->push ((CTIMER), (ITEM_NAME));   \
+  } while (0)
+
+#define CTIMER_POP(CTIMER)                      \
+  do {                                          \
+    if (CTIMER)                                 \
+      (CTIMER)->pop (CTIMER);                   \
+  } while (0)
+
 #ifdef __cplusplus
 }
 #endif