From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 96889 invoked by alias); 1 Jun 2015 20:58:51 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Received: (qmail 96806 invoked by uid 89); 1 Jun 2015 20:58:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.1 required=5.0 tests=AWL,BAYES_50,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 01 Jun 2015 20:58:39 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 84B5E3173D2; Mon, 1 Jun 2015 20:50:24 +0000 (UTC) Received: from c64.redhat.com (vpn-230-103.phx2.redhat.com [10.3.230.103]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t51KoE5L030113; Mon, 1 Jun 2015 16:50:23 -0400 From: David Malcolm To: gcc-patches@gcc.gnu.org, binutils@sourceware.org Cc: David Malcolm Subject: [PATCH 14/16] gcc: Add CTIMER_PUSH/POP to gcc's copy of libiberty Date: Mon, 01 Jun 2015 20:58:00 -0000 Message-Id: <1433192664-50156-15-git-send-email-dmalcolm@redhat.com> In-Reply-To: <1433192664-50156-1-git-send-email-dmalcolm@redhat.com> References: <1433192664-50156-1-git-send-email-dmalcolm@redhat.com> X-IsSubscribed: yes X-SW-Source: 2015-06/txt/msg00022.txt.bz2 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