From 950412b4f54181f54cae91e9400952b6e8f14012 Mon Sep 17 00:00:00 2001 From: jdolecek Date: Mon, 22 Jan 2001 09:52:21 +0000 Subject: [PATCH] when generating individual *_desc, generate also proper offsets so that then don't need to be patched at runtime add new define VNODE_OPS_COUNT (to vnode_if.h) so that the number is known at compile-time make stuff const, it now can be --- sys/kern/vnode_if.sh | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/sys/kern/vnode_if.sh b/sys/kern/vnode_if.sh index bed22d3bcf36..86207898ea37 100644 --- a/sys/kern/vnode_if.sh +++ b/sys/kern/vnode_if.sh @@ -33,7 +33,7 @@ copyright="\ * SUCH DAMAGE. */ " -SCRIPT_ID='$NetBSD: vnode_if.sh,v 1.27 2001/01/19 12:22:56 martin Exp $' +SCRIPT_ID='$NetBSD: vnode_if.sh,v 1.28 2001/01/22 09:52:21 jdolecek Exp $' # Script to produce VFS front-end sugar. # @@ -170,7 +170,7 @@ echo '#include "opt_vnode_op_noinline.h"' echo '#endif' echo '#endif /* _KERNEL */' echo ' -extern struct vnodeop_desc vop_default_desc; +extern const struct vnodeop_desc vop_default_desc; ' # Body stuff @@ -179,12 +179,12 @@ sed -e "$sed_prep" $src | $awk "$toupper"' function doit() { # Declare arg struct, descriptor. printf("\nstruct %s_args {\n", name); - printf("\tstruct vnodeop_desc * a_desc;\n"); + printf("\tconst struct vnodeop_desc * a_desc;\n"); for (i=0; i\n"); @@ -242,6 +244,8 @@ END { doit(); name="vop_bwrite"; doit(); + + printf("\n#define VNODE_OPS_COUNT\t%d\n", vops); } '"$awk_parser" | sed -e "$anal_retentive" @@ -316,9 +320,9 @@ function doit() { print "\tVDESC_NO_OFFSET"; print "};"; # Define F_desc - printf("struct vnodeop_desc %s_desc = {\n", name); + printf("const struct vnodeop_desc %s_desc = {\n", name); # offset - printf ("\t0,\n"); + printf ("\t%d,\n", vop_offset++); # printable name printf ("\t\"%s\",\n", name); # flags @@ -376,10 +380,9 @@ function doit() { printf("#endif\n"); } BEGIN { - arg0special=""; -} -END { printf("\n/* Special cases: */\n"); + # start from 1 (vop_default is at 0) + vop_offset=1; argc=1; argdir[0]="IN"; argtype[0]="struct buf *"; @@ -390,6 +393,9 @@ END { doit(); name="vop_bwrite"; doit(); + printf("\n/* End of special cases */\n"); + + arg0special=""; } '"$awk_parser" | sed -e "$anal_retentive" @@ -400,7 +406,7 @@ echo ' # Add the vfs_op_descs array to the C file. # Begin stuff echo ' -struct vnodeop_desc * const vfs_op_descs[] = { +const struct vnodeop_desc * const vfs_op_descs[] = { &vop_default_desc, /* MUST BE FIRST */ &vop_strategy_desc, /* XXX: SPECIAL CASE */ &vop_bwrite_desc, /* XXX: SPECIAL CASE */