vnode_if.awk (be392b40255efde144eacc0c3d5af66fbbec3243) | vnode_if.awk (aec0fb7b40e4cf877bea663f2d86dd07c3524fe8) |
---|---|
1#!/usr/bin/awk -f 2 3# 4# Copyright (c) 1992, 1993 5# The Regents of the University of California. All rights reserved. 6# 7# Redistribution and use in source and binary forms, with or without 8# modification, are permitted provided that the following conditions --- 25 unchanged lines hidden (view full) --- 34# Script to produce VFS front-end sugar. 35# 36# usage: vnode_if.awk <srcfile> [-c | -h] 37# (where <srcfile> is currently /sys/kern/vnode_if.src) 38# 39 40function usage() 41{ | 1#!/usr/bin/awk -f 2 3# 4# Copyright (c) 1992, 1993 5# The Regents of the University of California. All rights reserved. 6# 7# Redistribution and use in source and binary forms, with or without 8# modification, are permitted provided that the following conditions --- 25 unchanged lines hidden (view full) --- 34# Script to produce VFS front-end sugar. 35# 36# usage: vnode_if.awk <srcfile> [-c | -h] 37# (where <srcfile> is currently /sys/kern/vnode_if.src) 38# 39 40function usage() 41{ |
42 print "usage: vnode_if.awk <srcfile> [-c|-h]"; | 42 print "usage: vnode_if.awk <srcfile> [-c|-h|-p|-q]"; |
43 exit 1; 44} 45 46function die(msg, what) 47{ 48 printf msg "\n", what > "/dev/stderr"; 49 exit 1; 50} 51 52function t_spc(type) 53{ 54 # Append a space if the type is not a pointer 55 return (type ~ /\*$/) ? type : type " "; 56} 57 58# These are just for convenience ... 59function printc(s) {print s > cfile;} 60function printh(s) {print s > hfile;} | 43 exit 1; 44} 45 46function die(msg, what) 47{ 48 printf msg "\n", what > "/dev/stderr"; 49 exit 1; 50} 51 52function t_spc(type) 53{ 54 # Append a space if the type is not a pointer 55 return (type ~ /\*$/) ? type : type " "; 56} 57 58# These are just for convenience ... 59function printc(s) {print s > cfile;} 60function printh(s) {print s > hfile;} |
61function printp(s) {print s > pfile;} 62function printq(s) {print s > qfile;} |
|
61 62function add_debug_code(name, arg, pos) 63{ 64 if (arg == "vpp") 65 arg = "*vpp"; 66 if (lockdata[name, arg, pos] && (lockdata[name, arg, pos] != "-")) { 67 if (arg ~ /^\*/) { 68 printh("\tif ("substr(arg, 2)" != NULL) {"); --- 43 unchanged lines hidden (view full) --- 112 return "VDESC_NO_OFFSET"; 113} 114 115BEGIN{ 116 117# Process the command line 118for (i = 1; i < ARGC; i++) { 119 arg = ARGV[i]; | 63 64function add_debug_code(name, arg, pos) 65{ 66 if (arg == "vpp") 67 arg = "*vpp"; 68 if (lockdata[name, arg, pos] && (lockdata[name, arg, pos] != "-")) { 69 if (arg ~ /^\*/) { 70 printh("\tif ("substr(arg, 2)" != NULL) {"); --- 43 unchanged lines hidden (view full) --- 114 return "VDESC_NO_OFFSET"; 115} 116 117BEGIN{ 118 119# Process the command line 120for (i = 1; i < ARGC; i++) { 121 arg = ARGV[i]; |
120 if (arg !~ /^-[ch]+$/ && arg !~ /\.src$/) | 122 if (arg !~ /^-[chpq]+$/ && arg !~ /\.src$/) |
121 usage(); 122 if (arg ~ /^-.*c/) 123 cfile = "vnode_if.c"; 124 if (arg ~ /^-.*h/) 125 hfile = "vnode_if.h"; | 123 usage(); 124 if (arg ~ /^-.*c/) 125 cfile = "vnode_if.c"; 126 if (arg ~ /^-.*h/) 127 hfile = "vnode_if.h"; |
128 if (arg ~ /^-.*p/) 129 pfile = "vnode_if_newproto.h"; 130 if (arg ~ /^-.*q/) 131 qfile = "vnode_if_typedef.h"; |
|
126 if (arg ~ /\.src$/) 127 srcfile = arg; 128} 129ARGC = 1; 130 | 132 if (arg ~ /\.src$/) 133 srcfile = arg; 134} 135ARGC = 1; 136 |
131if (!cfile && !hfile) | 137if (!cfile && !hfile && !pfile && !qfile) |
132 exit 0; 133 134if (!srcfile) 135 usage(); 136 137common_head = \ 138 "/*\n" \ 139 " * This file is produced automatically.\n" \ 140 " * Do not modify anything in here by hand.\n" \ 141 " *\n" \ 142 " * Created from $FreeBSD$\n" \ 143 " */\n" \ 144 "\n"; 145 | 138 exit 0; 139 140if (!srcfile) 141 usage(); 142 143common_head = \ 144 "/*\n" \ 145 " * This file is produced automatically.\n" \ 146 " * Do not modify anything in here by hand.\n" \ 147 " *\n" \ 148 " * Created from $FreeBSD$\n" \ 149 " */\n" \ 150 "\n"; 151 |
146if (hfile) | 152if (pfile) { 153 printp(common_head) 154 printp("struct vop_vector {") 155 printp("\tstruct vop_vector\t*vop_default;") 156 printp("\tvop_bypass_t\t*vop_bypass;") 157} 158 159if (qfile) { 160 printq(common_head) 161 printq("struct vop_generic_args;") 162 printq("typedef int vop_bypass_t(struct vop_generic_args *);\n") 163} 164 165if (hfile) { |
147 printh(common_head "extern struct vnodeop_desc vop_default_desc;"); | 166 printh(common_head "extern struct vnodeop_desc vop_default_desc;"); |
167 printh("#include \"vnode_if_typedef.h\"") 168 printh("#include \"vnode_if_newproto.h\"") 169} |
|
148 149if (cfile) { 150 printc(common_head \ 151 "#include <sys/param.h>\n" \ 152 "#include <sys/systm.h>\n" \ 153 "#include <sys/vnode.h>\n" \ 154 "\n" \ 155 "struct vnodeop_desc vop_default_desc = {\n" \ --- 101 unchanged lines hidden (view full) --- 257 ctrargs = 6; 258 else 259 ctrargs = numargs; 260 ctrstr = "\tCTR" ctrargs "(KTR_VOP, " ctrstr ")\""; 261 for (i = 0; i < ctrargs; ++i) 262 ctrstr = ctrstr ", " args[i]; 263 ctrstr = ctrstr ");"; 264 | 170 171if (cfile) { 172 printc(common_head \ 173 "#include <sys/param.h>\n" \ 174 "#include <sys/systm.h>\n" \ 175 "#include <sys/vnode.h>\n" \ 176 "\n" \ 177 "struct vnodeop_desc vop_default_desc = {\n" \ --- 101 unchanged lines hidden (view full) --- 279 ctrargs = 6; 280 else 281 ctrargs = numargs; 282 ctrstr = "\tCTR" ctrargs "(KTR_VOP, " ctrstr ")\""; 283 for (i = 0; i < ctrargs; ++i) 284 ctrstr = ctrstr ", " args[i]; 285 ctrstr = ctrstr ");"; 286 |
287 if (pfile) { 288 printp("\t"name"_t\t*"name";") 289 } 290 if (qfile) { 291 printq("struct "name"_args;") 292 printq("typedef int "name"_t(struct "name"_args *);\n") 293 } 294 |
|
265 if (hfile) { 266 # Print out the vop_F_args structure. 267 printh("struct "name"_args {\n\tstruct vnodeop_desc *a_desc;"); 268 for (i = 0; i < numargs; ++i) 269 printh("\t" t_spc(types[i]) "a_" args[i] ";"); 270 printh("};"); 271 272 # Print out extern declaration. --- 8 unchanged lines hidden (view full) --- 281 printh("{\n\tstruct " name "_args a;"); 282 printh("\tint rc;"); 283 printh("\ta.a_desc = VDESC(" name ");"); 284 for (i = 0; i < numargs; ++i) 285 printh("\ta.a_" args[i] " = " args[i] ";"); 286 for (i = 0; i < numargs; ++i) 287 add_debug_code(name, args[i], "Entry"); 288 add_debug_pre(name); | 295 if (hfile) { 296 # Print out the vop_F_args structure. 297 printh("struct "name"_args {\n\tstruct vnodeop_desc *a_desc;"); 298 for (i = 0; i < numargs; ++i) 299 printh("\t" t_spc(types[i]) "a_" args[i] ";"); 300 printh("};"); 301 302 # Print out extern declaration. --- 8 unchanged lines hidden (view full) --- 311 printh("{\n\tstruct " name "_args a;"); 312 printh("\tint rc;"); 313 printh("\ta.a_desc = VDESC(" name ");"); 314 for (i = 0; i < numargs; ++i) 315 printh("\ta.a_" args[i] " = " args[i] ";"); 316 for (i = 0; i < numargs; ++i) 317 add_debug_code(name, args[i], "Entry"); 318 add_debug_pre(name); |
289 printh("\trc = VCALL(" args[0] ", VOFFSET(" name "), &a);"); | 319 printh("\t{") 320 printh("\t\tstruct vop_vector *vop = "args[0]"->v_op;") 321 printh("\t\twhile(vop != NULL && vop->"name" == NULL && vop->vop_bypass == NULL)") 322 printh("\t\t\tvop = vop->vop_default;") 323 printh("\t\tKASSERT(vop != NULL, (\"No "name"(%p...)\", "args[0]"));") 324 printh("\t\tif (vop->"name" != NULL)") 325 printh("\t\t\trc = vop->"name"(&a);") 326 printh("\t\telse") 327 printh("\t\t\trc = vop->vop_bypass((struct vop_generic_args *)&a);") 328 printh("\t}") |
290 printh(ctrstr); 291 printh("if (rc == 0) {"); 292 for (i = 0; i < numargs; ++i) 293 add_debug_code(name, args[i], "OK"); 294 printh("} else {"); 295 for (i = 0; i < numargs; ++i) 296 add_debug_code(name, args[i], "Error"); 297 printh("}"); 298 add_debug_post(name); 299 printh("\treturn (rc);\n}"); | 329 printh(ctrstr); 330 printh("if (rc == 0) {"); 331 for (i = 0; i < numargs; ++i) 332 add_debug_code(name, args[i], "OK"); 333 printh("} else {"); 334 for (i = 0; i < numargs; ++i) 335 add_debug_code(name, args[i], "Error"); 336 printh("}"); 337 add_debug_post(name); 338 printh("\treturn (rc);\n}"); |
300 printh("typedef int "name"_t(struct "name"_args *);\n") | |
301 } 302 303 if (cfile) { 304 # Print out the vop_F_vp_offsets structure. This all depends 305 # on naming conventions and nothing else. 306 printc("static int " name "_vp_offsets[] = {"); 307 # as a side effect, figure out the releflags 308 releflags = ""; --- 12 unchanged lines hidden (view full) --- 321 322 sub(/^\|/, "", releflags); 323 printc("\tVDESC_NO_OFFSET"); 324 printc("};"); 325 326 # Print out the vnodeop_desc structure. 327 printc("struct vnodeop_desc " name "_desc = {"); 328 # offset | 339 } 340 341 if (cfile) { 342 # Print out the vop_F_vp_offsets structure. This all depends 343 # on naming conventions and nothing else. 344 printc("static int " name "_vp_offsets[] = {"); 345 # as a side effect, figure out the releflags 346 releflags = ""; --- 12 unchanged lines hidden (view full) --- 359 360 sub(/^\|/, "", releflags); 361 printc("\tVDESC_NO_OFFSET"); 362 printc("};"); 363 364 # Print out the vnodeop_desc structure. 365 printc("struct vnodeop_desc " name "_desc = {"); 366 # offset |
329 printc("\t0,"); | 367 printc("\toffsetof(struct vop_vector, "name"),"); |
330 # printable name 331 printc("\t\"" name "\","); 332 # flags 333 vppwillrele = ""; 334 for (i = 0; i < numargs; i++) { 335 if (types[i] == "struct vnode **" && \ 336 reles[i] == "WILLRELE") { 337 vppwillrele = "|VDESC_VPP_WILLRELE"; --- 14 unchanged lines hidden (view full) --- 352 printc("\t" find_arg_with_type("struct thread *") ","); 353 # componentname 354 printc("\t" find_arg_with_type("struct componentname *") ","); 355 # transport layer information 356 printc("\tNULL,\n};\n"); 357 } 358} 359 | 368 # printable name 369 printc("\t\"" name "\","); 370 # flags 371 vppwillrele = ""; 372 for (i = 0; i < numargs; i++) { 373 if (types[i] == "struct vnode **" && \ 374 reles[i] == "WILLRELE") { 375 vppwillrele = "|VDESC_VPP_WILLRELE"; --- 14 unchanged lines hidden (view full) --- 390 printc("\t" find_arg_with_type("struct thread *") ","); 391 # componentname 392 printc("\t" find_arg_with_type("struct componentname *") ","); 393 # transport layer information 394 printc("\tNULL,\n};\n"); 395 } 396} 397 |
398if (pfile) 399 printp("};") 400 |
|
360if (hfile) 361 close(hfile); 362if (cfile) 363 close(cfile); | 401if (hfile) 402 close(hfile); 403if (cfile) 404 close(cfile); |
405if (pfile) 406 close(pfile); |
|
364close(srcfile); 365 366exit 0; 367 368} | 407close(srcfile); 408 409exit 0; 410 411} |