c5e6bc2335
Current script to generate mmap flags and prot checks headers from the uapi/asm-generic directory but it might come from a different directory in some environment. So change the pattern to accept it. Signed-off-by: Namhyung Kim <namhyung@kernel.org> Acked-by: Ian Rogers <irogers@google.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lore.kernel.org/lkml/20201023020628.346257-1-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
41 lines
1.7 KiB
Bash
Executable File
41 lines
1.7 KiB
Bash
Executable File
#!/bin/sh
|
|
# SPDX-License-Identifier: LGPL-2.1
|
|
|
|
if [ $# -ne 3 ] ; then
|
|
[ $# -eq 1 ] && hostarch=$1 || hostarch=`uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/`
|
|
linux_header_dir=tools/include/uapi/linux
|
|
header_dir=tools/include/uapi/asm-generic
|
|
arch_header_dir=tools/arch/${hostarch}/include/uapi/asm
|
|
else
|
|
linux_header_dir=$1
|
|
header_dir=$2
|
|
arch_header_dir=$3
|
|
fi
|
|
|
|
linux_mman=${linux_header_dir}/mman.h
|
|
arch_mman=${arch_header_dir}/mman.h
|
|
|
|
# those in egrep -vw are flags, we want just the bits
|
|
|
|
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 \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 \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 \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 \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"
|