perf beauty mmap_flags: Conditionaly define the mmap flags
authorArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 30 Sep 2020 12:34:20 +0000 (09:34 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 30 Sep 2020 12:34:20 +0000 (09:34 -0300)
So that in older systems we get it in the mmap flags scnprintf routines:

  $ tools/perf/trace/beauty/mmap_flags.sh  | head -9 2> /dev/null
  static const char *mmap_flags[] = {
   [ilog2(0x40) + 1] = "32BIT",
  #ifndef MAP_32BIT
  #define MAP_32BIT 0x40
  #endif
   [ilog2(0x01) + 1] = "SHARED",
  #ifndef MAP_SHARED
  #define MAP_SHARED 0x01
  #endif
  $

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/trace/beauty/mmap_flags.sh

index 5f5eefc..39eb259 100755 (executable)
@@ -21,20 +21,20 @@ printf "static const char *mmap_flags[] = {\n"
 regex='^[[:space:]]*#[[:space:]]*define[[:space:]]+MAP_([[:alnum:]_]+)[[:space:]]+(0x[[:xdigit:]]+)[[:space:]]*.*'
 egrep -q $regex ${arch_mman} && \
 (egrep $regex ${arch_mman} | \
-       sed -r "s/$regex/\2 \1/g"       | \
-       xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n")
+       sed -r "s/$regex/\2 \1 \1 \1 \2/g"      | \
+       xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef MAP_%s\n#define MAP_%s %s\n#endif\n")
 egrep -q $regex ${linux_mman} && \
 (egrep $regex ${linux_mman} | \
        egrep -vw 'MAP_(UNINITIALIZED|TYPE|SHARED_VALIDATE)' | \
-       sed -r "s/$regex/\2 \1/g"       | \
-       xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n")
+       sed -r "s/$regex/\2 \1 \1 \1 \2/g" | \
+       xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef MAP_%s\n#define MAP_%s %s\n#endif\n")
 ([ ! -f ${arch_mman} ] || egrep -q '#[[:space:]]*include[[:space:]]+<uapi/asm-generic/mman.*' ${arch_mman}) &&
 (egrep $regex ${header_dir}/mman-common.h | \
        egrep -vw 'MAP_(UNINITIALIZED|TYPE|SHARED_VALIDATE)' | \
-       sed -r "s/$regex/\2 \1/g"       | \
-       xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n")
+       sed -r "s/$regex/\2 \1 \1 \1 \2/g"      | \
+       xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef MAP_%s\n#define MAP_%s %s\n#endif\n")
 ([ ! -f ${arch_mman} ] || egrep -q '#[[:space:]]*include[[:space:]]+<uapi/asm-generic/mman.h>.*' ${arch_mman}) &&
 (egrep $regex ${header_dir}/mman.h | \
-       sed -r "s/$regex/\2 \1/g"       | \
-       xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n")
+       sed -r "s/$regex/\2 \1 \1 \1 \2/g"      | \
+       xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef MAP_%s\n#define MAP_%s %s\n#endif\n")
 printf "};\n"