Back to home page

OSCL-LXR

 
 

    


0001 #!/bin/sh
0002 # SPDX-License-Identifier: LGPL-2.1
0003 
0004 if [ $# -ne 3 ] ; then
0005         [ $# -eq 1 ] && hostarch=$1 || hostarch=`uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/`
0006         linux_header_dir=tools/include/uapi/linux
0007         header_dir=tools/include/uapi/asm-generic
0008         arch_header_dir=tools/arch/${hostarch}/include/uapi/asm
0009 else
0010         linux_header_dir=$1
0011         header_dir=$2
0012         arch_header_dir=$3
0013 fi
0014 
0015 linux_mman=${linux_header_dir}/mman.h
0016 arch_mman=${arch_header_dir}/mman.h
0017 
0018 # those in egrep -vw are flags, we want just the bits
0019 
0020 printf "static const char *mmap_flags[] = {\n"
0021 regex='^[[:space:]]*#[[:space:]]*define[[:space:]]+MAP_([[:alnum:]_]+)[[:space:]]+(0x[[:xdigit:]]+)[[:space:]]*.*'
0022 egrep -q $regex ${arch_mman} && \
0023 (egrep $regex ${arch_mman} | \
0024         sed -r "s/$regex/\2 \1 \1 \1 \2/g"      | \
0025         xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef MAP_%s\n#define MAP_%s %s\n#endif\n")
0026 egrep -q $regex ${linux_mman} && \
0027 (egrep $regex ${linux_mman} | \
0028         egrep -vw 'MAP_(UNINITIALIZED|TYPE|SHARED_VALIDATE)' | \
0029         sed -r "s/$regex/\2 \1 \1 \1 \2/g" | \
0030         xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef MAP_%s\n#define MAP_%s %s\n#endif\n")
0031 ([ ! -f ${arch_mman} ] || egrep -q '#[[:space:]]*include[[:space:]]+.*uapi/asm-generic/mman.*' ${arch_mman}) &&
0032 (egrep $regex ${header_dir}/mman-common.h | \
0033         egrep -vw 'MAP_(UNINITIALIZED|TYPE|SHARED_VALIDATE)' | \
0034         sed -r "s/$regex/\2 \1 \1 \1 \2/g"      | \
0035         xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef MAP_%s\n#define MAP_%s %s\n#endif\n")
0036 ([ ! -f ${arch_mman} ] || egrep -q '#[[:space:]]*include[[:space:]]+.*uapi/asm-generic/mman.h>.*' ${arch_mman}) &&
0037 (egrep $regex ${header_dir}/mman.h | \
0038         sed -r "s/$regex/\2 \1 \1 \1 \2/g"      | \
0039         xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef MAP_%s\n#define MAP_%s %s\n#endif\n")
0040 printf "};\n"