1 Star 0 Fork 0

aosp-riscv/platform-external-minijail

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
gen_syscalls.sh 1.56 KB
一键复制 编辑 原始数据 按行查看 历史
#!/bin/sh
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Generates a header file with a system call table made up of "name",
# syscall_nr entries by including the build target <asm/unistd.h> and
# emitting the list of defines. Use of the compiler is needed to
# dereference the actual provider of syscall definitions.
# E.g., asm/unistd_32.h or asm/unistd_64.h, etc.
set -e
if [ $# -ne 1 ] && [ $# -ne 2 ]; then
echo "Usage: $(basename "$0") OUTFILE"
echo "Usage: $(basename "$0") INFILE OUTFILE"
exit 1
fi
BUILD="${CC} -dD ${SRC:-.}/gen_syscalls.c -E"
GEN_DEPS=1
if [ $# -eq 2 ]; then
BUILD="cat $1"
GEN_DEPS=0
shift
fi
OUTFILE="$1"
if [ ${GEN_DEPS} -eq 1 ]; then
# Generate a dependency file which helps the build tool to see when it
# should regenerate ${OUTFILE}.
${BUILD} -M -MF "${OUTFILE}.d"
fi
# sed expression which extracts system calls that are
# defined via asm/unistd.h. It converts them from:
# #define __NR_read foo
# to:
# #ifdef __NR_read
# { "read", __NR_read },
# #endif
SED_MULTILINE='s/#define __(ARM_)?(NR_)([[:lower:]0-9_]*) (.*)$/#ifdef __\1\2\3\
{ "\1\3", __\1\2\3 },\
#endif/g p;'
cat <<-EOF > "${OUTFILE}"
/* GENERATED BY MAKEFILE */
#include <stddef.h>
#include "gen_syscalls-inl.h"
#include "libsyscalls.h"
const struct syscall_entry syscall_table[] = {
$(${BUILD} | sed -Ene "${SED_MULTILINE}")
{ NULL, -1 },
};
const size_t syscall_table_size =
sizeof(syscall_table) / sizeof(syscall_table[0]);
EOF
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/aosp-riscv/platform-external-minijail.git
git@gitee.com:aosp-riscv/platform-external-minijail.git
aosp-riscv
platform-external-minijail
platform-external-minijail
riscv64-android-12.0.0_dev

搜索帮助