diff options
author | peter <peter@FreeBSD.org> | 2001-06-13 10:58:39 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 2001-06-13 10:58:39 +0000 |
commit | f10fa038c14063eaf2da32ed734e644e5f569694 (patch) | |
tree | 88aef8097c80f09c2f725d61b6da4d433a595a61 /sys/dev/kbd/kbd.c | |
parent | 2514663dd721b9ac234d35a4dac65dfc457ff6bc (diff) | |
download | FreeBSD-src-f10fa038c14063eaf2da32ed734e644e5f569694.zip FreeBSD-src-f10fa038c14063eaf2da32ed734e644e5f569694.tar.gz |
With this commit, I hereby pronounce gensetdefs past its use-by date.
Replace the a.out emulation of 'struct linker_set' with something
a little more flexible. <sys/linker_set.h> now provides macros for
accessing elements and completely hides the implementation.
The linker_set.h macros have been on the back burner in various
forms since 1998 and has ideas and code from Mike Smith (SET_FOREACH()),
John Polstra (ELF clue) and myself (cleaned up API and the conversion
of the rest of the kernel to use it).
The macros declare a strongly typed set. They return elements with the
type that you declare the set with, rather than a generic void *.
For ELF, we use the magic ld symbols (__start_<setname> and
__stop_<setname>). Thanks to Richard Henderson <rth@redhat.com> for the
trick about how to force ld to provide them for kld's.
For a.out, we use the old linker_set struct.
NOTE: the item lists are no longer null terminated. This is why
the code impact is high in certain areas.
The runtime linker has a new method to find the linker set
boundaries depending on which backend format is in use.
linker sets are still module/kld unfriendly and should never be used
for anything that may be modular one day.
Reviewed by: eivind
Diffstat (limited to 'sys/dev/kbd/kbd.c')
-rw-r--r-- | sys/dev/kbd/kbd.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/sys/dev/kbd/kbd.c b/sys/dev/kbd/kbd.c index 8ebba7e..ce55b65 100644 --- a/sys/dev/kbd/kbd.c +++ b/sys/dev/kbd/kbd.c @@ -54,6 +54,8 @@ typedef struct genkbd_softc { static SLIST_HEAD(, keyboard_driver) keyboard_drivers = SLIST_HEAD_INITIALIZER(keyboard_drivers); +SET_DECLARE(kbddriver_set, const keyboard_driver_t); + /* local arrays */ /* @@ -199,8 +201,8 @@ kbd_register(keyboard_t *kbd) return index; } } - list = (const keyboard_driver_t **)kbddriver_set.ls_items; - while ((p = *list++) != NULL) { + SET_FOREACH(list, kbddriver_set) { + p = *list; if (strcmp(p->name, kbd->kb_name) == 0) { keyboard[index] = kbd; kbdsw[index] = p->kbdsw; @@ -254,8 +256,8 @@ keyboard_switch_t if (strcmp(p->name, driver) == 0) return p->kbdsw; } - list = (const keyboard_driver_t **)kbddriver_set.ls_items; - while ((p = *list++) != NULL) { + SET_FOREACH(list, kbddriver_set) { + p = *list; if (strcmp(p->name, driver) == 0) return p->kbdsw; } @@ -393,8 +395,8 @@ kbd_configure(int flags) if (p->configure != NULL) (*p->configure)(flags); } - list = (const keyboard_driver_t **)kbddriver_set.ls_items; - while ((p = *list++) != NULL) { + SET_FOREACH(list, kbddriver_set) { + p = *list; if (p->configure != NULL) (*p->configure)(flags); } |