Merge commit 'v2.6.37-rc1' into kbuild/kbuild
authorMichal Marek <mmarek@suse.cz>
Tue, 14 Dec 2010 21:01:55 +0000 (22:01 +0100)
committerMichal Marek <mmarek@suse.cz>
Tue, 14 Dec 2010 21:01:55 +0000 (22:01 +0100)
scripts/basic/fixdep.c
scripts/genksyms/parse.c_shipped
scripts/genksyms/parse.y
scripts/headers_install.pl
usr/gen_init_cpio.c

index ea26b23..ed05846 100644 (file)
@@ -138,38 +138,36 @@ static void print_cmdline(void)
        printf("cmd_%s := %s\n\n", target, cmdline);
 }
 
-char * str_config  = NULL;
-int    size_config = 0;
-int    len_config  = 0;
+struct item {
+       struct item     *next;
+       unsigned int    len;
+       unsigned int    hash;
+       char            name[0];
+};
 
-/*
- * Grow the configuration string to a desired length.
- * Usually the first growth is plenty.
- */
-static void grow_config(int len)
-{
-       while (len_config + len > size_config) {
-               if (size_config == 0)
-                       size_config = 2048;
-               str_config = realloc(str_config, size_config *= 2);
-               if (str_config == NULL)
-                       { perror("fixdep:malloc"); exit(1); }
-       }
-}
+#define HASHSZ 256
+static struct item *hashtab[HASHSZ];
 
+static unsigned int strhash(const char *str, unsigned int sz)
+{
+       /* fnv32 hash */
+       unsigned int i, hash = 2166136261U;
 
+       for (i = 0; i < sz; i++)
+               hash = (hash ^ str[i]) * 0x01000193;
+       return hash;
+}
 
 /*
  * Lookup a value in the configuration string.
  */
