Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/config Merge struct objects into struct files. Keep...



details:   https://anonhg.NetBSD.org/src/rev/5428dd006061
branches:  trunk
changeset: 340352:5428dd006061
user:      uebayasi <uebayasi%NetBSD.org@localhost>
date:      Tue Sep 01 11:22:59 2015 +0000

description:
Merge struct objects into struct files.  Keep per-suffix file lists.

diffstat:

 usr.bin/config/defs.h       |  46 ++++++++----------------------
 usr.bin/config/files.c      |  67 ++++++++++++++++++--------------------------
 usr.bin/config/gram.y       |   8 ++--
 usr.bin/config/mkmakefile.c |  11 +++----
 4 files changed, 48 insertions(+), 84 deletions(-)

diffs (truncated from 302 to 300 lines):

diff -r 1993f4208725 -r 5428dd006061 usr.bin/config/defs.h
--- a/usr.bin/config/defs.h     Tue Sep 01 10:37:48 2015 +0000
+++ b/usr.bin/config/defs.h     Tue Sep 01 11:22:59 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: defs.h,v 1.75 2015/09/01 10:37:48 uebayasi Exp $       */
+/*     $NetBSD: defs.h,v 1.76 2015/09/01 11:22:59 uebayasi Exp $       */
 
 /*
  * Copyright (c) 1992, 1993
@@ -149,6 +149,9 @@
        struct nvlist *dl_depends;
 };
 
+struct files;
+TAILQ_HEAD(filelist, files);
+
 struct module {
        const char              *m_name;
 #if 1
@@ -158,7 +161,7 @@
        struct modulelist       *m_deps;
 #endif
        int                     m_expanding;
-       TAILQ_HEAD(, files)     m_files;
+       struct filelist         m_files;
        int                     m_weight;
 };
 
@@ -334,6 +337,7 @@
  */
 struct filetype {
        TAILQ_ENTRY(files) fit_next;
+       TAILQ_ENTRY(files) fit_snext;
        const char *fit_srcfile;        /* the name of the "files" file that got us */
        u_short fit_srcline;    /* and the line number */
        u_char  fit_flags;      /* as below */
@@ -367,6 +371,7 @@
        struct filetype fi_fit;
 };
 #define fi_next    fi_fit.fit_next
+#define fi_snext    fi_fit.fit_snext
 #define fi_srcfile fi_fit.fit_srcfile
 #define fi_srcline fi_fit.fit_srcline
 #define fi_flags   fi_fit.fit_flags
@@ -390,35 +395,6 @@
 #define        FI_HIDDEN       0x08    /* obscured by other(s), base names overlap */
 
 /*
- * Objects and libraries.  This allows precompiled object and library
- * files (e.g. binary-only device drivers) to be linked in.
- */
-struct objects {
-       struct  filetype oi_fit;
-};
-
-#define oi_next    oi_fit.fit_next
-#define oi_srcfile oi_fit.fit_srcfile
-#define oi_srcline oi_fit.fit_srcline
-#define oi_flags   oi_fit.fit_flags
-#define oi_lastc   oi_fit.fit_lastc
-#define oi_tail    oi_fit.fit_tail
-#define oi_base    oi_fit.fit_base
-#define oi_path    oi_fit.fit_path
-#define oi_prefix  oi_fit.fit_prefix
-#define oi_suffix  oi_fit.fit_suffix
-#define oi_len     oi_fit.fit_len
-#define oi_optx    oi_fit.fit_optx
-#define oi_optf    oi_fit.fit_optf
-#define oi_mkrule  oi_fit.fit_mkrule
-#define oi_attr    oi_fit.fit_attr
-#define oi_anext   oi_fit.fit_anext
-
-/* flags */
-#define        OI_SEL          0x01    /* selected */
-#define        OI_NEEDSFLAG    0x02    /* needs-flag */
-
-/*
  * Condition expressions.
  */
 
@@ -534,8 +510,11 @@
 int    oktopackage;                    /* 0 before setmachine() */
 int    devilevel;                      /* used for devi->i_level */
 
