public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] automatic initcalls
@ 2002-07-27 20:22 Roman Zippel
  2002-07-28  3:31 ` Rusty Russell
  0 siblings, 1 reply; 36+ messages in thread
From: Roman Zippel @ 2002-07-27 20:22 UTC (permalink / raw)
  To: linux-kernel; +Cc: Rusty Russell, Kai Germaschewski

[-- Attachment #1: Type: text/plain, Size: 617 bytes --]

Hi,

This patch is based on Rusty's patch, I did these changes to get it
working:
- I only look at modules which contain an initcall
- I only order initcalls of level 6 and 7
This makes the problem managable, so that everything what can be built
as module is also correctly initialized when compiled in. Other
initcalls still have to be ordered manually, but these are the minority
and so easier to manage.
I had to push up a few initcall levels and fix a bug in the IDE driver,
but otherwise it seems to work fine.
I also included my version of KBUILD_MODNAME (IMO my version should be a
bit faster :) ).

bye, Roman

[-- Attachment #2: initcall.diff --]
[-- Type: text/plain, Size: 10214 bytes --]

Index: Makefile
===================================================================
RCS file: /usr/src/cvsroot/linux-2.5/Makefile,v
retrieving revision 1.1.1.30
diff -u -p -r1.1.1.30 Makefile
--- Makefile	27 Jul 2002 12:34:13 -0000	1.1.1.30
+++ Makefile	27 Jul 2002 13:19:29 -0000
@@ -268,6 +268,7 @@ cmd_link_vmlinux = $(LD) $(LDFLAGS) $(LD
 		$(DRIVERS) \
 		$(NETWORKS) \
 		--end-group \
+		init/generated-initcalls.o \
 		-o vmlinux
 
 #	set -e makes the rule exit immediately on error
@@ -284,9 +285,25 @@ define rule_link_vmlinux
 	$(NM) vmlinux | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | sort > System.map
 endef
 
-vmlinux: $(vmlinux-objs) FORCE
+init/generated-initcalls.c: .allinit.defs
+	set -e; echo '#include <linux/init.h>' > $@; \
+	sed -n < $< "s,^T ,,p" | sort > .defined.all; \
+	sed -n < $< "s,^U ,,p" | sort > .undefined.all; \
+	join -o "1.2 2.2" .defined.all .undefined.all | sort -u | tsort > .sorted.all; \
+	cut -d ' ' -f 3 < .allinit.defs | sort -u | grep -v -f .sorted.all > .other.all; \
+	cat .other.all >> .sorted.all; \
+	while read obj; do objdump -t $$obj | awk '/F \.initcall\.test/ { print "extern int " $$6 "(void);" }'; done < .other.all >> $@; \
+	echo 'initcall_t generated_initcalls[] = {' >> $@; \
+	while read obj; do objdump -t $$obj | awk '/F \.initcall\.test/ { print $$6 "," }'; done < .other.all >> $@; \
+	echo '0 };' >> $@
+
+vmlinux: $(vmlinux-objs) init/generated-initcalls.o FORCE
 	$(call if_changed_rule,link_vmlinux)
 
+.allinit.defs: $(CORE_FILES) $(LIBS) $(DRIVERS) $(NETWORKS)
+	rm -f $@; \
+	for s in $(dir $^); do ls -ld $$s; awk "{ print \$$1 \" \" \$$2 \" $$s\" \$$3 }" < $${s}.all_defs >> $@; done
+
 #	The actual objects are generated when descending, 
 #	make sure no implicit rule kicks in
 
@@ -586,6 +603,7 @@ defconfig:
 
 #	files removed with 'make clean'
 CLEAN_FILES += \
+	init/generated-initcalls.c .allinit.defs .defined.all .undefined.all .other.all .sorted.all \
 	include/linux/compile.h \
 	vmlinux System.map \
 	drivers/char/consolemap_deftbl.c drivers/video/promcon_tbl.c \
@@ -647,7 +665,7 @@ clean:	archclean
 	@echo 'Cleaning up'
 	@find . -name SCCS -prune -o -name BitKeeper -prune -o \
 		\( -name \*.[oas] -o -name core -o -name .\*.cmd -o \
-		-name .\*.tmp -o -name .\*.d \) -type f -print \
+		-name .\*.tmp -o -name .\*.d -o -name .\*[._]defs \) -type f -print \
 		| grep -v lxdialog/ | xargs rm -f
 	@rm -f $(CLEAN_FILES)
 	@$(MAKE) -f Documentation/DocBook/Makefile clean
Index: Rules.make
===================================================================
RCS file: /usr/src/cvsroot/linux-2.5/Rules.make,v
retrieving revision 1.1.1.17
diff -u -p -r1.1.1.17 Rules.make
--- Rules.make	6 Jul 2002 00:33:37 -0000	1.1.1.17
+++ Rules.make	27 Jul 2002 18:56:39 -0000
@@ -105,9 +105,16 @@ multi-objs-m := $(foreach m, $(multi-use
 subdir-obj-y := $(foreach o,$(obj-y),$(if $(filter-out $(o),$(notdir $(o))),$(o)))
 
 # Replace multi-part objects by their individual parts, look at local dir only
-real-objs-y := $(foreach m, $(filter-out $(subdir-obj-y), $(obj-y)), $(if $($(m:.o=-objs)),$($(m:.o=-objs)),$(m))) $(EXTRA_TARGETS)
+mod-objs-y := $(filter-out $(subdir-obj-y), $(obj-y))
+real-objs-y := $(foreach m, $(mod-objs-y), $(if $($(m:.o=-objs)),$($(m:.o=-objs)),$(m))) $(EXTRA_TARGETS)
 real-objs-m := $(foreach m, $(obj-m), $(if $($(m:.o=-objs)),$($(m:.o=-objs)),$(m)))
 
+modnames := $(foreach m, $(sort $(mod-objs-y) $(objs-m)), $(if $($(m:.o=-objs)),$(foreach mm,$($(m:.o=-objs)),.$(mm).$(m))))
+
+modname = $(*F)
+
+$(multi-objs-y) $(multi-objs-m) : modname = $(patsubst .$@.%,%,$(filter .$@.%,$(modnames)))
+
 # Only build module versions for files which are selected to be built
 export-objs := $(filter $(export-objs),$(real-objs-y) $(real-objs-m))
 
@@ -168,6 +175,7 @@ $(addprefix $(MODVERDIR)/,$(export-objs:
 c_flags = -Wp,-MD,$(depfile) $(CFLAGS) $(NOSTDINC_FLAGS) \
 	  $(modkern_cflags) $(EXTRA_CFLAGS) $(CFLAGS_$(*F).o) \
 	  -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) \
+	  -DKBUILD_MODNAME=$(subst $(comma),_,$(subst -,_,$(modname:.o=))) \
 	  $(export_flags) 
 
 # Our objects only depend on modversions.h, not on the individual .ver
@@ -248,7 +256,7 @@ endif
 #	The echo suppresses the "Nothing to be done for first_rule"
 first_rule: $(if $(KBUILD_BUILTIN),$(O_TARGET) $(L_TARGET) $(EXTRA_TARGETS)) \
 	    $(if $(KBUILD_MODULES),$(obj-m)) \
-	    sub_dirs
+	    sub_dirs .all_defs
 	@echo -n
 
 # Compile C sources (.c)
@@ -269,6 +277,7 @@ $(export-objs:.o=.lst): export_flags   :
 c_flags = -Wp,-MD,$(depfile) $(CFLAGS) $(NOSTDINC_FLAGS) \
 	  $(modkern_cflags) $(EXTRA_CFLAGS) $(CFLAGS_$(*F).o) \
 	  -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) \
+	  -DKBUILD_MODNAME=$(subst $(comma),_,$(subst -,_,$(modname:.o=))) \
 	  $(export_flags) 
 
 quiet_cmd_cc_s_c = CC     $(echo_target)
@@ -294,6 +303,17 @@ cmd_cc_lst_c     = $(CC) $(c_flags) -g -
 
 %.lst: %.c FORCE
 	$(call if_changed_dep,cc_lst_c)
+
+.%.defs: %.o
+	if [ -n "$$(objdump -h $< | egrep '^[ ]*[0-9]+ \.initcall\.test')" ]; then \
+	nm $< | sed -n "s,^[0-9a-f ]*\([TU].*\),\1 $<,p" > $@; \
+	else > $@; fi
+
+$(subdir-y:%=%/.all_defs): sub_dirs
+
+.all_defs: $(mod-objs-y:%.o=.%.defs) $(subdir-y:%=%/.all_defs)
+	cat $(mod-objs-y:%.o=.%.defs) /dev/null > $@; \
+	for s in $(subdir-y); do awk "{ print \$$1 \" \" \$$2 \" $$s/\" \$$3 }" < $$s/.all_defs; done >> $@
 
 # Compile assembler sources (.S)
 # ---------------------------------------------------------------------------
Index: drivers/ide/main.c
===================================================================
RCS file: /usr/src/cvsroot/linux-2.5/drivers/ide/main.c,v
retrieving revision 1.1.1.7
diff -u -p -r1.1.1.7 main.c
--- drivers/ide/main.c	27 Jul 2002 12:40:01 -0000	1.1.1.7
+++ drivers/ide/main.c	27 Jul 2002 13:19:30 -0000
@@ -1401,12 +1401,6 @@ static int __init ata_module_init(void)
 	/*
 	 * Initialize all device type driver modules.
 	 */
-#ifdef CONFIG_BLK_DEV_IDEDISK
-	idedisk_init();
-#endif
-#ifdef CONFIG_BLK_DEV_IDECD
-	ide_cdrom_init();
-#endif
 #ifdef CONFIG_BLK_DEV_IDETAPE
 	idetape_init();
 #endif
Index: fs/dnotify.c
===================================================================
RCS file: /usr/src/cvsroot/linux-2.5/fs/dnotify.c,v
retrieving revision 1.1.1.5
diff -u -p -r1.1.1.5 dnotify.c
--- fs/dnotify.c	27 Jul 2002 12:34:15 -0000	1.1.1.5
+++ fs/dnotify.c	27 Jul 2002 13:19:30 -0000
@@ -155,4 +155,4 @@ static int __init dnotify_init(void)
 	return 0;
 }
 
-module_init(dnotify_init)
+fs_initcall(dnotify_init);
Index: fs/fcntl.c
===================================================================
RCS file: /usr/src/cvsroot/linux-2.5/fs/fcntl.c,v
retrieving revision 1.1.1.8
diff -u -p -r1.1.1.8 fcntl.c
--- fs/fcntl.c	27 Jul 2002 12:34:14 -0000	1.1.1.8
+++ fs/fcntl.c	27 Jul 2002 13:19:30 -0000
@@ -568,4 +568,4 @@ static int __init fasync_init(void)
 	return 0;
 }
 
-module_init(fasync_init)
+fs_initcall(fasync_init);
Index: fs/locks.c
===================================================================
RCS file: /usr/src/cvsroot/linux-2.5/fs/locks.c,v
retrieving revision 1.1.1.9
diff -u -p -r1.1.1.9 locks.c
--- fs/locks.c	27 Jul 2002 12:34:14 -0000	1.1.1.9
+++ fs/locks.c	27 Jul 2002 13:19:30 -0000
@@ -1936,4 +1936,4 @@ static int __init filelock_init(void)
 	return 0;
 }
 
-module_init(filelock_init)
+fs_initcall(filelock_init);
Index: include/linux/init.h
===================================================================
RCS file: /usr/src/cvsroot/linux-2.5/include/linux/init.h,v
retrieving revision 1.1.1.6
diff -u -p -r1.1.1.6 init.h
--- include/linux/init.h	13 Jun 2002 00:22:57 -0000	1.1.1.6
+++ include/linux/init.h	27 Jul 2002 13:19:30 -0000
@@ -65,10 +65,16 @@ extern initcall_t __initcall_start, __in
 #define arch_initcall(fn)		__define_initcall("3",fn)
 #define subsys_initcall(fn)		__define_initcall("4",fn)
 #define fs_initcall(fn)			__define_initcall("5",fn)
-#define device_initcall(fn)		__define_initcall("6",fn)
-#define late_initcall(fn)		__define_initcall("7",fn)
 
-#define __initcall(fn) device_initcall(fn)
+#define device_initcall(fn)		__initcall(fn)
+#define late_initcall(fn)		__initcall(fn)
+
+#define __CAT3(a,b,c) a##b##c
+#define _CAT3(a,b,c) __CAT3(a,b,c)
+
+#define __initcall(fn)								\
+  int __attribute__((__section__ (".initcall.test"))) _CAT3(fn,_,KBUILD_MODNAME)(void) \
+       { return fn(); }
 
 #define __exitcall(fn)								\
 	static exitcall_t __exitcall_##fn __exit_call = fn
Index: init/main.c
===================================================================
RCS file: /usr/src/cvsroot/linux-2.5/init/main.c,v
retrieving revision 1.1.1.17
diff -u -p -r1.1.1.17 main.c
--- init/main.c	27 Jul 2002 12:34:42 -0000	1.1.1.17
+++ init/main.c	27 Jul 2002 13:19:31 -0000
@@ -464,6 +464,8 @@ asmlinkage void __init start_kernel(void
 
 struct task_struct *child_reaper = &init_task;
 
+extern initcall_t generated_initcalls[];
+
 static void __init do_initcalls(void)
 {
 	initcall_t *call;
@@ -473,6 +475,9 @@ static void __init do_initcalls(void)
 		(*call)();
 		call++;
 	} while (call < &__initcall_end);
+
+	for (call = generated_initcalls; *call; call++)
+		(*call)();
 
 	/* Make sure there is no pending stuff from the initcall sequence */
 	flush_scheduled_tasks();
Index: kernel/sched.c
===================================================================
RCS file: /usr/src/cvsroot/linux-2.5/kernel/sched.c,v
retrieving revision 1.1.1.22
diff -u -p -r1.1.1.22 sched.c
--- kernel/sched.c	27 Jul 2002 12:34:42 -0000	1.1.1.22
+++ kernel/sched.c	27 Jul 2002 15:50:14 -0000
@@ -1910,7 +1910,7 @@ int __init migration_init(void)
 	return 0;
 }
 
-__initcall(migration_init);
+fs_initcall(migration_init);
 #endif
 
 extern void init_timervecs(void);
Index: kernel/softirq.c
===================================================================
RCS file: /usr/src/cvsroot/linux-2.5/kernel/softirq.c,v
retrieving revision 1.1.1.12
diff -u -p -r1.1.1.12 softirq.c
--- kernel/softirq.c	27 Jul 2002 12:34:43 -0000	1.1.1.12
+++ kernel/softirq.c	27 Jul 2002 15:50:14 -0000
@@ -417,4 +417,4 @@ static __init int spawn_ksoftirqd(void)
 	return 0;
 }
 
-__initcall(spawn_ksoftirqd);
+fs_initcall(spawn_ksoftirqd);

^ permalink raw reply	[flat|nested] 36+ messages in thread
* [PATCH] automatic module_init ordering
@ 2002-08-01 23:52 Roman Zippel
  2002-08-02  3:19 ` Kai Germaschewski
  0 siblings, 1 reply; 36+ messages in thread
