diff options
author | ed <ed@FreeBSD.org> | 2011-11-08 15:38:21 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2011-11-08 15:38:21 +0000 |
commit | 85414e79bdef94068b56fcf8ff45df665f2cbfd7 (patch) | |
tree | fc5b9970d963124a81d318347c4ce8c458b60540 /sys | |
parent | ae7b6414d5691d7d65c5b698558cb8a8f1e5b8de (diff) | |
download | FreeBSD-src-85414e79bdef94068b56fcf8ff45df665f2cbfd7.zip FreeBSD-src-85414e79bdef94068b56fcf8ff45df665f2cbfd7.tar.gz |
Make kobj_methods constant.
These structures hold no information that is modified during runtime. By
marking this constant, we see approximately 600 symbols become
read-only (amd64 GENERIC). While there, also mark the kobj_method
structures generated by makeobjops.awk static. They are only referenced
by the kobjop_desc structures within the same file.
Before:
$ ls -l kernel
-rwxr-xr-x 1 ed wheel 15937309 Nov 8 16:29 kernel*
$ size kernel
text data bss dec hex filename
12260854 1358468 2848832 16468154 fb48ba kernel
$ nm kernel | fgrep -c ' r '
8240
After:
$ ls -l kernel
-rwxr-xr-x 1 ed wheel 15922469 Nov 8 16:25 kernel*
$ size kernel
text data bss dec hex filename
12302869 1302660 2848704 16454233 fb1259 kernel
$ nm kernel | fgrep -c ' r '
8838
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/subr_kobj.c | 2 | ||||
-rw-r--r-- | sys/sys/kobj.h | 2 | ||||
-rw-r--r-- | sys/tools/makeobjops.awk | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/sys/kern/subr_kobj.c b/sys/kern/subr_kobj.c index 4ee7182..23ad29f 100644 --- a/sys/kern/subr_kobj.c +++ b/sys/kern/subr_kobj.c @@ -92,7 +92,7 @@ SYSINIT(kobj, SI_SUB_LOCK, SI_ORDER_ANY, kobj_init_mutex, NULL); * desc pointer is NULL, it is guaranteed never to match any read * descriptors. */ -static struct kobj_method null_method = { +static const struct kobj_method null_method = { 0, 0, }; diff --git a/sys/sys/kobj.h b/sys/sys/kobj.h index 3143bea..31d308a 100644 --- a/sys/sys/kobj.h +++ b/sys/sys/kobj.h @@ -34,7 +34,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; diff --git a/sys/tools/makeobjops.awk b/sys/tools/makeobjops.awk index 0406b85..4e3bd04 100644 --- a/sys/tools/makeobjops.awk +++ b/sys/tools/makeobjops.awk @@ -307,7 +307,7 @@ function handle_method (static, doc) line_width, length(prototype))); # Print out the method desc - printc("struct kobj_method " mname "_method_default = {"); + printc("static const struct kobj_method " mname "_method_default = {"); printc("\t&" mname "_desc, (kobjop_t) " default_function); printc("};\n"); |