-TAILQ_HEAD(, files)    allfiles;       /* list of all kernel source files */
-TAILQ_HEAD(, objects)  allobjects;     /* list of all kernel object and
+struct filelist                allfiles;       /* list of all kernel source files */
+struct filelist                allcfiles;      /* list of all .c files */
+struct filelist                allsfiles;      /* list of all .S files */
+struct filelist                allofiles;      /* list of all .o files */
+TAILQ_HEAD(, files)    allobjects;     /* list of all kernel object and
                                           library files */
 
 SLIST_HEAD(, prefix)   prefixes,       /* prefix stack */
@@ -563,7 +542,6 @@
 int    fixobjects(void);
 int    fixdevsw(void);
 void   addfile(const char *, struct condexpr *, u_char, const char *);
-void   addobject(const char *, struct condexpr *, u_char);
 int    expr_eval(struct condexpr *, int (*)(const char *, void *), void *);
 
 /* hash.c */
diff -r 1993f4208725 -r 5428dd006061 usr.bin/config/files.c
--- a/usr.bin/config/files.c    Tue Sep 01 10:37:48 2015 +0000
+++ b/usr.bin/config/files.c    Tue Sep 01 11:22:59 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: files.c,v 1.21 2015/08/29 02:54:07 uebayasi Exp $      */
+/*     $NetBSD: files.c,v 1.22 2015/09/01 11:22:59 uebayasi Exp $      */
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: files.c,v 1.21 2015/08/29 02:54:07 uebayasi Exp $");
+__RCSID("$NetBSD: files.c,v 1.22 2015/09/01 11:22:59 uebayasi Exp $");
 
 #include <sys/param.h>
 #include <errno.h>
@@ -81,6 +81,9 @@
        basetab = ht_new();
        pathtab = ht_new();
        TAILQ_INIT(&allfiles);
+       TAILQ_INIT(&allcfiles);
+       TAILQ_INIT(&allsfiles);
+       TAILQ_INIT(&allofiles);
        unchecked = &TAILQ_FIRST(&allfiles);
        TAILQ_INIT(&allobjects);
 }
@@ -168,7 +171,21 @@
        fi->fi_optf = NULL;
        fi->fi_mkrule = rule;
        fi->fi_attr = NULL;
-       TAILQ_INSERT_TAIL(&allfiles, fi, fi_next);
+       switch (fi->fi_suffix) {
+       case 'c':
+               TAILQ_INSERT_TAIL(&allcfiles, fi, fi_snext);
+               TAILQ_INSERT_TAIL(&allfiles, fi, fi_next);
+               break;
+       case 'S':
+       case 's':
+               TAILQ_INSERT_TAIL(&allsfiles, fi, fi_snext);
+               TAILQ_INSERT_TAIL(&allfiles, fi, fi_next);
+               break;
+       case 'o':
+               TAILQ_INSERT_TAIL(&allofiles, fi, fi_snext);
+               TAILQ_INSERT_TAIL(&allobjects, fi, fi_next);
+               break;
+       }
        return;
  bad:
        if (optx != NULL) {
@@ -176,36 +193,6 @@
        }
 }
 