From: Roman Zippel @ 2002-08-01 23:52 UTC (permalink / raw)
  To: Kai Germaschewski, linux-kernel, Rusty Russell

Hi,

This is latest version of the automatic module_init ordering patch.
IMO the patch is almost ready. A bit annoying problem is that
-DKBUILD_MODNAME=unix becomes -DKBUILD_MODNAME=1. An undef helps
of course, but I'm not sure whether we should put it on the command
line or in the source.
This patch depends on Kai's KBUILD_MODNAME patch.
Kai, do you see any possible kbuild problem left? I hope I found
everything. :)

bye, Roman

diff -Nur linux-2.5/Makefile linux-initcall/Makefile
--- linux-2.5/Makefile	Fri Aug  2 00:40:57 2002
+++ linux-initcall/Makefile	Thu Aug  1 23:28:32 2002
@@ -268,6 +268,7 @@
 		$(DRIVERS) \
 		$(NETWORKS) \
 		--end-group \
+		init/generated-initcalls.o \
 		-o vmlinux
 
 #	set -e makes the rule exit immediately on error
@@ -284,9 +285,15 @@
 	$(NM) vmlinux | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | sort > System.map
 endef
 
-vmlinux: $(vmlinux-objs) FORCE
+vmlinux: $(vmlinux-objs) init/generated-initcalls.o FORCE
 	$(call if_changed_rule,link_vmlinux)
 
