Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1721219ybk; Thu, 21 May 2020 13:39:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzPm9bk6yBKm7Myl7aKY5uDidrtRfTuVnJdVkeC80on3A9bRwKMSUsNQWtICE2E2k8gzpkg X-Received: by 2002:a17:906:e08a:: with SMTP id gh10mr5588059ejb.512.1590093545149; Thu, 21 May 2020 13:39:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590093545; cv=none; d=google.com; s=arc-20160816; b=rVrTiOsXCw2+ALhRRgAfr8YLUKjKUKdFBh+K8BZSQiVM0gUXrwM4ip1FwB7hv7t2M0 MiCBQfrSO3/CyIOsqsl3C4iBNbURoKFbdBCsE8NTmzBhDBC82SlP/ybss+7lTfQxsrdc dPLS3Dy6KvxjKwncnDxfvPXFo+deZvpirChzCG6pV0SvFKsgrWpEWR4o2/LFHQMv6EOA JV2nRuf6S1/SCK/mWnZWckF+IknRVW7tQR+5NYJ6p7HIYSh55eNPJzsvweDURXWAs9AF XxSG2QtFwGHhmDLyLx+pa1OkVTCHV5XTzYmbY9nQdh1AHZmvQ6V+as1IPAXzsvB3RMxS bIuw== 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 :dkim-signature; bh=QllVIHkUbgQQjUuqCCdzf4R8GJeQbjkV9f9np+EkWR4=; b=I0XRed8HFywDAdSkVWdBnmziAlYt4rNHJXUJrAUTak5fmSnzDYfZc6RebbXm6FNID1 SOMQ1qWEy2CFOUB2hGb1jk/J4R6uts2aE+uUm1rT7M5M/5Rs5I8u2URMF8r+OjlNkXP7 F4sQke4K5j1BQDIC//eRYkqJ8n4nYYKJpuvKZYn8NMDWU8YYnTOTo57iJnZ5AU+lO3Yq hknN7c3Z7URu/iJxhA7nm1ITxmaa4bOOZFN+q/81eLFbgJ5/+6CXOMNbLnKVfb+B/btv t7q91oG5ZImQ2/RNeWZRu763KyWjJsWvcWY5V3ZvzYzMKLVLr8uTlVVivv+HyqMUX4vM u05A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XnSQFi94; 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 qo7si3996438ejb.458.2020.05.21.13.38.42; Thu, 21 May 2020 13:39:05 -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; dkim=pass header.i=@kernel.org header.s=default header.b=XnSQFi94; 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 S1729455AbgEUUhV (ORCPT + 99 others); Thu, 21 May 2020 16:37:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:57588 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726814AbgEUUhT (ORCPT ); Thu, 21 May 2020 16:37:19 -0400 Received: from localhost (fw-tnat.cambridge.arm.com [217.140.96.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 15CEB20756; Thu, 21 May 2020 20:37:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590093438; bh=Kocl9qKzbhhSYvxWD7eR0QIaqitMTcRIhZX3UCsFB8c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XnSQFi94nvN35RZxMPjyOnUxAy4NrfBEDqxOt9Vk68Kbqoz9buvKXyrrqW9GrF8DP tQe0PfRBCiAQlcjBciTjv7XsOtgzegpfIFcS4ZhTv57rQJv2ppiAZReXH3Zhb01Gql R9Kk1idCCyfvcf35/rcYzM8zu3abdkbQ2hwYL7bQ= From: Mark Brown To: Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Mark Brown Subject: [PATCH v2 2/3] selftests: vdso: Use a header file to prototype parse_vdso API Date: Thu, 21 May 2020 21:37:06 +0100 Message-Id: <20200521203707.37304-3-broonie@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200521203707.37304-1-broonie@kernel.org> References: <20200521203707.37304-1-broonie@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Both vdso_test_gettimeofday and vdso_standalone_test_x86 use the library in parse_vdso.c but each separately declares the API it offers which is not ideal. Create a header file with prototypes of the functions and use it in both the library and the tests to ensure that the same prototypes are used throughout. Signed-off-by: Mark Brown --- tools/testing/selftests/vDSO/parse_vdso.c | 24 +------------- tools/testing/selftests/vDSO/parse_vdso.h | 31 +++++++++++++++++++ .../selftests/vDSO/vdso_standalone_test_x86.c | 4 +-- .../selftests/vDSO/vdso_test_gettimeofday.c | 5 +-- 4 files changed, 34 insertions(+), 30 deletions(-) create mode 100644 tools/testing/selftests/vDSO/parse_vdso.h diff --git a/tools/testing/selftests/vDSO/parse_vdso.c b/tools/testing/selftests/vDSO/parse_vdso.c index 1dbb4b87268f..413f75620a35 100644 --- a/tools/testing/selftests/vDSO/parse_vdso.c +++ b/tools/testing/selftests/vDSO/parse_vdso.c @@ -21,29 +21,7 @@ #include #include -/* - * To use this vDSO parser, first call one of the vdso_init_* functions. - * If you've already parsed auxv, then pass the value of AT_SYSINFO_EHDR - * to vdso_init_from_sysinfo_ehdr. Otherwise pass auxv to vdso_init_from_auxv. - * Then call vdso_sym for each symbol you want. For example, to look up - * gettimeofday on x86_64, use: - * - * = vdso_sym("LINUX_2.6", "gettimeofday"); - * or - * = vdso_sym("LINUX_2.6", "__vdso_gettimeofday"); - * - * vdso_sym will return 0 if the symbol doesn't exist or if the init function - * failed or was not called. vdso_sym is a little slow, so its return value - * should be cached. - * - * vdso_sym is threadsafe; the init functions are not. - * - * These are the prototypes: - */ -extern void vdso_init_from_auxv(void *auxv); -extern void vdso_init_from_sysinfo_ehdr(uintptr_t base); -extern void *vdso_sym(const char *version, const char *name); - +#include "parse_vdso.h" /* And here's the code. */ #ifndef ELF_BITS diff --git a/tools/testing/selftests/vDSO/parse_vdso.h b/tools/testing/selftests/vDSO/parse_vdso.h new file mode 100644 index 000000000000..ea4b8635bb0b --- /dev/null +++ b/tools/testing/selftests/vDSO/parse_vdso.h @@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef PARSE_VDSO_H +#define PARSE_VDSO_H + +#include + +/* + * To use this vDSO parser, first call one of the vdso_init_* functions. + * If you've already parsed auxv, then pass the value of AT_SYSINFO_EHDR + * to vdso_init_from_sysinfo_ehdr. Otherwise pass auxv to vdso_init_from_auxv. + * Then call vdso_sym for each symbol you want. For example, to look up + * gettimeofday on x86_64, use: + * + * = vdso_sym("LINUX_2.6", "gettimeofday"); + * or + * = vdso_sym("LINUX_2.6", "__vdso_gettimeofday"); + * + * vdso_sym will return 0 if the symbol doesn't exist or if the init function + * failed or was not called. vdso_sym is a little slow, so its return value + * should be cached. + * + * vdso_sym is threadsafe; the init functions are not. + * + * These are the prototypes: + */ +extern void *vdso_sym(const char *version, const char *name); +extern void vdso_init_from_sysinfo_ehdr(uintptr_t base); +extern void vdso_init_from_auxv(void *auxv); + +#endif diff --git a/tools/testing/selftests/vDSO/vdso_standalone_test_x86.c b/tools/testing/selftests/vDSO/vdso_standalone_test_x86.c index 5ac4b00acfbc..8a44ff973ee1 100644 --- a/tools/testing/selftests/vDSO/vdso_standalone_test_x86.c +++ b/tools/testing/selftests/vDSO/vdso_standalone_test_x86.c @@ -16,9 +16,7 @@ #include #include -extern void *vdso_sym(const char *version, const char *name); -extern void vdso_init_from_sysinfo_ehdr(uintptr_t base); -extern void vdso_init_from_auxv(void *auxv); +#include "parse_vdso.h" /* We need a libc functions... */ int strcmp(const char *a, const char *b) diff --git a/tools/testing/selftests/vDSO/vdso_test_gettimeofday.c b/tools/testing/selftests/vDSO/vdso_test_gettimeofday.c index 511c0dc5e47e..8ccc73ed8240 100644 --- a/tools/testing/selftests/vDSO/vdso_test_gettimeofday.c +++ b/tools/testing/selftests/vDSO/vdso_test_gettimeofday.c @@ -17,10 +17,7 @@ #include #include "../kselftest.h" - -extern void *vdso_sym(const char *version, const char *name); -extern void vdso_init_from_sysinfo_ehdr(uintptr_t base); -extern void vdso_init_from_auxv(void *auxv); +#include "parse_vdso.h" /* * ARM64's vDSO exports its gettimeofday() implementation with a different -- 2.20.1