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