Changeset View
Changeset View
Standalone View
Standalone View
sys/tools/vnode_if.awk
Show First 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | if (lockdata[name, arg, pos] && (lockdata[name, arg, pos] != "-")) { | ||||
else if (lockdata[name, arg, pos] == "E") | else if (lockdata[name, arg, pos] == "E") | ||||
printc(ind"ASSERT_VOP_ELOCKED(" star "a->a_"arg", \""uname"\");"); | printc(ind"ASSERT_VOP_ELOCKED(" star "a->a_"arg", \""uname"\");"); | ||||
else if (0) { | else if (0) { | ||||
# XXX More checks! | # XXX More checks! | ||||
} | } | ||||
} | } | ||||
} | } | ||||
function add_debugpre(name) | |||||
{ | |||||
if (lockdata[name, "debugpre"]) { | |||||
printc("#ifdef DEBUG_VFS_LOCKS"); | |||||
printc("\t"lockdata[name, "debugpre"]"(a);"); | |||||
printc("#endif"); | |||||
} | |||||
} | |||||
function add_debugpost(name) | |||||
{ | |||||
if (lockdata[name, "debugpost"]) { | |||||
printc("#ifdef DEBUG_VFS_LOCKS"); | |||||
printc("\t"lockdata[name, "debugpost"]"(a, rc);"); | |||||
printc("#endif"); | |||||
} | |||||
} | |||||
function add_pre(name) | function add_pre(name) | ||||
{ | { | ||||
if (lockdata[name, "pre"]) { | if (lockdata[name, "pre"]) { | ||||
printc("\t"lockdata[name, "pre"]"(a);"); | printc("\t"lockdata[name, "pre"]"(a);"); | ||||
} | } | ||||
} | } | ||||
function add_post(name) | function add_post(name) | ||||
{ | { | ||||
if (lockdata[name, "post"]) { | if (lockdata[name, "post"]) { | ||||
printc("\t"lockdata[name, "post"]"(a, rc);"); | printc("\t"lockdata[name, "post"]"(a, rc);"); | ||||
} | } | ||||
} | } | ||||
function can_inline(name) | |||||
{ | |||||
if (lockdata[name, "pre"]) | |||||
return 0; | |||||
if (lockdata[name, "post"]) | |||||
return 0; | |||||
return 1; | |||||
} | |||||
function find_arg_with_type (type) | function find_arg_with_type (type) | ||||
{ | { | ||||
for (jj = 0; jj < numargs; jj++) { | for (jj = 0; jj < numargs; jj++) { | ||||
if (types[jj] == type) { | if (types[jj] == type) { | ||||
return "VOPARG_OFFSETOF(struct " \ | return "VOPARG_OFFSETOF(struct " \ | ||||
name "_args,a_" args[jj] ")"; | name "_args,a_" args[jj] ")"; | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | if ($1 ~ /^%%/) { | ||||
lockdata["vop_" $2, $3, "Entry"] = $4; | lockdata["vop_" $2, $3, "Entry"] = $4; | ||||
lockdata["vop_" $2, $3, "OK"] = $5; | lockdata["vop_" $2, $3, "OK"] = $5; | ||||
lockdata["vop_" $2, $3, "Error"] = $6; | lockdata["vop_" $2, $3, "Error"] = $6; | ||||
continue; | continue; | ||||
} | } | ||||
if ($1 ~ /^%!/) { | if ($1 ~ /^%!/) { | ||||
if (NF != 4 || | if (NF != 4 || | ||||
($3 != "pre" && $3 != "post")) { | ($3 != "pre" && $3 != "post" && | ||||
$3 != "debugpre" && $3 != "debugpost")) { | |||||
die("Invalid %s construction", "%!"); | die("Invalid %s construction", "%!"); | ||||
continue; | continue; | ||||
} | } | ||||
lockdata["vop_" $2, $3] = $4; | lockdata["vop_" $2, $3] = $4; | ||||
continue; | continue; | ||||
} | } | ||||
if ($1 ~ /^#/) | if ($1 ~ /^#/) | ||||
continue; | continue; | ||||
▲ Show 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | for (i = 0; i < numargs; ++i) { | ||||
(i < numargs - 1 ? "," : ")")); | (i < numargs - 1 ? "," : ")")); | ||||
} | } | ||||
printh("{"); | printh("{"); | ||||
printh("\tstruct " name "_args a;"); | printh("\tstruct " name "_args a;"); | ||||
printh(""); | printh(""); | ||||
printh("\ta.a_gen.a_desc = &" name "_desc;"); | printh("\ta.a_gen.a_desc = &" name "_desc;"); | ||||
for (i = 0; i < numargs; ++i) | for (i = 0; i < numargs; ++i) | ||||
printh("\ta.a_" args[i] " = " args[i] ";"); | printh("\ta.a_" args[i] " = " args[i] ";"); | ||||
if (can_inline(name)) { | |||||
printh("\n#if !defined(DEBUG_VFS_LOCKS) && !defined(INVARIANTS) && !defined(KTR)"); | |||||
printh("\tif (!SDT_PROBES_ENABLED())"); | |||||
printh("\t\treturn (" args[0]"->v_op->"name"(&a));"); | |||||
# printh("\t\treturn (vop->"name"(a));") | |||||
printh("\telse"); | |||||
printh("\t\treturn (" uname "_APV("args[0]"->v_op, &a));"); | |||||
printh("#else"); | |||||
} | |||||
printh("\treturn (" uname "_APV("args[0]"->v_op, &a));"); | printh("\treturn (" uname "_APV("args[0]"->v_op, &a));"); | ||||
if (can_inline(name)) | |||||
printh("#endif"); | |||||
printh("}"); | printh("}"); | ||||
printh(""); | printh(""); | ||||
} | } | ||||
if (cfile) { | if (cfile) { | ||||
funcarr[name] = 1; | funcarr[name] = 1; | ||||
# Print out the vop_F_vp_offsets structure. This all depends | # Print out the vop_F_vp_offsets structure. This all depends | ||||
Show All 31 Lines | if (cfile) { | ||||
printc("\nint\n" uname "_APV(struct vop_vector *vop, struct " name "_args *a)"); | printc("\nint\n" uname "_APV(struct vop_vector *vop, struct " name "_args *a)"); | ||||
printc("{"); | printc("{"); | ||||
printc("\tint rc;"); | printc("\tint rc;"); | ||||
printc(""); | printc(""); | ||||
printc("\tVNASSERT(a->a_gen.a_desc == &" name "_desc, a->a_" args[0]","); | printc("\tVNASSERT(a->a_gen.a_desc == &" name "_desc, a->a_" args[0]","); | ||||
printc("\t (\"Wrong a_desc in " name "(%p, %p)\", a->a_" args[0]", a));"); | printc("\t (\"Wrong a_desc in " name "(%p, %p)\", a->a_" args[0]", a));"); | ||||
printc("\tVNASSERT(vop != NULL, a->a_" args[0]", (\"No "name"(%p, %p)\", a->a_" args[0]", a));") | printc("\tVNASSERT(vop != NULL, a->a_" args[0]", (\"No "name"(%p, %p)\", a->a_" args[0]", a));") | ||||
printc("\tKTR_START" ctrstr); | printc("\tKTR_START" ctrstr); | ||||
add_debugpre(name); | |||||
add_pre(name); | add_pre(name); | ||||
for (i = 0; i < numargs; ++i) | for (i = 0; i < numargs; ++i) | ||||
add_debug_code(name, args[i], "Entry", "\t"); | add_debug_code(name, args[i], "Entry", "\t"); | ||||
printc("\tif (!SDT_PROBES_ENABLED()) {"); | printc("\tif (!SDT_PROBES_ENABLED()) {"); | ||||
printc("\t\trc = vop->"name"(a);") | printc("\t\trc = vop->"name"(a);") | ||||
printc("\t} else {") | printc("\t} else {") | ||||
printc("\t\tSDT_PROBE2(vfs, vop, " name ", entry, a->a_" args[0] ", a);"); | printc("\t\tSDT_PROBE2(vfs, vop, " name ", entry, a->a_" args[0] ", a);"); | ||||
printc("\t\trc = vop->"name"(a);") | printc("\t\trc = vop->"name"(a);") | ||||
printc("\t\tSDT_PROBE3(vfs, vop, " name ", return, a->a_" args[0] ", a, rc);"); | printc("\t\tSDT_PROBE3(vfs, vop, " name ", return, a->a_" args[0] ", a, rc);"); | ||||
printc("\t}") | printc("\t}") | ||||
printc("\tif (rc == 0) {"); | printc("\tif (rc == 0) {"); | ||||
for (i = 0; i < numargs; ++i) | for (i = 0; i < numargs; ++i) | ||||
add_debug_code(name, args[i], "OK", "\t\t"); | add_debug_code(name, args[i], "OK", "\t\t"); | ||||
printc("\t} else {"); | printc("\t} else {"); | ||||
for (i = 0; i < numargs; ++i) | for (i = 0; i < numargs; ++i) | ||||
add_debug_code(name, args[i], "Error", "\t\t"); | add_debug_code(name, args[i], "Error", "\t\t"); | ||||
printc("\t}"); | printc("\t}"); | ||||
add_post(name); | add_post(name); | ||||
add_debugpost(name); | |||||
printc("\tKTR_STOP" ctrstr); | printc("\tKTR_STOP" ctrstr); | ||||
printc("\treturn (rc);"); | printc("\treturn (rc);"); | ||||
printc("}\n"); | printc("}\n"); | ||||
# Print out the vnodeop_desc structure. | # Print out the vnodeop_desc structure. | ||||
printc("struct vnodeop_desc " name "_desc = {"); | printc("struct vnodeop_desc " name "_desc = {"); | ||||
# printable name | # printable name | ||||
printc("\t\"" name "\","); | printc("\t\"" name "\","); | ||||
▲ Show 20 Lines • Show All 86 Lines • Show Last 20 Lines |