lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAM9d7cg1pmkMTFEoK7tNxQTmux7obr7KPr-5SPNDrB=S5Xp=vw@mail.gmail.com>
Date:   Wed, 30 Nov 2022 10:52:35 -0800
From:   Namhyung Kim <namhyung@...nel.org>
To:     Ian Rogers <irogers@...gle.com>
Cc:     Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>,
        Arnaldo Carvalho de Melo <acme@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Jiri Olsa <jolsa@...nel.org>,
        Masami Hiramatsu <mhiramat@...nel.org>,
        Steven Rostedt <rostedt@...dmis.org>,
        Adrian Hunter <adrian.hunter@...el.com>,
        Leo Yan <leo.yan@...aro.org>,
        Kan Liang <kan.liang@...ux.intel.com>,
        linux-kernel@...r.kernel.org, linux-perf-users@...r.kernel.org,
        Stephane Eranian <eranian@...gle.com>
Subject: Re: [PATCH v2 2/4] perf util: Add host_is_bigendian to util.h

On Tue, Nov 29, 2022 at 10:30 PM Ian Rogers <irogers@...gle.com> wrote:
>
> Avoid libtraceevent dependency for tep_is_bigendian or trace-event.h
> dependency for bigendian. Add a new host_is_bigendian to util.h, using
> the compiler defined __BYTE_ORDER__ when available.
>
> Signed-off-by: Ian Rogers <irogers@...gle.com>

Acked-by: Namhyung Kim <namhyung@...nel.org>

A nit below...

> ---
[SNIP]
> diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
> index 63cdab0e5314..87d418cb6792 100644
> --- a/tools/perf/util/util.h
> +++ b/tools/perf/util/util.h
> @@ -94,4 +94,23 @@ int do_realloc_array_as_needed(void **arr, size_t *arr_sz, size_t x,
>                 0;                                              \
>         })
>
> +static inline bool host_is_bigendian(void)
> +{
> +#ifdef __BYTE_ORDER__
> +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
> +       return false;
> +#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
> +       return true;
> +#else
> +#error "Unrecognized __BYTE_ORDER__"
> +#endif
> +#else

It'd be nice if we could have a comment at least there's a nested
ifdef condition.  Like below?

#else  /* !__BYTE_ORDER__ */

Thanks,
Namhyung


> +       unsigned char str[] = { 0x1, 0x2, 0x3, 0x4, 0x0, 0x0, 0x0, 0x0};
> +       unsigned int *ptr;
> +
> +       ptr = (unsigned int *)(void *)str;
> +       return *ptr == 0x01020304;
> +#endif
> +}
> +
>  #endif /* __PERF_UTIL_H */
> --
> 2.38.1.584.g0f3c55d4c2-goog
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