Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F142675858
D39916.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D39916.diff
View Options
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c
--- a/sys/kern/init_main.c
+++ b/sys/kern/init_main.c
@@ -216,6 +216,18 @@
}
#endif
+static int
+compare_sysinit(const void *a, const void *b)
+{
+ const struct sysinit *s1 = *(const struct sysinit * const *)a;
+ const struct sysinit *s2 = *(const struct sysinit * const *)b;
+ /* Sort by subsystem first, then by order. */
+ int cmp = (int)s1->subsystem - (int)s2->subsystem;
+ if (cmp == 0)
+ cmp = (int)s1->order - (int)s2->order;
+ return cmp;
+}
+
/*
* System startup; initialize the world, create process 0, mount root
* filesystem, and fork to create init and pagedaemon. Most of the
@@ -232,10 +244,8 @@
{
struct sysinit **sipp; /* system initialization*/
- struct sysinit **xipp; /* interior loop of sort*/
- struct sysinit *save; /* bubble*/
- int last;
+ enum sysinit_sub_id last;
#if defined(VERBOSE_SYSINIT)
int verbose;
#endif
@@ -252,22 +262,13 @@
restart:
/*
- * Perform a bubble sort of the system initialization objects by
- * their subsystem (primary key) and order (secondary key).
+ * Sort the system initialization objects by their subsystem (primary key)
+ * and order (secondary key).
*/
- TSENTER2("bubblesort");
- for (sipp = sysinit; sipp < sysinit_end; sipp++) {
- for (xipp = sipp + 1; xipp < sysinit_end; xipp++) {
- if ((*sipp)->subsystem < (*xipp)->subsystem ||
- ((*sipp)->subsystem == (*xipp)->subsystem &&
- (*sipp)->order <= (*xipp)->order))
- continue; /* skip*/
- save = *sipp;
- *sipp = *xipp;
- *xipp = save;
- }
- }
- TSEXIT2("bubblesort");
+ TSENTER2("qsort");
+ qsort(sysinit, sysinit_end - sysinit, sizeof(struct sysinit *),
+ compare_sysinit);
+ TSEXIT2("qsort");
last = SI_SUB_COPYRIGHT;
#if defined(VERBOSE_SYSINIT)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jan 23, 3:28 AM (13 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
27873487
Default Alt Text
D39916.diff (1 KB)
Attached To
Mode
D39916: mi_startup: sort sysinit array using qsort instead of bubble sort
Attached
Detach File
Event Timeline
Log In to Comment