mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-08-21 16:31:14 +02:00

"[" is part of the shell builtin test (and a synonym for it), not a link to the external command /usr/bin/test. Using the "test" is simpler because it avoids a lot of "[]". Suggested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Yanteng Si <siyanteng@loongson.cn> Acked-by: Huacai Chen <chenhuacai@kernel.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Ian Rogers <irogers@google.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: loongarch@lists.linux.dev Cc: loongson-kernel@lists.loongnix.cn Link: https://lore.kernel.org/r/c50bc0a92dce0ff0fa6504c1a52fb53e2ac007bf.1692962043.git.siyanteng@loongson.cn Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
44 lines
1.8 KiB
Bash
Executable File
44 lines
1.8 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 grep -E -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:]]*.*'
|
|
test -f ${arch_mman} && \
|
|
grep -E -q $regex ${arch_mman} && \
|
|
(grep -E $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")
|
|
grep -E -q $regex ${linux_mman} && \
|
|
(grep -E $regex ${linux_mman} | \
|
|
grep -E -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")
|
|
( ! test -f ${arch_mman} || \
|
|
grep -E -q '#[[:space:]]*include[[:space:]]+.*uapi/asm-generic/mman.*' ${arch_mman}) &&
|
|
(grep -E $regex ${header_dir}/mman-common.h | \
|
|
grep -E -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")
|
|
( ! test -f ${arch_mman} || \
|
|
grep -E -q '#[[:space:]]*include[[:space:]]+.*uapi/asm-generic/mman.h>.*' ${arch_mman}) &&
|
|
(grep -E $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"
|