-static int is_defined_config(const char * name, int len)
+static int is_defined_config(const char *name, int len, unsigned int hash)
 {
-       const char * pconfig;
-       const char * plast = str_config + len_config - len;
-       for ( pconfig = str_config + 1; pconfig < plast; pconfig++ ) {
-               if (pconfig[ -1] == '\n'
-               &&  pconfig[len] == '\n'
-               &&  !memcmp(pconfig, name, len))
+       struct item *aux;
+
+       for (aux = hashtab[hash % HASHSZ]; aux; aux = aux->next) {
+               if (aux->hash == hash && aux->len == len &&
+                   memcmp(aux->name, name, len) == 0)
                        return 1;
        }
        return 0;
@@ -178,13 +176,19 @@ static int is_defined_config(const char * name, int len)
 /*
  * Add a new value to the configuration string.
  */
-static void define_config(const char * name, int len)
+static void define_config(const char *name, int len, unsigned int hash)
 {
-       grow_config(len + 1);
+       struct item *aux = malloc(sizeof(*aux) + len);
 
-       memcpy(str_config+len_config, name, len);
-       len_config += len;
-       str_config[len_config++] = '\n';
+       if (!aux) {
+               perror("fixdep:malloc");
+               exit(1);
+       }
+       memcpy(aux->name, name, len);
+       aux->len = len;
+       aux->hash = hash;
+       aux->next = hashtab[hash % HASHSZ];
+       hashtab[hash % HASHSZ] = aux;
 }
 
 /*
@@ -192,40 +196,49 @@ static void define_config(const char * name, int len)
  */
 static void clear_config(void)
 {
-       len_config = 0;
-       define_config("", 0);
+       struct item *aux, *next;
+       unsigned int i;
+
+       for (i = 0; i < HASHSZ; i++) {
+               for (aux = hashtab[i]; aux; aux = next) {
+                       next = aux->next;
+                       free(aux);
+               }
+               hashtab[i] = NULL;
+       }
 }
 
 /*
  * Record the use of a CONFIG_* word.
  */
-static void use_config(char *m, int slen)
+static void use_config(const char *m, int slen)
 {
-       char s[PATH_MAX];
-       char *p;
+       unsigned int hash = strhash(m, slen);
+       int c, i;
 
-       if (is_defined_config(m, slen))
+       if (is_defined_config(m, slen, hash))
            return;
 
-       define_config(m, slen);
-
-       memcpy(s, m, slen); s[slen] = 0;
+       define_config(m, slen, hash);
 
-       for (p = s; p < s + slen; p++) {
-               if (*p == '_')
-                       *p = '/';
+       printf("    $(wildcard include/config/");
+       for (i = 0; i < slen; i++) {
+               c = m[i];
+               if (c == '_')
+                       c = '/';
                else
-                       *p = tolower((int)*p);
+                       c = tolower(c);
+               putchar(c);
        }
-       printf("    $(wildcard include/config/%s.h) \\\n", s);
+       printf(".h) \\\n");
 }
 
-static void parse_config_file(char *map, size_t len)
+static void parse_config_file(const char *map, size_t len)
 {
-       int *end = (int *) (map + len);
+       const int *end = (const int *) (map + len);
        /* start at +1, so that p can never be < map */
-       int *m   = (int *) map + 1;
-       char *p, *q;
+       const int *m   = (const int *) map + 1;
+       const char *p, *q;
 
        for (; m < end; m++) {
                if (*m == INT_CONF) { p = (char *) m  ; goto conf; }
@@ -265,7 +278,7 @@ static int strrcmp(char *s, char *sub)
        return memcmp(s + slen - sublen, sub, sublen);
 }
 
-static void do_config_file(char *filename)
+static void do_config_file(const char *filename)
 {
        struct stat st;
        int fd;
index eaee44e..809b949 100644 (file)
 
 
 #include <assert.h>
-#include <malloc.h>
+#include <stdlib.h>
 #include "genksyms.h"
 
 static int is_typedef;
index 10d7dc7..09a265c 100644 (file)
@@ -24,7 +24,7 @@
 %{
 
 #include <assert.h>
-#include <malloc.h>
+#include <stdlib.h>
 #include "genksyms.h"
 
 static int is_typedef;
index 4ca3be3..efb3be1 100644 (file)
@@ -45,6 +45,13 @@ foreach my $file (@files) {
        close $in;
 
        system $unifdef . " $tmpfile > $installdir/$file";
+       # unifdef will exit 0 on success, and will exit 1 when the
+       # file was processed successfully but no changes were made,
+       # so abort only when it's higher than that.
+       my $e = $? >> 8;
+       if ($e > 1) {
+               die "$tmpfile: $!\n";
+       }
        unlink $tmpfile;
 }
 exit 0;
index b2b3c2d..59df70d 100644 (file)
@@ -104,6 +104,8 @@ static int cpio_mkslink(const char *name, const char *target,
        char s[256];
        time_t mtime = time(NULL);
 
+       if (name[0] == '/')
+               name++;
        sprintf(s,"%s%08X%08X%08lX%08lX%08X%08lX"
               "%08X%08X%08X%08X%08X%08X%08X",
                "070701",               /* magic */
@@ -152,6 +154,8 @@ static int cpio_mkgeneric(const char *name, unsigned int mode,
        char s[256];
        time_t mtime = time(NULL);
 
+       if (name[0] == '/')
+               name++;
        sprintf(s,"%s%08X%08X%08lX%08lX%08X%08lX"
               "%08X%08X%08X%08X%08X%08X%08X",
                "070701",               /* magic */
@@ -245,6 +249,8 @@ static int cpio_mknod(const char *name, unsigned int mode,
        else
                mode |= S_IFCHR;
 
+       if (name[0] == '/')
+               name++;
        sprintf(s,"%s%08X%08X%08lX%08lX%08X%08lX"
               "%08X%08X%08X%08X%08X%08X%08X",
                "070701",               /* magic */
@@ -332,6 +338,8 @@ static int cpio_mkfile(const char *name, const char *location,
                /* data goes on last link */
                if (i == nlinks) size = buf.st_size;
 
+               if (name[0] == '/')
+                       name++;
                namesize = strlen(name) + 1;
                sprintf(s,"%s%08X%08X%08lX%08lX%08X%08lX"
                       "%08lX%08X%08X%08X%08X%08X%08X",