From: "Emilio G. Cota" <cota@braap.org>
To: Richard Henderson <rth@twiddle.net>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v4 1/7] util: add cacheinfo
Date: Wed, 7 Jun 2017 18:11:56 -0400 [thread overview]
Message-ID: <20170607221156.GA25936@flamenco> (raw)
In-Reply-To: <20170607155536.1193-2-rth@twiddle.net>
On Wed, Jun 07, 2017 at 08:55:30 -0700, Richard Henderson wrote:
(snip)
> +#elif defined(__APPLE__) \
> + || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
> +# include <sys/sysctl.h>
> +# if defined(__APPLE__)
> +# define SYSCTL_CACHELINE_NAME "hw.cachelinesize"
> +# else
> +# define SYSCTL_CACHELINE_NAME "machdep.cacheline_size"
> +# endif
> +
> +static void sys_cache_info(void)
> +{
> + /* There's only a single sysctl for both I/D cache line sizes. */
> + size_t len = sizeof(qemu_icache_linesize);
> + if (!sysctlbyname(SYSCTL_CACHELINE_NAME, &qemu_icache_linesize,
> + &len, NULL, 0)) {
> + qemu_dcache_linesize = qemu_icache_linesize;
> + }
> +}
This doesn't work on the MacOS (Darwin 16.6.0) I have access to.
If we do
long size; // <-- type here matters!
size_t len = sizeof(size);
sysctlbyname(..., &size, &len, ...);
then size == 64.
However, if instead of 'long size' we have 'int size' (as in the patch),
then 'size == 1' yet sysctlbyname still returns 0. (!)
This is why I was using an intermediate long in my previous patch,
although obviously a comment there would have been appropriate.
FWIW, if we query what length sysctlbyname expects for this param (by
calling sysctlbyname(NAME, NULL, &size, NULL, 0), we get len == 8;
I presume on both 32 and 64-bit systems passing a long will work
OK here.
E.
next prev parent reply other threads:[~2017-06-07 22:12 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-07 15:55 [Qemu-devel] [PATCH v4 0/7] tcg: allocate TB structs preceding translate Richard Henderson
2017-06-07 15:55 ` [Qemu-devel] [PATCH v4 1/7] util: add cacheinfo Richard Henderson
2017-06-07 22:11 ` Emilio G. Cota [this message]
2017-06-08 16:42 ` Richard Henderson
2017-06-07 15:55 ` [Qemu-devel] [PATCH v4 2/7] tcg: allocate TB structs before the corresponding translated code Richard Henderson
2017-06-07 15:55 ` [Qemu-devel] [PATCH v4 3/7] tcg/aarch64: Use ADR in tcg_out_movi Richard Henderson
2017-06-07 15:55 ` [Qemu-devel] [PATCH v4 4/7] target/arm: Use indirect branch for goto_tb Richard Henderson
2017-06-07 15:55 ` [Qemu-devel] [PATCH v4 5/7] target/arm: Remove limit on code buffer size Richard Henderson
2017-06-07 15:55 ` [Qemu-devel] [PATCH v4 6/7] target/arm: Try pc-relative addresses for movi Richard Henderson
2017-06-07 15:55 ` [Qemu-devel] [PATCH v4 7/7] target/arm: Use ldr (literal) for goto_tb Richard Henderson
2017-06-07 19:46 ` [Qemu-devel] [PATCH v4 0/7] tcg: allocate TB structs preceding translate no-reply
2017-06-07 23:30 ` Emilio G. Cota
2017-06-08 16:44 ` Richard Henderson
2017-06-08 17:44 ` Emilio G. Cota
2017-06-08 20:17 ` Richard Henderson
2017-06-08 0:02 ` no-reply
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=20170607221156.GA25936@flamenco \
--to=cota@braap.org \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/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).