This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH 14/16] gcc: Add CTIMER_PUSH/POP to gcc's copy of libiberty
- From: David Malcolm <dmalcolm at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org, binutils at sourceware dot org
- Cc: David Malcolm <dmalcolm at redhat dot com>
- Date: Mon, 1 Jun 2015 17:04:22 -0400
- Subject: [PATCH 14/16] gcc: Add CTIMER_PUSH/POP to gcc's copy of libiberty
- Authentication-results: sourceware.org; auth=none
- References: <1433192664-50156-1-git-send-email-dmalcolm at redhat dot com>
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