linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: shuah <shuah@kernel.org>
To: Mark Brown <broonie@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
	shuah <shuah@kernel.org>
Subject: Re: [PATCH 2/3] selftests: vdso: Use a header file to prototype parse_vdso API
Date: Tue, 19 May 2020 11:29:10 -0600	[thread overview]
Message-ID: <aaeb0619-68d2-18f8-f72a-b8b37f348b4e@kernel.org> (raw)
In-Reply-To: <20200505174728.46594-3-broonie@kernel.org>

On 5/5/20 11:47 AM, Mark Brown wrote:
> 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 <broonie@kernel.org>
> ---
>   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 <limits.h>
>   #include <elf.h>
>   
> -/*
> - * 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:
> - *
> - *     <some pointer> = vdso_sym("LINUX_2.6", "gettimeofday");
> - * or
> - *     <some pointer> = 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 <stdint.h>
> +
> +/*
> + * 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:
> + *
> + *     <some pointer> = vdso_sym("LINUX_2.6", "gettimeofday");
> + * or
> + *     <some pointer> = 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);
> +

You don't need extern here - this should be in scope?

> +#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 <unistd.h>
>   #include <stdint.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);


thanks,
-- Shuah

  reply	other threads:[~2020-05-19 17:29 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-05 17:47 [PATCH 0/3] selftests: vdso: Add a selftest for vDSO getcpu() Mark Brown
2020-05-05 17:47 ` [PATCH 1/3] selftests: vdso: Rename vdso_test to vdso_test_gettimeofday Mark Brown
2020-05-05 17:47 ` [PATCH 2/3] selftests: vdso: Use a header file to prototype parse_vdso API Mark Brown
2020-05-19 17:29   ` shuah [this message]
2020-05-19 17:42     ` Mark Brown
2020-05-05 17:47 ` [PATCH 3/3] selftests: vdso: Add a selftest for vDSO getcpu() Mark Brown
2020-05-19 17:11   ` shuah
2020-05-19 17:44     ` Mark Brown
2020-05-22 14:55       ` shuah
2020-05-22 15:12         ` Mark Brown
2020-05-22 15:15           ` shuah
2020-05-22 16:15             ` Mark Brown
2020-05-05 18:17 ` [PATCH 0/3] " shuah

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aaeb0619-68d2-18f8-f72a-b8b37f348b4e@kernel.org \
    --to=shuah@kernel.org \
    --cc=broonie@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).