+init/generated-initcalls.c: .allbuiltin_mods
+	$(CONFIG_SHELL) -e scripts/build-initcalls $< $@
+
+.allbuiltin_mods: $(CORE_FILES) $(LIBS) $(DRIVERS) $(NETWORKS)
+	for s in $(dir $^); do sed "s,^,$$s," < $${s}.builtin_mods; done > $@
+
 #	The actual objects are generated when descending, 
 #	make sure no implicit rule kicks in
 
@@ -586,6 +593,7 @@
 
 #	files removed with 'make clean'
 CLEAN_FILES += \
+	init/generated-initcalls.c .allbuiltin_mods \
 	include/linux/compile.h \
 	vmlinux System.map \
 	drivers/char/consolemap_deftbl.c drivers/video/promcon_tbl.c \
@@ -647,7 +655,7 @@
 	@echo 'Cleaning up'
 	@find . -name SCCS -prune -o -name BitKeeper -prune -o \
 		\( -name \*.[oas] -o -name core -o -name .\*.cmd -o \
-		-name .\*.tmp -o -name .\*.d \) -type f -print \
+		-name .\*.tmp -o -name .\*.d -o -name .builtin_mods \) -type f -print \
 		| grep -v lxdialog/ | xargs rm -f
 	@rm -f $(CLEAN_FILES)
 	@$(MAKE) -f Documentation/DocBook/Makefile clean
