Messages in this thread Patch in this message | | | Date | Mon, 5 Dec 2022 10:16:39 -0300 | From | Arnaldo Carvalho de Melo <> | Subject | Re: [PATCH v2 2/4] perf util: Add host_is_bigendian to util.h |
| |
Em Wed, Nov 30, 2022 at 10:52:35AM -0800, Namhyung Kim escreveu: > On Tue, Nov 29, 2022 at 10:30 PM Ian Rogers <irogers@google.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@google.com> > > Acked-by: Namhyung Kim <namhyung@kernel.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__ */
Reasonable, added it and applied the first two patches in this series, with your Acked-by, thanks.
- Arnaldo
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 87d418cb67929576..a06c54ab85ee4506 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -104,7 +104,7 @@ static inline bool host_is_bigendian(void) #else #error "Unrecognized __BYTE_ORDER__" #endif -#else +#else /* !__BYTE_ORDER__ */ unsigned char str[] = { 0x1, 0x2, 0x3, 0x4, 0x0, 0x0, 0x0, 0x0}; unsigned int *ptr;
| |