From: Sascha Wildner Date: Thu, 22 Mar 2012 18:35:13 +0000 (+0100) Subject: kernel/kobj: Put the default kobj_method inside the kobjop_desc struct. X-Git-Tag: v3.4.0rc~1159^2 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/0e0fd600f4c75d4dc8a6d605ba9edc960d4f205e kernel/kobj: Put the default kobj_method inside the kobjop_desc struct. Also, make kobj_methods constant. See FreeBSD's r227343 and r227384 for more information. This change reduces the size of a LINT64 kernel by 18KB and our source by 7 lines! Taken-from: FreeBSD --- diff --git a/sys/kern/subr_kobj.c b/sys/kern/subr_kobj.c index 8041f3cb69..0461d93219 100644 --- a/sys/kern/subr_kobj.c +++ b/sys/kern/subr_kobj.c @@ -24,7 +24,6 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/kern/subr_kobj.c,v 1.4.2.1 2001/02/02 19:49:13 cg Exp $ - * $DragonFly: src/sys/kern/subr_kobj.c,v 1.9 2007/04/30 07:18:54 dillon Exp $ */ #include @@ -62,7 +61,7 @@ SYSINIT(kobj, SI_BOOT1_LOCK, SI_ORDER_ANY, kobj_init_token, NULL); * desc pointer is NULL, it is guaranteed never to match any real * descriptors. */ -static struct kobj_method null_method = { +static const struct kobj_method null_method = { 0, 0, }; @@ -170,7 +169,7 @@ kobj_lookup_method(kobj_class_t cls, ce = kobj_lookup_method_mi(cls, desc); if (!ce) - ce = desc->deflt; + ce = &desc->deflt; *cep = ce; return(ce); } diff --git a/sys/sys/kobj.h b/sys/sys/kobj.h index e20f427785..d85f09ba95 100644 --- a/sys/sys/kobj.h +++ b/sys/sys/kobj.h @@ -24,7 +24,6 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/sys/kobj.h,v 1.8 2003/09/22 21:32:49 peter Exp $ - * $DragonFly: src/sys/sys/kobj.h,v 1.11 2007/10/03 18:58:20 dillon Exp $ */ #ifndef _SYS_KOBJ_H_ @@ -43,7 +42,7 @@ */ typedef struct kobj *kobj_t; typedef struct kobj_class *kobj_class_t; -typedef struct kobj_method kobj_method_t; +typedef const struct kobj_method kobj_method_t; typedef int (*kobjop_t)(void); typedef struct kobj_ops *kobj_ops_t; typedef struct kobjop_desc *kobjop_desc_t; @@ -95,7 +94,7 @@ struct kobj_ops { struct kobjop_desc { unsigned int id; /* unique ID */ - kobj_method_t *deflt; /* default implementation */ + kobj_method_t deflt; /* default implementation */ }; /* diff --git a/sys/tools/makeobjops.awk b/sys/tools/makeobjops.awk index 2a0a46e164..ac8632c8ab 100644 --- a/sys/tools/makeobjops.awk +++ b/sys/tools/makeobjops.awk @@ -38,7 +38,6 @@ # From src/sys/kern/makeobjops.pl,v 1.8 2001/11/16 02:02:42 joe Exp # # $FreeBSD: src/sys/tools/makeobjops.awk,v 1.3 2003/10/16 13:29:26 dfr Exp $ -# $DragonFly: src/sys/tools/makeobjops.awk,v 1.5 2005/08/29 16:03:31 hsu Exp $ # # Script to produce kobj front-end sugar. @@ -294,12 +293,8 @@ function handle_method (static) line_width, length(prototype))); # Print out the method desc - printc("struct kobj_method " mname "_method_default = {"); - printc("\t&" mname "_desc, (kobjop_t) " default); - printc("};\n"); - printc("struct kobjop_desc " mname "_desc = {"); - printc("\t0, &" mname "_method_default"); + printc("\t0, { &" mname "_desc, (kobjop_t)" default " }"); printc("};\n"); # Print out the method itself