This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


include/ChangeLog:
	* libiberty.h (struct ctimer): New.
	(CTIMER_PUSH): New.
	(CTIMER_POP): New.
---
 include/libiberty.h | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

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
-- 
1.8.5.3


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]