1 Star 0 Fork 2

公子文彬 / fakeroot

forked from openKylin / fakeroot 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
wrapawk_macosx 3.69 KB
一键复制 编辑 原始数据 按行查看 历史
邓好 提交于 2022-11-10 15:44 . merge upstream 1.30.1
#Saluton Emacson! Bonvolu elekti -*- mode: awk; -*-. Dankon.
BEGIN{
headerfile="wrapped.h";
deffile="wrapdef.h";
structfile="wrapstruct.h";
tmpffile="wraptmpf.h";
FS=";";
WARNING="/* Automatically generated file. Do not edit. Edit wrapawk_macosx/wrapfunc.inp. */";
print WARNING > headerfile;
print "#ifndef WRAPPED_H" > headerfile;
print "#define WRAPPED_H" > headerfile;
print "#define MY_GLUE2(a,b) a ## b" > headerfile;
print "#define MY_DEF(a) MY_GLUE2(my_,a)" > headerfile;
print WARNING > deffile;
print "#ifndef WRAPDEF_H" > deffile;
print "#define WRAPDEF_H" > deffile;
print WARNING > tmpffile;
print "#ifndef WRAPTMPF_H" > tmpffile;
print "#define WRAPTMPF_H" > tmpffile;
print WARNING > structfile;
print "#ifndef WRAPSTRUCT_H" > structfile;
print "#define WRAPSTRUCT_H" > structfile;
print "typedef struct interpose_s {" > structfile;
print " void *new_func;" > structfile;
print " void *orig_func;" > structfile;
print "} interpose_t;" > structfile;
print "#define INTERPOSE(newf,oldf) \\" > structfile;
print " __attribute__((used)) static const interpose_t MY_GLUE2(_interpose_,oldf) \\" > structfile;
print " __attribute__((section(\"__DATA,__interpose\"))) = {(void *)newf, (void *)oldf}" > structfile;
print "" > structfile;
}
/\/\*/{
}
/^(\#)/{
print $0 > structfile;
print $0 > tmpffile;
print $0 > deffile;
print $0 > headerfile;
}
/^[^\/].*;.*;.*/{
name=$1;
ret=$2;
argtype=$3;
argname=$4;
MACRO=$5;
argtype_def=$6
if(!argtype_def) {
argtype_def = argtype
}
if(MACRO){
print "extern " ret " MY_DEF(" name ")" argtype " __attribute__((visibility(\"hidden\")));" > headerfile;
print "INTERPOSE(MY_DEF(" name "_RAW)," name "_RAW);" > structfile;
print "#undef " name > deffile
print "#define " name " MY_DEF(" name "_RAW)" > deffile
print "extern " ret, name, argtype_def ";" > tmpffile;
print "static __inline__ " ret " NEXT_" MACRO "_NOARG " argtype " __attribute__((always_inline));" > tmpffile;
print "static __inline__ " ret " NEXT_" MACRO "_NOARG " argtype " {" > tmpffile;
print " return " name, argname ";" > tmpffile;
print "}" > tmpffile;
print "" > tmpffile;
} else {
print "extern " ret " my_" name, argtype_def " __attribute__((visibility(\"hidden\")));" > headerfile;
print "#undef " name > structfile;
print "INTERPOSE(my_" name "," name ");" > structfile;
print "#define " name " my_" name > structfile
print "#define " name " my_" name > deffile
print "extern " ret, name, argtype_def ";" > tmpffile;
if(argname){
print "static __inline__ " ret " next_" name, argtype " __attribute__((always_inline));" > tmpffile;
print "static __inline__ " ret " next_" name, argtype " {" > tmpffile;
print " return " name, argname ";" > tmpffile;
print "}" > tmpffile;
}
print "" > tmpffile;
}
}
/^ *$/{
print > structfile;
print > headerfile;
print > deffile;
print > tmpffile;
}
END{
print "" > structfile;
print "struct next_wrap_st next_wrap[]= {" > structfile;
print " {NULL, NULL}," > structfile;
print "};" > structfile;
print "#endif" > structfile;
print "#endif" > tmpffile;
print "#endif" > deffile;
print "#endif" > headerfile;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/xiewei/fakeroot.git
git@gitee.com:xiewei/fakeroot.git
xiewei
fakeroot
fakeroot
openkylin/yangtze

搜索帮助

344bd9b3 5694891 D2dac590 5694891