mremap_flags.sh 573 B

123456789101112131415161718
  1. #!/bin/sh
  2. # SPDX-License-Identifier: LGPL-2.1
  3. if [ $# -ne 1 ] ; then
  4. linux_header_dir=tools/include/uapi/linux
  5. else
  6. linux_header_dir=$1
  7. fi
  8. linux_mman=${linux_header_dir}/mman.h
  9. printf "static const char *mremap_flags[] = {\n"
  10. regex='^[[:space:]]*#[[:space:]]*define[[:space:]]+MREMAP_([[:alnum:]_]+)[[:space:]]+((0x)?[[:xdigit:]]+)[[:space:]]*.*'
  11. grep -E -q $regex ${linux_mman} && \
  12. (grep -E $regex ${linux_mman} | \
  13. sed -r "s/$regex/\2 \1 \1 \1 \2/g" | \
  14. xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef MREMAP_%s\n#define MREMAP_%s %s\n#endif\n")
  15. printf "};\n"