config: make reconfig target

2013-10-28 Thread Marc Espie
The following patch expands config(8) slightly to be able to say
make reconfig from the build directory.

Yeah, it's sugar, but it got tiresome having to change directories
all the time.

I've put the reconfig target at end, where I'm sure it can't be the
first target.

An alternative approach would be to add an extra keyword for
boilerplate stuff that would always be emitted by config, but I
don't see the point of the extra knob in that particular case.

Index: config.h
===
RCS file: /build/data/openbsd/cvs/src/usr.sbin/config/config.h,v
retrieving revision 1.25
diff -u -p -r1.25 config.h
--- config.h5 Dec 2012 23:20:26 -   1.25
+++ config.h28 Oct 2013 07:44:56 -
@@ -339,6 +339,10 @@ void   defoption(const char *name);
 intdevbase_has_instances(struct devbase *, int);
 intdeva_has_instances(struct deva *, int);
 void   setupdirs(void);
+intpflag;
+char   *sflag;
+char   *bflag;
+char   *startdir;
 
 /* mkheaders.c */
 intmkheaders(void);
Index: main.c
===
RCS file: /build/data/openbsd/cvs/src/usr.sbin/config/main.c,v
retrieving revision 1.44
diff -u -p -r1.44 main.c
--- main.c  22 Jun 2012 22:02:29 -  1.44
+++ main.c  28 Oct 2013 07:47:13 -
@@ -93,15 +93,24 @@ usage(void)
exit(1);
 }
 