-void
-addobject(const char *path, struct condexpr *optx, u_char flags)
-{
-       struct objects *oi;
-
-       /*
-        * Commit this object to memory.  We will decide later whether it
-        * will be used after all.
-        */
-       oi = ecalloc(1, sizeof *oi);
-       if (ht_insert(pathtab, path, oi)) {
-               free(oi);
-               if ((oi = ht_lookup(pathtab, path)) == NULL)
-                       panic("addfile: ht_lookup(%s)", path);
-               cfgerror("duplicate file %s", path);
-               cfgxerror(oi->oi_srcfile, oi->oi_srcline,
-                   "here is the original definition");
-       } 
-       oi->oi_srcfile = yyfile;
-       oi->oi_srcline = currentline();
-       oi->oi_flags = flags;
-       oi->oi_path = path;
-       oi->oi_prefix = SLIST_EMPTY(&prefixes) ? NULL :
-                       SLIST_FIRST(&prefixes)->pf_prefix;
-       oi->oi_optx = optx;
-       oi->oi_optf = NULL;
-       TAILQ_INSERT_TAIL(&allobjects, oi, oi_next);
-       return;
-}     
-
 static void
 addfiletoattr(const char *name, struct files *fi)
 {
@@ -339,26 +326,26 @@
 int    
 fixobjects(void)
 {     
-       struct objects *oi;
+       struct files *fi;
        struct nvlist *flathead, **flatp;
        int err, sel; 
  
        err = 0;
-       TAILQ_FOREACH(oi, &allobjects, oi_next) {
+       TAILQ_FOREACH(fi, &allobjects, fi_next) {
                /* Optional: see if it is to be included. */
-               if (oi->oi_optx != NULL) {
+               if (fi->fi_optx != NULL) {
                        flathead = NULL;
                        flatp = &flathead;
-                       sel = expr_eval(oi->oi_optx,
-                           oi->oi_flags & OI_NEEDSFLAG ? fixfsel :
+                       sel = expr_eval(fi->fi_optx,
+                           fi->fi_flags & FI_NEEDSFLAG ? fixfsel :
                            fixsel,
                            &flatp);
-                       oi->oi_optf = flathead;
+                       fi->fi_optf = flathead;
                        if (!sel)
                                continue;
                }
 
-               oi->oi_flags |= OI_SEL;  
+               fi->fi_flags |= FI_SEL;  
        }
        return (err);
 }     
diff -r 1993f4208725 -r 5428dd006061 usr.bin/config/gram.y
--- a/usr.bin/config/gram.y     Tue Sep 01 10:37:48 2015 +0000
+++ b/usr.bin/config/gram.y     Tue Sep 01 11:22:59 2015 +0000
@@ -1,5 +1,5 @@
 %{
-/*     $NetBSD: gram.y,v 1.50 2015/08/31 02:58:25 uebayasi Exp $       */
+/*     $NetBSD: gram.y,v 1.51 2015/09/01 11:22:59 uebayasi Exp $       */
 
 /*
  * Copyright (c) 1992, 1993
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: gram.y,v 1.50 2015/08/31 02:58:25 uebayasi Exp $");
+__RCSID("$NetBSD: gram.y,v 1.51 2015/09/01 11:22:59 uebayasi Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -343,7 +343,7 @@
 
 /* object file: object zot.o foo|zot needs-flag */
 define_object:
-       XOBJECT filename fopts oflags   { addobject($2, $3, $4); }
+       XOBJECT filename fopts oflags   { addfile($2, $3, $4, NULL); }
 ;
 
 /* device major declaration */
@@ -473,7 +473,7 @@
 
 /* a single flag for an object file */
 oflag:
-       NEEDS_FLAG                      { $$ = OI_NEEDSFLAG; }
+       NEEDS_FLAG                      { $$ = FI_NEEDSFLAG; }
 ;
 
 /* char 55 */
diff -r 1993f4208725 -r 5428dd006061 usr.bin/config/mkmakefile.c
--- a/usr.bin/config/mkmakefile.c       Tue Sep 01 10:37:48 2015 +0000
+++ b/usr.bin/config/mkmakefile.c       Tue Sep 01 11:22:59 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mkmakefile.c,v 1.51 2015/09/01 01:17:56 uebayasi Exp $ */
+/*     $NetBSD: mkmakefile.c,v 1.52 2015/09/01 11:22:59 uebayasi Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: mkmakefile.c,v 1.51 2015/09/01 01:17:56 uebayasi Exp $");
+__RCSID("$NetBSD: mkmakefile.c,v 1.52 2015/09/01 11:22:59 uebayasi Exp $");
 
 #include <sys/param.h>
 #include <ctype.h>
@@ -313,7 +313,6 @@
 emitobjs(FILE *fp)
 {
        struct files *fi;
-       struct objects *oi;
 
        fputs("OBJS= \\\n", fp);
        TAILQ_FOREACH(fi, &allfiles, fi_next) {
@@ -321,11 +320,11 @@
                        continue;
                fprintf(fp, "\t%s.o \\\n", fi->fi_base);
        }
-       TAILQ_FOREACH(oi, &allobjects, oi_next) {
-               if ((oi->oi_flags & OI_SEL) == 0)
+       TAILQ_FOREACH(fi, &allobjects, fi_next) {
+               if ((fi->fi_flags & FI_SEL) == 0)
                        continue;
                putc('\t', fp);
-               emitfiletype(fp, &oi->oi_fit);
+               emitfiletype(fp, &fi->fi_fit);
                fputs(" \\\n", fp);



Home | Main Index | Thread Index | Old Index