diff -Nur linux-2.5/Rules.make linux-initcall/Rules.make
--- linux-2.5/Rules.make	Fri Aug  2 00:42:14 2002
+++ linux-initcall/Rules.make	Thu Aug  1 21:21:40 2002
@@ -109,7 +109,8 @@
 subdir-obj-y := $(foreach o,$(obj-y),$(if $(filter-out $(o),$(notdir $(o))),$(o)))
 
 # Replace multi-part objects by their individual parts, look at local dir only
-real-objs-y := $(foreach m, $(filter-out $(subdir-obj-y), $(obj-y)), $(if $($(m:.o=-objs)),$($(m:.o=-objs)),$(m))) $(EXTRA_TARGETS)
+local-objs-y := $(filter-out $(subdir-obj-y), $(obj-y))
+real-objs-y := $(foreach m, $(local-objs-y), $(if $($(m:.o=-objs)),$($(m:.o=-objs)),$(m))) $(EXTRA_TARGETS)
 real-objs-m := $(foreach m, $(obj-m), $(if $($(m:.o=-objs)),$($(m:.o=-objs)),$(m)))
 
 # Only build module versions for files which are selected to be built
@@ -268,7 +269,7 @@
 #	The echo suppresses the "Nothing to be done for first_rule"
 first_rule: $(if $(KBUILD_BUILTIN),$(O_TARGET) $(L_TARGET) $(EXTRA_TARGETS)) \
 	    $(if $(KBUILD_MODULES),$(obj-m)) \