+int pflag = 0;
+char *sflag = NULL;
+char *bflag = NULL;
+char *startdir;
+
 int
 main(int argc, char *argv[])
 {
char *p;
const char *last_component;
char *outfile = NULL;
-   int pflag, ch, eflag, uflag, fflag;
+   int ch, eflag, uflag, fflag;
+   char dirbuffer[PATH_MAX];
 
pflag = eflag = uflag = fflag = 0;
+   startdir = getcwd(dirbuffer, sizeof dirbuffer);
+   if (startdir == NULL)
+   warn(Can't getcwd, no make reconfig);
while ((ch = getopt(argc, argv, egpfb:s:o:u)) != -1) {
switch (ch) {
 
@@ -148,10 +157,12 @@ main(int argc, char *argv[])
break;
 
case 'b':
+   bflag = optarg;
builddir = optarg;
break;
 
case 's':
+   sflag = optarg;
srcdir = optarg;
break;
 
Index: mkmakefile.c
===
RCS file: /build/data/openbsd/cvs/src/usr.sbin/config/mkmakefile.c,v
retrieving revision 1.37
diff -u -p -r1.37 mkmakefile.c
--- mkmakefile.c17 Sep 2012 17:36:13 -  1.37
+++ mkmakefile.c28 Oct 2013 07:47:03 -
@@ -60,6 +60,7 @@
 static const char *srcpath(struct files *);
 
 static int emitdefs(FILE *);
+static int emitreconfig(FILE *);
 static int emitfiles(FILE *, int);
 
 static int emitobjs(FILE *);
@@ -120,6 +121,10 @@ mkmakefile(void)
if ((*fn)(ofp))
goto wrerror;
}
+   if (startdir != NULL) {
+   if (emitreconfig(ofp) != 0)
+   goto wrerror;
+   }
if (ferror(ifp)) {
(void)fprintf(stderr,
config: error reading %s (at line %d): %s\n,
@@ -271,6 +276,33 @@ emitdefs(FILE *fp)
for (nv = mkoptions; nv != NULL; nv = nv-nv_next)
if (fprintf(fp, %s=%s\n, nv-nv_name, nv-nv_str)  0)
return (1);
+   return (0);
+}
+
+static int
+emitreconfig(FILE *fp)
+{
+   if (fputs(\n
+   .PHONY: reconfig\n
+   reconfig:\n, fp)  0)
+   return (1);
+   if (fprintf(fp, \tcd %s  config , startdir)  0)
+   return (1);
+   if (pflag) {
+   if (fputs(-p , fp)  0)
+   return (1);
+   }
+   if (sflag) {
+   if (fprintf(fp, -s %s , sflag)  0)
+   return (1);
+   }
+   if (bflag) {
+   if (fprintf(fp, -b %s , bflag)  0)
+   return (1);
+   }
+   /* other options */
+   if (fprintf(fp, %s\n, conffile)  0)
+   return (1);
return (0);
 }
 



Re: HFSC queue pusher

2013-10-28 Thread Martin Pelikan
 As far as I know, HZ is all we have in a portable fashion.  How do you
 get better?
 
 (I have an answer.  I've prodded for years.  Noone has bit yet.  Maybe
 you will).

Is the answer start writing drivers for other timers and make them run
softclock independently of the scheduler tick?  Do we want tickless
operation in the future?

I don't know enough about our supported platforms to see whether any of
them could actually benefit from it, other than amd64 and i386.
The local APIC timer on amd64 is likely the first candidate.  Scheduler
tick would then become yet another timeout.  I don't see if it is that
easy and what else could it possibly break.

This is why the diff doesn't bother with any of that.  It just
simplifies the current situation and shows places to improve later on.

ok? :-)



config(8) 'make config' v2

2013-10-28 Thread Marc Espie
Theo says no need for reconfig, make config will do just fine.

okays ?


Index: config.h
===
RCS file: /build/data/openbsd/cvs/src/usr.sbin/config/config.h,v
retrieving revision 1.25
diff -u -p -r1.25 config.h
--- config.h5 Dec 2012 23:20:26 -   1.25
+++ config.h28 Oct 2013 07:44:56 -
@@ -339,6 +339,10 @@ void   defoption(const char *name);
 intdevbase_has_instances(struct devbase *, int);
 intdeva_has_instances(struct deva *, int);
 void   setupdirs(void);
+intpflag;
+char   *sflag;
+char   *bflag;
+char   *startdir;
 
 /* mkheaders.c */
 intmkheaders(void);
Index: main.c
===
RCS file: /build/data/openbsd/cvs/src/usr.sbin/config/main.c,v
retrieving revision 1.44
diff -u -p -r1.44 main.c
--- main.c  22 Jun 2012 22:02:29 -  1.44
+++ main.c  28 Oct 2013 07:47:13 -
@@ -93,15 +93,24 @@ usage(void)
exit(1);
 }
 
+int pflag = 0;
+char *sflag = NULL;
+char *bflag = NULL;
+char *startdir;
+
 int
 main(int argc, char *argv[])
 {
char *p;
const char *last_component;
char *outfile = NULL;
-   int pflag, ch, eflag, uflag, fflag;
+   int ch, eflag, uflag, fflag;
+   char dirbuffer[PATH_MAX];
 
pflag = eflag = uflag = fflag = 0;
+   startdir = getcwd(dirbuffer, sizeof dirbuffer);
+   if (startdir == NULL)
+   warn(Can't getcwd, no make reconfig);
while ((ch = getopt(argc, argv, egpfb:s:o:u)) != -1) {
switch (ch) {
 
@@ -148,10 +157,12 @@ main(int argc, char *argv[])
break;
 
case 'b':
+   bflag = optarg;
builddir = optarg;
break;
 
case 's':
+   sflag = optarg;
srcdir = optarg;
break;
 
Index: mkmakefile.c
===
RCS file: /build/data/openbsd/cvs/src/usr.sbin/config/mkmakefile.c,v
retrieving revision 1.37
diff -u -p -r1.37 mkmakefile.c
--- mkmakefile.c17 Sep 2012 17:36:13 -  1.37
+++ mkmakefile.c28 Oct 2013 17:57:38 -
@@ -60,6 +60,7 @@
 static const char *srcpath(struct files *);
 
 static int emitdefs(FILE *);
+static int emitreconfig(FILE *);
 static int emitfiles(FILE *, int);
 
 static int emitobjs(FILE *);
@@ -120,6 +121,10 @@ mkmakefile(void)
if ((*fn)(ofp))
goto wrerror;
}
+   if (startdir != NULL) {
+   if (emitreconfig(ofp) != 0)
+   goto wrerror;
+   }
if (ferror(ifp)) {
(void)fprintf(stderr,
config: error reading %s (at line %d): %s\n,
@@ -271,6 +276,33 @@ emitdefs(FILE *fp)
for (nv = mkoptions; nv != NULL; nv = nv-nv_next)
if (fprintf(fp, %s=%s\n, nv-nv_name, nv-nv_str)  0)
return (1);
+   return (0);
+}
+
+static int
+emitreconfig(FILE *fp)
+{
+   if (fputs(\n
+   .PHONY: config\n
+   config:\n, fp)  0)
+   return (1);
+   if (fprintf(fp, \tcd %s  config , startdir)  0)
+   return (1);
+   if (pflag) {
+   if (fputs(-p , fp)  0)
+   return (1);
+   }
+   if (sflag) {
+   if (fprintf(fp, -s %s , sflag)  0)
+   return (1);
+   }
+   if (bflag) {
+   if (fprintf(fp, -b %s , bflag)  0)
+   return (1);
+   }
+   /* other options */
+   if (fprintf(fp, %s\n, conffile)  0)
+   return (1);
return (0);
 }
 



Re: config(8) 'make config' v2

2013-10-28 Thread Vadim Zhukov
2013/10/28 Marc Espie es...@nerim.net:
 Theo says no need for reconfig, make config will do just fine.

 okays ?


 Index: config.h
 ===
 RCS file: /build/data/openbsd/cvs/src/usr.sbin/config/config.h,v
 retrieving revision 1.25
 diff -u -p -r1.25 config.h
 --- config.h5 Dec 2012 23:20:26 -   1.25
 +++ config.h28 Oct 2013 07:44:56 -
 @@ -339,6 +339,10 @@ void   defoption(const char *name);
  intdevbase_has_instances(struct devbase *, int);
  intdeva_has_instances(struct deva *, int);
  void   setupdirs(void);
 +intpflag;
 +char   *sflag;
 +char   *bflag;
 +char   *startdir;

  /* mkheaders.c */
  intmkheaders(void);
 Index: main.c
 ===
 RCS file: /build/data/openbsd/cvs/src/usr.sbin/config/main.c,v
 retrieving revision 1.44
 diff -u -p -r1.44 main.c
 --- main.c  22 Jun 2012 22:02:29 -  1.44
 +++ main.c  28 Oct 2013 07:47:13 -
 @@ -93,15 +93,24 @@ usage(void)
 exit(1);
  }

 +int pflag = 0;
 +char *sflag = NULL;
 +char *bflag = NULL;
 +char *startdir;
 +
  int
  main(int argc, char *argv[])
  {
 char *p;
 const char *last_component;
 char *outfile = NULL;
 -   int pflag, ch, eflag, uflag, fflag;
 +   int ch, eflag, uflag, fflag;
 +   char dirbuffer[PATH_MAX];

 pflag = eflag = uflag = fflag = 0;
 +   startdir = getcwd(dirbuffer, sizeof dirbuffer);
 +   if (startdir == NULL)
 +   warn(Can't getcwd, no make reconfig);

make config here, too.

 while ((ch = getopt(argc, argv, egpfb:s:o:u)) != -1) {
 switch (ch) {

 @@ -148,10 +157,12 @@ main(int argc, char *argv[])
 break;

 case 'b':
 +   bflag = optarg;
 builddir = optarg;
 break;

 case 's':
 +   sflag = optarg;
 srcdir = optarg;
 break;

 Index: mkmakefile.c
 ===
 RCS file: /build/data/openbsd/cvs/src/usr.sbin/config/mkmakefile.c,v
 retrieving revision 1.37
 diff -u -p -r1.37 mkmakefile.c
 --- mkmakefile.c17 Sep 2012 17:36:13 -  1.37
 +++ mkmakefile.c28 Oct 2013 17:57:38 -
 @@ -60,6 +60,7 @@
  static const char *srcpath(struct files *);

  static int emitdefs(FILE *);
 +static int emitreconfig(FILE *);
  static int emitfiles(FILE *, int);

  static int emitobjs(FILE *);
 @@ -120,6 +121,10 @@ mkmakefile(void)
 if ((*fn)(ofp))
 goto wrerror;
 }
 +   if (startdir != NULL) {
 +   if (emitreconfig(ofp) != 0)
 +   goto wrerror;
 +   }
 if (ferror(ifp)) {
 (void)fprintf(stderr,
 config: error reading %s (at line %d): %s\n,
 @@ -271,6 +276,33 @@ emitdefs(FILE *fp)
 for (nv = mkoptions; nv != NULL; nv = nv-nv_next)
 if (fprintf(fp, %s=%s\n, nv-nv_name, nv-nv_str)  0)
 return (1);
 +   return (0);
 +}
 +
 +static int
 +emitreconfig(FILE *fp)
 +{
 +   if (fputs(\n
 +   .PHONY: config\n
 +   config:\n, fp)  0)
 +   return (1);
 +   if (fprintf(fp, \tcd %s  config , startdir)  0)
 +   return (1);
 +   if (pflag) {
 +   if (fputs(-p , fp)  0)
 +   return (1);
 +   }
 +   if (sflag) {
 +   if (fprintf(fp, -s %s , sflag)  0)
 +   return (1);
 +   }
 +   if (bflag) {
 +   if (fprintf(fp, -b %s , bflag)  0)
 +   return (1);
 +   }
 +   /* other options */
 +   if (fprintf(fp, %s\n, conffile)  0)
 +   return (1);
 return (0);
  }

Reads and runs fine here on i386. Handy, thanks.

--
  WBR,
  Vadim Zhukov



V3 Re: config(8) 'make config' v2

2013-10-28 Thread Marc Espie
Backforth with Theo. A bit more logic.
Most trees are moveable, and it's possible to
do so when -b is not in use...

Index: config.h
===
RCS file: /build/data/openbsd/cvs/src/usr.sbin/config/config.h,v
retrieving revision 1.25
diff -u -p -r1.25 config.h
--- config.h5 Dec 2012 23:20:26 -   1.25
+++ config.h28 Oct 2013 07:44:56 -
@@ -339,6 +339,10 @@ void   defoption(const char *name);
 intdevbase_has_instances(struct devbase *, int);
 intdeva_has_instances(struct deva *, int);
 void   setupdirs(void);
+intpflag;
+char   *sflag;
+char   *bflag;
+char   *startdir;
 
 /* mkheaders.c */
 intmkheaders(void);
Index: main.c
===
RCS file: /build/data/openbsd/cvs/src/usr.sbin/config/main.c,v
retrieving revision 1.44
diff -u -p -r1.44 main.c
--- main.c  22 Jun 2012 22:02:29 -  1.44
+++ main.c  28 Oct 2013 18:36:33 -
@@ -93,13 +93,19 @@ usage(void)
exit(1);
 }
 
+int pflag = 0;
+char *sflag = NULL;
+char *bflag = NULL;
+char *startdir;
+
 int
 main(int argc, char *argv[])
 {
char *p;
const char *last_component;
char *outfile = NULL;
-   int pflag, ch, eflag, uflag, fflag;
+   int ch, eflag, uflag, fflag;
+   char dirbuffer[PATH_MAX];
 
pflag = eflag = uflag = fflag = 0;
while ((ch = getopt(argc, argv, egpfb:s:o:u)) != -1) {
@@ -148,10 +154,12 @@ main(int argc, char *argv[])
break;
 
case 'b':
+   bflag = optarg;
builddir = optarg;
break;
 
case 's':
+   sflag = optarg;
srcdir = optarg;
break;
 
@@ -163,7 +171,15 @@ main(int argc, char *argv[])
argc -= optind;
argv += optind;
if (argc  1 || (eflag  argv[0] == NULL))
+
usage();
+   if (bflag) {
+   startdir = getcwd(dirbuffer, sizeof dirbuffer);
+   if (startdir == NULL)
+   warn(Use of -b and can't getcwd, no make config);
+   } else {
+   startdir = ../../conf;
+   }
 
if (eflag) {
 #ifdef MAKE_BOOTSTRAP
Index: mkmakefile.c
===
RCS file: /build/data/openbsd/cvs/src/usr.sbin/config/mkmakefile.c,v
retrieving revision 1.37
diff -u -p -r1.37 mkmakefile.c
--- mkmakefile.c17 Sep 2012 17:36:13 -  1.37
+++ mkmakefile.c28 Oct 2013 18:36:46 -
@@ -60,6 +60,7 @@
 static const char *srcpath(struct files *);
 
 static int emitdefs(FILE *);
+static int emitreconfig(FILE *);
 static int emitfiles(FILE *, int);
 
 static int emitobjs(FILE *);
@@ -120,6 +121,10 @@ mkmakefile(void)
if ((*fn)(ofp))
goto wrerror;
}
+   if (startdir != NULL) {
+   if (emitreconfig(ofp) != 0)
+   goto wrerror;
+   }
if (ferror(ifp)) {
(void)fprintf(stderr,
config: error reading %s (at line %d): %s\n,
@@ -271,6 +276,33 @@ emitdefs(FILE *fp)
for (nv = mkoptions; nv != NULL; nv = nv-nv_next)
if (fprintf(fp, %s=%s\n, nv-nv_name, nv-nv_str)  0)
return (1);
+   return (0);
+}
+
+static int
+emitreconfig(FILE *fp)
+{
+   if (fputs(\n
+   .PHONY: config\n
+   config:\n, fp)  0)
+   return (1);
+   if (fprintf(fp, \tcd %s  config , startdir)  0)
+   return (1);
+   if (pflag) {
+   if (fputs(-p , fp)  0)
+   return (1);
+   }
+   if (sflag) {
+   if (fprintf(fp, -s %s , sflag)  0)
+   return (1);
+   }
+   if (bflag) {
+   if (fprintf(fp, -b %s , bflag)  0)
+   return (1);
+   }
+   /* other options */
+   if (fprintf(fp, %s\n, conffile)  0)
+   return (1);
return (0);
 }