From f41325db5f16640212574a03b9a34e5ed4a884ca Mon Sep 17 00:00:00 2001 From: Peter Wemm Date: Wed, 13 Jun 2001 10:58:39 +0000 Subject: 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. 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_ and __stop_). Thanks to Richard Henderson 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 --- sys/dev/fb/fb.c | 15 +++++++++------ sys/dev/fb/fbreg.h | 1 - 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'sys/dev/fb') diff --git a/sys/dev/fb/fb.c b/sys/dev/fb/fb.c index 3d927617369c7..056988dc02b5b 100644 --- a/sys/dev/fb/fb.c +++ b/sys/dev/fb/fb.c @@ -39,12 +39,15 @@ #include #include #include +#include #include #include #include +SET_DECLARE(videodriver_set, const video_driver_t); + /* local arrays */ /* @@ -160,8 +163,8 @@ vid_register(video_adapter_t *adp) adp->va_index = index; adp->va_token = NULL; - list = (const video_driver_t **)videodriver_set.ls_items; - while ((p = *list++) != NULL) { + SET_FOREACH(list, videodriver_set) { + p = *list; if (strcmp(p->name, adp->va_name) == 0) { adapter[index] = adp; vidsw[index] = p->vidsw; @@ -192,8 +195,8 @@ video_switch_t const video_driver_t **list; const video_driver_t *p; - list = (const video_driver_t **)videodriver_set.ls_items; - while ((p = *list++) != NULL) { + SET_FOREACH(list, videodriver_set) { + p = *list; if (strcmp(p->name, name) == 0) return p->vidsw; } @@ -281,8 +284,8 @@ vid_configure(int flags) const video_driver_t **list; const video_driver_t *p; - list = (const video_driver_t **)videodriver_set.ls_items; - while ((p = *list++) != NULL) { + SET_FOREACH(list, videodriver_set) { + p = *list; if (p->configure != NULL) (*p->configure)(flags); } diff --git a/sys/dev/fb/fbreg.h b/sys/dev/fb/fbreg.h index 7070f19d52f43..ba6c0e1322c34 100644 --- a/sys/dev/fb/fbreg.h +++ b/sys/dev/fb/fbreg.h @@ -148,7 +148,6 @@ typedef struct video_driver { /* global variables */ extern struct video_switch **vidsw; -extern struct linker_set videodriver_set; /* functions for the video card driver */ int vid_register(video_adapter_t *adp); -- cgit v1.3