• Wang Nan's avatar
    tools include: Add uapi mman.h for each architecture · f3539c12
    Wang Nan authored
    Some mmap related macros have different values for different
    architectures. This patch introduces uapi mman.h for each
    architectures.
    
    Three headers are cloned from kernel include to tools/include:
    
     tools/include/uapi/asm-generic/mman-common.h
     tools/include/uapi/asm-generic/mman.h
     tools/include/uapi/linux/mman.h
    
    The main part of this patch is generated by following script:
    
     macros=`cat $0 | awk 'V==1 {print}; /^# start macro list/ {V=1}'`
     for arch in `ls tools/arch`
     do
       [ -d tools/arch/$arch/include/uapi/asm ] || mkdir -p tools/arch/$arch/include/uapi/asm
       src=arch/$arch/include/uapi/asm/mman.h
       target=tools/arch/$arch/include/uapi/asm/mman.h
       guard="TOOLS_ARCH_"`echo $arch | awk '{print toupper($0)}'`_UAPI_ASM_MMAN_FIX_H
       echo '#ifndef '$guard > $target
       echo '#define '$guard >> $target
    
       [ -f $src ] &&
       for m in $macros
       do
         if grep '#define[ \t]*'$m $src > /dev/null 2>&1
         then
           grep -h '#define[ \t]*'$m $src | sed 's/[ \t]*\/\*.*$//g' >> $target
         fi
       done
    
       if [ -f $src ]
       then
          grep '#include <asm-generic' $src >> $target
       else
          echo "#include <asm-generic/mman.h>" >> $target
       fi
       echo '#endif' >> $target
       echo "$target"
     done
    
     exit 0
     # Following macros are extracted from:
     # tools/perf/trace/beauty/mmap.c
     #
     # start macro list
     MADV_DODUMP
     MADV_DOFORK
     MADV_DONTDUMP
     MADV_DONTFORK
     MADV_DONTNEED
     MADV_HUGEPAGE
     MADV_HWPOISON
     MADV_MERGEABLE
     MADV_NOHUGEPAGE
     MADV_NORMAL
     MADV_RANDOM
     MADV_REMOVE
     MADV_SEQUENTIAL
     MADV_SOFT_OFFLINE
     MADV_UNMERGEABLE
     MADV_WILLNEED
     MAP_32BIT
     MAP_ANONYMOUS
     MAP_DENYWRITE
     MAP_EXECUTABLE
     MAP_FILE
     MAP_FIXED
     MAP_GROWSDOWN
     MAP_HUGETLB
     MAP_LOCKED
     MAP_NONBLOCK
     MAP_NORESERVE
     MAP_POPULATE
     MAP_PRIVATE
     MAP_SHARED
     MAP_STACK
     MAP_UNINITIALIZED
     MREMAP_FIXED
     MREMAP_MAYMOVE
     PROT_EXEC
     PROT_GROWSDOWN
     PROT_GROWSUP
     PROT_NONE
     PROT_READ
     PROT_SEM
     PROT_WRITE
    Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
    Cc: Zefan Li <lizefan@huawei.com>
    Cc: pi3orama@163.com
    Link: http://lkml.kernel.org/r/1473684871-209320-2-git-send-email-wangnan0@huawei.com
    [ Added new files to tools/perf/MANIFEST to fix the detached tarball build, add mman.h for ARC ]
    Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    f3539c12
mman-common.h 2.87 KB