Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/sys Add KERNHIST_INITIALIZER(NAME, BUF) macro to be used ...



details:   https://anonhg.NetBSD.org/src/rev/48205c30231c
branches:  trunk
changeset: 327339:48205c30231c
user:      matt <matt%NetBSD.org@localhost>
date:      Wed Mar 05 05:32:41 2014 +0000

description:
Add KERNHIST_INITIALIZER(NAME,BUF) macro to be used with KERNHIST_DEFINE to
static initialize a kern_history.  After boot, it still needs to linked
to list of kern_history's and a KERNHIST_LINK_STATIC(NAME) macro was added
to do that.

diffstat:

 sys/sys/kernhist.h |  17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 deletions(-)

diffs (38 lines):

diff -r 697ed69bb228 -r 48205c30231c sys/sys/kernhist.h
--- a/sys/sys/kernhist.h        Wed Mar 05 03:51:25 2014 +0000
+++ b/sys/sys/kernhist.h        Wed Mar 05 05:32:41 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kernhist.h,v 1.7 2013/02/19 22:54:03 skrll Exp $       */
+/*     $NetBSD: kernhist.h,v 1.8 2014/03/05 05:32:41 matt Exp $        */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -122,6 +122,19 @@
        LIST_INSERT_HEAD(&kern_histories, &(NAME), list); \
 } while (/*CONSTCOND*/ 0)
 
+#define KERNHIST_INITIALIZER(NAME,BUF) \
+{ \
+       .name = __STRING(NAME), \
+       .namelen = sizeof(__STRING(NAME)) - 1, \
+       .n = sizeof(BUF) / sizeof(struct kern_history_ent), \
+       .f = 0, \
+       .e = (struct kern_history_ent *) (BUF), \
+       /* BUF will inititalized to zeroes by being in .bss */ \
+}
+
+#define KERNHIST_LINK_STATIC(NAME) \
+       LIST_INSERT_HEAD(&kern_histories, &(NAME), list)
+
 #define KERNHIST_INIT_STATIC(NAME,BUF) \
 do { \
        (NAME).name = __STRING(NAME); \
@@ -130,7 +143,7 @@
        (NAME).f = 0; \
        (NAME).e = (struct kern_history_ent *) (BUF); \
        memset((NAME).e, 0, sizeof(struct kern_history_ent) * (NAME).n); \
-       LIST_INSERT_HEAD(&kern_histories, &(NAME), list); \
+       KERNHIST_LINK_STATIC(NAME); \
 } while (/*CONSTCOND*/ 0)
 
 #ifndef KERNHIST_DELAY



Home | Main Index | Thread Index | Old Index