-	    sub_dirs
+	    sub_dirs .builtin_mods
 	@echo -n
 
 # Compile C sources (.c)
@@ -318,6 +319,23 @@
 
 %.lst: %.c FORCE
 	$(call if_changed_dep,cc_lst_c)
+
+quiet_cmd_gen_builtin_mod = '  Generating $(echo_target)'
+define cmd_gen_builtin_mod
+	for o in $(sort $(local-objs-y)); do \
+	  if [ -n "$$($(OBJDUMP) -h $$o | grep .initcall.module)" ]; then \
+	    echo $$o; \
+	  fi \
+	done > $@; \
+	for s in $(sort $(subdir-y)); do \
+	  sed "s,^,$$s/," < $$s/.builtin_mods; \
+	done >> $@
+endef
+
+$(subdir-y:%=%/.builtin_mods): sub_dirs
+
+.builtin_mods: $(local-objs-y) $(subdir-y:%=%/.builtin_mods)
+	$(call if_changed,gen_builtin_mod)
 
 # Compile assembler sources (.S)
 # ---------------------------------------------------------------------------
diff -Nur linux-2.5/drivers/ide/main.c linux-initcall/drivers/ide/main.c
--- linux-2.5/drivers/ide/main.c	Fri Aug  2 00:40:57 2002
+++ linux-initcall/drivers/ide/main.c	Wed Jul 31 00:51:58 2002
@@ -1397,23 +1397,6 @@
 	}
 # endif
 #endif
