Skip to contentSkip to conversation

Have split-include take another argument

PATCH In review Tom Rini 3 participants 5 messages Nov 11, 2002 – Nov 14, 2002

lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH 1/1 Have split-include take another argument

Hello. The following patch makes split-include take another argument, which is the prefix of what is being split up. This is needed since I'm working on a system which will allow for various params in the kernel to be tweaked at compile-time, without offering numerous CONFIG options (see http://marc.theaimsgroup.com/?l=linux-kernel&m=103669658505842&w=2).
I'm sending this out for two reasons. First, does anyone see any problems with the patch itself? Second, Kai, would you be willing to apply this patch now, or would should I wait until the system is ready?

Signature · 57 lines
Tom Rini (TR1265)
http://gate.crashing.org/~trini/

===== Makefile 1.320 vs edited =====
--- 1.320/Makefile	Mon Nov 11 08:08:41 2002
+++ edited/Makefile	Mon Nov 11 09:30:45 2002
@@ -413,7 +413,7 @@
 
 include/config/MARKER: scripts/split-include include/linux/autoconf.h
 	@echo '  SPLIT  include/linux/autoconf.h -> include/config/*'
-	@scripts/split-include include/linux/autoconf.h include/config
+	@scripts/split-include include/linux/autoconf.h include/config CONFIG_
 	@touch $@
 
 # 	if .config is newer than include/linux/autoconf.h, someone tinkered
===== scripts/split-include.c 1.3 vs edited =====
--- 1.3/scripts/split-include.c	Sun Jun  2 18:34:13 2002
+++ edited/scripts/split-include.c	Mon Nov 11 09:29:55 2002
@@ -46,6 +46,7 @@
     const char * str_my_name;
     const char * str_file_autoconf;
     const char * str_dir_config;
+    const char * str_split_token;
 
     FILE * fp_config;
     FILE * fp_target;
@@ -61,7 +62,7 @@
     struct stat stat_buf;
 
     /* Check arg count. */
-    if (argc != 3)
+    if (argc != 4)
     {
 	fprintf(stderr, "%s: wrong number of arguments.\n", argv[0]);
 	exit(1);
@@ -70,6 +71,7 @@
     str_my_name       = argv[0];
     str_file_autoconf = argv[1];
     str_dir_config    = argv[2];
+    str_split_token   = argv[3];
 
     /* Find a buffer size. */
     if (stat(str_file_autoconf, &stat_buf) != 0)
@@ -110,11 +112,11 @@
 
 	if (line[0] != '#')
 	    continue;
-	if ((str_config = strstr(line, "CONFIG_")) == NULL)
+	if ((str_config = strstr(line, str_split_token)) == NULL)
 	    continue;
 
 	/* Make the output file name. */
-	str_config += sizeof("CONFIG_") - 1;
+	str_config += strlen(str_split_token);
 	for (itarget = 0; !isspace(str_config[itarget]); itarget++)
 	{
 	    int c = (unsigned char) str_config[itarget];
#1 lore raw

[Tom Rini]

Quoted 1 line

First, does anyone see any problems with the patch itself?

Well,

Review

Quoted 2 lines
(quoted diff) +1 -1
-	str_config += sizeof("CONFIG_") - 1;
+	str_config += strlen(str_split_token);

it does seem a bit inefficient to call strlen() for every single line of every single source file. Perhaps today's compilers know that strlen() is invariant and has no side effects, but I vote you go ahead and optimise it explicitly.

Peter

split-include.c renamed from split-include.c.trini +3 -2
@@ -52,7 +52,7 @@
     FILE * fp_target;
     FILE * fp_find;
 
-    int buffer_size;
+    int buffer_size, split_token_len;
 
     char * line;
     char * old_line;
@@ -72,6 +72,7 @@
     str_file_autoconf = argv[1];
     str_dir_config    = argv[2];
     str_split_token   = argv[3];
+    split_token_len = strlen(str_split_token);
 
     /* Find a buffer size. */
     if (stat(str_file_autoconf, &stat_buf) != 0)
@@ -116,7 +117,7 @@
 	    continue;
 
 	/* Make the output file name. */
-	str_config += strlen(str_split_token);
+	str_config += split_token_len;
 	for (itarget = 0; !isspace(str_config[itarget]); itarget++)
 	{
 	    int c = (unsigned char) str_config[itarget];
author
#2 lore raw
Quoted 5 lines · Peter Samuelson

[Tom Rini]

Quoted 1 line

First, does anyone see any problems with the patch itself?

Well,

Quoted 7 lines

Review

Quoted 2 lines
(quoted diff) +1 -1
-	str_config += sizeof("CONFIG_") - 1;
+	str_config += strlen(str_split_token);

it does seem a bit inefficient to call strlen() for every single line of every single source file. Perhaps today's compilers know that strlen() is invariant and has no side effects, but I vote you go ahead and optimise it explicitly.

Sounds good, thanks.

Signature · 2 lines
Tom Rini (TR1265)
http://gate.crashing.org/~trini/
#3 lore raw
In reply to Tom Rini
Quoted 8 lines · Tom Rini

Hello. The following patch makes split-include take another argument, which is the prefix of what is being split up. This is needed since I'm working on a system which will allow for various params in the kernel to be tweaked at compile-time, without offering numerous CONFIG options (see http://marc.theaimsgroup.com/?l=linux-kernel&m=103669658505842&w=2).
I'm sending this out for two reasons. First, does anyone see any problems with the patch itself? Second, Kai, would you be willing to apply this patch now, or would should I wait until the system is ready?

Hmmh, I think I'd rather like to wait for the rest of the patch to see what its actual purpose is. If at all possible, I'd like to avoid introducing further hacks like this into kbuild, but that's more easily discussed when I can see what you're trying to achieve.

--Kai

author
#4 lore raw
Quoted 11 lines · Kai Germaschewski
Quoted 8 lines · Tom Rini

Hello. The following patch makes split-include take another argument, which is the prefix of what is being split up. This is needed since I'm working on a system which will allow for various params in the kernel to be tweaked at compile-time, without offering numerous CONFIG options (see http://marc.theaimsgroup.com/?l=linux-kernel&m=103669658505842&w=2).
I'm sending this out for two reasons. First, does anyone see any problems with the patch itself? Second, Kai, would you be willing to apply this patch now, or would should I wait until the system is ready?

Quoted 4 lines

Hmmh, I think I'd rather like to wait for the rest of the patch to see what its actual purpose is. If at all possible, I'd like to avoid introducing further hacks like this into kbuild, but that's more easily discussed when I can see what you're trying to achieve.

Okay. I hope to have another version of the patch out soon, and with a few more kbuild questions once I convince myself that most of it works (Adding in something similar to the CONFIG tweaking done by fixdep, but with no real convinient way to see if the user changed something or not).

Signature · 2 lines
Tom Rini (TR1265)
http://gate.crashing.org/~trini/