Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp344274pxa; Wed, 5 Aug 2020 02:37:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwCFjI4nE+IED2ErWA9awBqOqqdv8OwJCtjO7XNsL7Khz/fLBrmEKkwC4ZagNyhTHdCjfyf X-Received: by 2002:a17:906:3449:: with SMTP id d9mr2366356ejb.460.1596620265536; Wed, 05 Aug 2020 02:37:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596620265; cv=none; d=google.com; s=arc-20160816; b=i/k8XSHVbY4TQmsJDlFhYKeWrmSBOxFluawPPBzIhpaeD5AA+TN8NWIU8h+CpD4M4J tZtXED3tHQFjs5GStJOXF2jPQl0HMolpuTq7RzFNWhXJs0xjV2w47sATjtjyN3FLz8dY akJD0K2nnW2j02HBOCDEep+ZliuKhTNZYfH/d+RyxYutDrDRtlORcPh7HlFSE/fkeb8C ylw9n/0YO+ZJxuqwHlDM6AEoHnTvalxpnCODfjnfiZuZUKI73UQHPt3ehtWoIYFd1Iim 9OY0uSQw+vVI4JCxp1AEf1JOBCo2hm1szWQ27+q6PTVEIReQuqLp48h1kywr3heZwyb5 MpgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=9ZKeE0TVFqhSAUQKjSSDxforqE7y4X/imz5A/zq5Yf0=; b=qkpWz+hPOLwJW/fztoVdThg7PtDxIGb5ZLg9Mk66kuxj8y2oWGDXb2rxuhY7W4/bzP Nexmj/czasTJPLaeHtorfpKE3PTH16O8iHHYvtfL6covy8TK/9t5bUyc3wg/3qw8us6d nF6ajNN1amJYHC9ON4HA+nWa7QG3Jw2H5bA6CxcOSu5qwCow2nzhp7OW7cBK0Xjsuqya zwjX60eOBv6PPAaMTjzpIFfje5WXttVtJRWRLj7J+4nj2e6eBCbhywJGzJG8cfXN6s36 YfkW01xHTD1KtoLC9RpdldAmOMfVMtsOApA+LTPnIKBO0yNZ+tzRypkVgCjDP8JdcSFE dmMw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h8si766749ejj.541.2020.08.05.02.36.49; Wed, 05 Aug 2020 02:37:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728175AbgHEJge convert rfc822-to-8bit (ORCPT + 99 others); Wed, 5 Aug 2020 05:36:34 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:21996 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728378AbgHEJfG (ORCPT ); Wed, 5 Aug 2020 05:35:06 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-407-db6gC643OpCV6XPvJ_8RpQ-1; Wed, 05 Aug 2020 05:35:01 -0400 X-MC-Unique: db6gC643OpCV6XPvJ_8RpQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5736918C63C1; Wed, 5 Aug 2020 09:34:58 +0000 (UTC) Received: from krava.redhat.com (unknown [10.40.194.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id D64517193A; Wed, 5 Aug 2020 09:34:54 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Michael Petlan , Ian Rogers , Andi Kleen , David Ahern , =?UTF-8?q?Genevi=C3=A8ve=20Bastien?= , Wang Nan , Jeremie Galarneau Subject: [PATCH v2 2/7] perf tools: Add clockid_name function Date: Wed, 5 Aug 2020 11:34:39 +0200 Message-Id: <20200805093444.314999-3-jolsa@kernel.org> In-Reply-To: <20200805093444.314999-1-jolsa@kernel.org> References: <20200805093444.314999-1-jolsa@kernel.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kernel.org Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adding clockid_name function to get the clock name based on its clockid. It will be used in following changes. Signed-off-by: Jiri Olsa --- tools/perf/util/clockid.c | 11 +++++++++++ tools/perf/util/clockid.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/tools/perf/util/clockid.c b/tools/perf/util/clockid.c index b7a08606dc3e..74365a5d99c1 100644 --- a/tools/perf/util/clockid.c +++ b/tools/perf/util/clockid.c @@ -106,3 +106,14 @@ int parse_clockid(const struct option *opt, const char *str, int unset) ui__warning("unknown clockid %s, check man page\n", ostr); return -1; } + +const char *clockid_name(clockid_t clk_id) +{ + const struct clockid_map *cm; + + for (cm = clockids; cm->name; cm++) { + if (cm->clockid == clk_id) + return cm->name; + } + return "(not found)"; +} diff --git a/tools/perf/util/clockid.h b/tools/perf/util/clockid.h index 8e567b3ebbbd..9b49b4711c76 100644 --- a/tools/perf/util/clockid.h +++ b/tools/perf/util/clockid.h @@ -6,4 +6,6 @@ struct option; int parse_clockid(const struct option *opt, const char *str, int unset); +const char *clockid_name(clockid_t clk_id); + #endif -- 2.25.4