-
-	/*
-	 * Initialize all device type driver modules.
-	 */
-#ifdef CONFIG_BLK_DEV_IDEDISK
-	idedisk_init();
-#endif
-#ifdef CONFIG_BLK_DEV_IDECD
-	ide_cdrom_init();
-#endif
-#ifdef CONFIG_BLK_DEV_IDETAPE
-	idetape_init();
-#endif
-#ifdef CONFIG_BLK_DEV_IDEFLOPPY
-	idefloppy_init();
-#endif
-
 	initializing = 0;
 
 	register_reboot_notifier(&ata_notifier);
diff -Nur linux-2.5/fs/dnotify.c linux-initcall/fs/dnotify.c
--- linux-2.5/fs/dnotify.c	Fri Aug  2 00:40:57 2002
+++ linux-initcall/fs/dnotify.c	Wed Jul 31 00:51:58 2002
@@ -155,4 +155,4 @@
 	return 0;
 }
 
-module_init(dnotify_init)
+fs_initcall(dnotify_init);
diff -Nur linux-2.5/fs/fcntl.c linux-initcall/fs/fcntl.c
--- linux-2.5/fs/fcntl.c	Fri Aug  2 00:40:57 2002
+++ linux-initcall/fs/fcntl.c	Wed Jul 31 00:51:58 2002
@@ -568,4 +568,4 @@
 	return 0;
 }
 
-module_init(fasync_init)
+fs_initcall(fasync_init);
diff -Nur linux-2.5/fs/locks.c linux-initcall/fs/locks.c
--- linux-2.5/fs/locks.c	Fri Aug  2 00:40:57 2002
+++ linux-initcall/fs/locks.c	Wed Jul 31 00:51:58 2002
@@ -1936,4 +1936,4 @@
 	return 0;
 }
 
-module_init(filelock_init)
+fs_initcall(filelock_init);
diff -Nur linux-2.5/include/linux/init.h linux-initcall/include/linux/init.h
--- linux-2.5/include/linux/init.h	Fri Aug  2 00:40:57 2002
+++ linux-initcall/include/linux/init.h	Wed Jul 31 00:51:58 2002
@@ -106,6 +106,9 @@
 #define __FINIT		.previous
 #define __INITDATA	.section	".data.init","aw"
 
+#define ___concat(a,b)	a##b
+#define __concat(a,b)	___concat(a,b)
+
 /**
  * module_init() - driver initialization entry point
  * @x: function to be run at kernel boot time or module insertion
@@ -116,7 +119,10 @@
  * routine with init_module() which is used by insmod and
  * modprobe when the driver is used as a module.
  */
-#define module_init(x)	__initcall(x);
+#define module_init(x)					\
+int __attribute__((__section__ (".initcall.module")))	\
+__concat(init_module_,KBUILD_MODNAME)(void)		\
+{ return x(); }
 
 /**
  * module_exit() - driver exit entry point
diff -Nur linux-2.5/kernel/module.c linux-initcall/kernel/module.c
--- linux-2.5/kernel/module.c	Fri Aug  2 00:40:57 2002
+++ linux-initcall/kernel/module.c	Wed Jul 31 00:51:58 2002
@@ -252,6 +252,19 @@
 	arch_init_modules(&kernel_module);
 }
 
+extern initcall_t generated_initcalls[];
+
+static int __init init_builtin_modules(void)
+{
+	initcall_t *call;
+
+	for (call = generated_initcalls; *call; call++)
+		(*call)();
+	return 0;
+}
+
+device_initcall(init_builtin_modules);
+
 /*
  * Copy the name of a module from user space.
  */
diff -Nur linux-2.5/net/unix/af_unix.c linux-initcall/net/unix/af_unix.c
--- linux-2.5/net/unix/af_unix.c	Fri Aug  2 00:40:57 2002
+++ linux-initcall/net/unix/af_unix.c	Thu Aug  1 23:31:27 2002
@@ -79,6 +79,8 @@
  *		  with BSD names.
  */
 
+#undef unix	/* KBUILD_MODNAME */
+
 #include <linux/module.h>
 #include <linux/config.h>
 #include <linux/kernel.h>
diff -Nur linux-2.5/scripts/build-initcalls linux-initcall/scripts/build-initcalls
--- linux-2.5/scripts/build-initcalls	Thu Jan  1 01:00:00 1970
+++ linux-initcall/scripts/build-initcalls	Thu Aug  1 23:28:15 2002
@@ -0,0 +1,35 @@
+list=$1
+initsrc=$2
+
+# initialize files
+echo -n > .undefined.tmp
+echo -n > .defined.tmp
+
+# get all global defined/undefined symbols and sort them into the right files
+while read obj; do
+  $NM $obj | sed -n "s,^[0-9a-f ]*\([UTD] .*\),\1 $(echo $obj | sed s/,/\\\\,/),p"
+done < $list |
+awk '/^U/ { print $2 " " $3 | "sort -u > .undefined.tmp" }
+     /^[TD]/ { print $2 " " $3 | "sort -u > .defined.tmp" }'
+
+# topological sort objects and append all independent objects
+join -o "1.2 2.2" .defined.tmp .undefined.tmp | sort -u | tsort > .sorted.tmp
+grep -v -f .sorted.tmp < $list > .other.tmp
+cat .other.tmp >> .sorted.tmp
+
+# extract init function call and prepare declarations and array
+while read obj; do
+  call=$($OBJDUMP -t $obj | awk '/F \.initcall\.module/ { print $6 }')
+  defs="$defs extern int $call(void);"
+  arr="$arr $call,"
+done < .sorted.tmp
+
+# finally write it
+echo "#include <linux/init.h>" > $initsrc
+echo $defs >> $initsrc
+echo 'initcall_t generated_initcalls[] = {' >> $initsrc
+echo $arr >> $initsrc
+echo '0 };' >> $initsrc
+
+# clean up
+rm .undefined.tmp .defined.tmp .sorted.tmp .other.tmp

^ permalink raw reply	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2002-08-07 11:15 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-07-27 20:22 [PATCH] automatic initcalls Roman Zippel
2002-07-28  3:31 ` Rusty Russell
2002-07-28  3:51   ` Jeff Garzik
2002-07-28  4:47     ` Linus Torvalds
2002-07-28  8:50       ` Keith Adamson
2002-07-28 18:59       ` Oliver Xymoron
2002-07-29 23:39       ` Rusty Russell
2002-07-29  8:39     ` Ingo Oeser
2002-07-30  2:49       ` Keith Adamson
2002-07-30  2:51         ` Keith Adamson
2002-07-28 12:18   ` Roman Zippel
2002-07-29 23:46     ` Rusty Russell
2002-07-30 23:04       ` [PATCH] automatic module_init ordering Roman Zippel
2002-07-31  2:33         ` Kai Germaschewski
2002-07-31  3:26           ` Rusty Russell
2002-07-31 17:06             ` Kai Germaschewski
2002-07-31 23:28               ` Rusty Russell
2002-07-28 21:59   ` [PATCH] automatic initcalls Kai Germaschewski
2002-07-29 18:56   ` Patrick Mochel
2002-07-29 20:14     ` Roman Zippel
  -- strict thread matches above, loose matches on Subject: below --
2002-08-01 23:52 [PATCH] automatic module_init ordering Roman Zippel
2002-08-02  3:19 ` Kai Germaschewski
2002-08-02 21:22   ` Sam Ravnborg
2002-08-03  1:17     ` Kai Germaschewski
2002-08-03 22:11       ` Sam Ravnborg
2002-08-04 15:30         ` Roman Zippel
2002-08-04 20:04           ` Sam Ravnborg
2002-08-04 20:10             ` Sam Ravnborg
2002-08-05  6:13           ` Rusty Russell
2002-08-05 19:05             ` Roman Zippel
2002-08-06  7:28               ` Rusty Russell
2002-08-06 18:57                 ` Roman Zippel
2002-08-07  1:05                   ` Rusty Russell
2002-08-07  2:28                     ` Kai Germaschewski
2002-08-07 10:40                     ` Roman Zippel
2002-08-07 11:10                       ` Rusty Russell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox