[4488] in Athena Bugs

home help back first fref pref prev next nref lref last post

RT /usr/etc/config changes

daemon@ATHENA.MIT.EDU (John Carr)
Sat Mar 10 04:59:33 1990

To: bugs@ATHENA.MIT.EDU
Date: Sat, 10 Mar 90 04:59:10 EST
From: John Carr <jfc@ATHENA.MIT.EDU>

This message includes two changes to config and the kernel build on
the RT:

	1. Patches to config to work with the 6.4R sprintf() (which returns
	   int, not char *).

	2. A program to inline some kernel functions (mostly spl?()) and
	   changes to config to use it in the build.  Someone should check
	   the definitions in this program carefully before installing it in
	   the sources (I've built and run a kernel with this, but it's
	   possible there's a bug that hasn't been hit yet).

*** src/config.h	Mon May  9 17:09:41 1988
--- config.h	Sat Mar 10 02:09:52 1990
***************
*** 136,142 ****
  char	*malloc();
  char	*strcpy();
  char	*strcat();
- char	*sprintf();
  
  #if MACHINE_VAX
  int	seen_mba, seen_uba;
--- 136,141 ----
*** src/config.y	Mon May  9 17:09:42 1988
--- config.y	Sat Mar 10 04:10:05 1990
***************
*** 350,356 ****
  	ID
  	      = { $$ = val_id = ns($1); } |
  	NUMBER
! 	      = { char nb[16]; $$ = val_id = ns(sprintf(nb, "%d", $1)); };
  
  
  Save_id:
--- 350,356 ----
  	ID
  	      = { $$ = val_id = ns($1); } |
  	NUMBER
! 	      = { char nb[16]; $$ = val_id = ns((sprintf(nb, "%d", $1),nb)); };
  
  
  Save_id:
***************
*** 412,420 ****
  Con_info:
  	AT Dev NUMBER
  	      = {
! 		if (eq(cur.d_name, "mba") || eq(cur.d_name, "uba"))
! 			yyerror(sprintf(errbuf,
! 			    "%s must be connected to a nexus", cur.d_name));
  		cur.d_conn = connect($2, $3);
  		} |
  	AT NEXUS NUMBER
--- 412,422 ----
  Con_info:
  	AT Dev NUMBER
  	      = {
! 		if (eq(cur.d_name, "mba") || eq(cur.d_name, "uba")) {
! 			sprintf(errbuf,
! 				"%s must be connected to a nexus", cur.d_name);
! 			yyerror(errbuf);
! 		}
  		cur.d_conn = connect($2, $3);
  		} |
  	AT NEXUS NUMBER
***************
*** 596,608 ****
  		if ((num != dp->d_unit) || !eq(dev, dp->d_name))
  			continue;
  		if (dp->d_type != CONTROLLER && dp->d_type != MASTER) {
! 			yyerror(sprintf(errbuf,
! 			    "%s connected to non-controller", dev));
  			return (0);
  		}
  		return (dp);
  	}
! 	yyerror(sprintf(errbuf, "%s %d not defined", dev, num));
  	return (0);
  }
  
--- 598,611 ----
  		if ((num != dp->d_unit) || !eq(dev, dp->d_name))
  			continue;
  		if (dp->d_type != CONTROLLER && dp->d_type != MASTER) {
! 			sprintf(errbuf, "%s connected to non-controller", dev);
! 			yyerror(errbuf);
  			return (0);
  		}
  		return (dp);
  	}
! 	sprintf(errbuf, "%s %d not defined", dev, num);
! 	yyerror(errbuf);
  	return (0);
  }
  
***************
*** 624,630 ****
  		if (eq(dp->d_name, dev))
  			break;
  	if (dp == 0) {
! 		yyerror(sprintf(errbuf, "no %s's to wildcard", dev));
  		return (0);
  	}
  	oldtype = dp->d_type;
--- 627,634 ----
  		if (eq(dp->d_name, dev))
  			break;
  	if (dp == 0) {
! 		sprintf(errbuf, "no %s's to wildcard", dev);
! 		yyerror(errbuf);
  		return (0);
  	}
  	oldtype = dp->d_type;
*** src/mkioconf.c	Mon May  9 17:09:43 1988
--- mkioconf.c	Sat Mar 10 02:13:15 1990
***************
*** 1070,1076 ****
  
  	if (dev->d_vec == 0)
  		return ("     0");
! 	return (sprintf(buf, "%sint%d", dev->d_name, dev->d_unit));
  }
  
  char *
--- 1070,1077 ----
  
  	if (dev->d_vec == 0)
  		return ("     0");
! 	sprintf(buf, "%sint%d", dev->d_name, dev->d_unit);
! 	return buf;
  }
  
  char *
***************
*** 1081,1085 ****
  		return ("'?'");
  	if (num == UNKNOWN)
  		return (" -1");
! 	return (sprintf(errbuf, "%3d", num));
  }
--- 1082,1087 ----
  		return ("'?'");
  	if (num == UNKNOWN)
  		return (" -1");
! 	sprintf(errbuf, "%3d", num);
! 	return errbuf;
  }
*** src/mkmakefile.c	Mon May  9 17:09:43 1988
--- mkmakefile.c	Sat Mar 10 03:40:47 1990
***************
*** 488,495 ****
  		case MACHINE_SUN:
  		case MACHINE_IBM370:
  		case MACHINE_IBM032:
! 			fprintf(f, "\t${CC} -I. -c -O ${COPTS} %s../%sc\n\n",
  				extras, np);
  			break;
  		}
  		break;
--- 488,498 ----
  		case MACHINE_SUN:
  		case MACHINE_IBM370:
  		case MACHINE_IBM032:
! 			fprintf(f, "\t${CC} -I. -S -O ${COPTS} %s../%sc\n",
  				extras, np);
+ 			fprintf(f, "\t../%s/inline/inline %ss | ${AS} -o %so || ${AS} %ss -o %so\n",
+ 				machinename, tp, tp, tp, tp);
+ 			fprintf(f, "\trm -f %ss\n\n", tp);
  			break;
  		}
  		break;
***************
*** 514,521 ****
  
  		case MACHINE_IBM032:
  			fprintf(f,
! 				"\t${CCDRIVER} -I. -c -O ${COPTS} %s../%sc\n\n",
  				extras, np);
  			break;
  		}
  		break;
--- 517,526 ----
  
  		case MACHINE_IBM032:
  			fprintf(f,
! 				"\t${CCDRIVER} -I. -S -O ${COPTS} %s../%sc\n",
  				extras, np);
+ 			fprintf(f, "\t../%s/inline/inline %ss | ${AS} -o %so || ${AS} -o %so %ss\n\n",
+ 				machinename, tp, tp, tp, tp);
  			break;
  		}
  		break;


----------------------------------------------------------------
Here is the program (to be installed as sys/inline/inline):
----------------------------------------------------------------
/* A simple inlining filter for the RT */
/* Usage: a.out [input [output]] */

#include <stdio.h>
#include <strings.h>
#include <ctype.h>

struct op { char *name, *repl; };

struct op ops[] = 
{
  {"_._spl0",
     "\tmfs r14,r2\n\tni r3,r2,-8\n\tni r2,r2,7\n\tmts r14,r3\n"},
  {"_._spl1",
     "\tmfs r14,r2\n\tni r3,r2,-8\n\tni r2,r2,7\n\toi r3,r3,1\n\tmts r14,r3\n"},
  {"_._spl2",
     "\tmfs r14,r2\n\tni r3,r2,-8\n\tni r2,r2,7\n\toi r3,r3,2\n\tmts r14,r3\n"},
  {"_._spl3",
     "\tmfs r14,r2\n\tni r3,r2,-8\n\tni r2,r2,7\n\toi r3,r3,3\n\tmts r14,r3\n"},
  {"_._spl4",
     "\tmfs r14,r2\n\tni r3,r2,-8\n\tni r2,r2,7\n\toi r3,r3,4\n\tmts r14,r3\n"},
  {"_._spl5",
     "\tmfs r14,r2\n\tni r3,r2,-8\n\tni r2,r2,7\n\toi r3,r3,5\n\tmts r14,r3\n"},
  {"_._spl6",
     "\tmfs r14,r2\n\tni r3,r2,-8\n\tni r2,r2,7\n\toi r3,r3,6\n\tmts r14,r3\n"},
  {"_._spl7",
     "\tmfs r14,r2\n\tni r3,r2,-8\n\tni r2,r2,7\n\toi r3,r3,7\n\tmts r14,r3\n"},
  {"_.splimp",
     "\tmfs r14,r2\n\tni r3,r2,-8\n\tni r2,r2,7\n\toi r3,r3,2\n\tmts r14,r3\n"},
  {"_.splnet",
     "\tmfs r14,r2\n\tni r3,r2,-8\n\tni r2,r2,7\n\toi r3,r3,6\n\tmts r14,r3\n"},
  {"_.getspl","\tmfs r14,r2\n\tni r2,r2,7\n"},
  {"_.splx","\tnilz r2,r2,7\n\tmfs r14,r3\n\tni r3,r3,-8\n\to r2,r3\n\tmts r14,r2\n"},
  {"_.ior","\tior r2,0(r2)\n"},
  {"_.iow","\tiow r3,0(r2)\n"},
  {"_.setsoftint", "\tsetsb\tr12,22-16\n"},
  {0,0}};


char *match_call(char *line, int *isbrx, int *len)
{
  while(isspace(*line))
    line++;
#ifdef DEBUG
  fprintf(stderr,"match_call(\"%s\")\n", line);
#endif
  if(line[0] == 'b' && line[1] == 'a' && line[2] == 'l' &&
     (line[3] == 'i' || line[3] == 'r'))
    {
      int ret;
      char *str;
      *isbrx = (line[4] == 'x');
      line = index(line+5, ',');
      if(line == 0)
	return 0;
      ret = 0;
      str = line + 1;
      while(*++line && !isspace(*line))
	ret++;
      *len = ret;
      return str;
    }
  return 0;
}

main(int argc, char *argv[])
{
  char in[BUFSIZ];

  switch(argc)
    {
    case 3:
      if(freopen(argv[2], "w", stdout) == NULL)
	{
	  perror("open(output)");
	  exit(2);
	}
    case 2:
      if(freopen(argv[1], "r", stdin) == NULL)
	{
	  perror("open(input)");
	  exit(3);
	}
    case 0:
    case 1:
      break;
    }
  while(fgets(in, sizeof(in), stdin))
    {
      int isbrx, len;
      char *fn = match_call(in, &isbrx, &len);
      if(fn == 0)
	{
	  fputs(in, stdout);
	  continue;
	} else {
	  struct op *o;
#ifdef DEBUG
	  fprintf(stderr, "matched \"%s\"\n", fn);
#endif
	  for(o = ops;o->name;o++)
	    if(!strncmp(o->name, fn, len))
	      {
		fputs(o->repl, stdout);
		if(isbrx)
		  (void)fgets(in, sizeof(in), stdin);
		goto xxx;
	      }
	  fputs(in, stdout);
	xxx:
	  ;
	}
    }
  exit(0);
}
----------------------------------------------------------------

Note: it is possible for the inserted code to turn 128 byte branches into
branches over 128 bytes (which makes the assembly fail).  The generated
makefile doesn't run the inline program in this case (that what the "||"
clause is for in mkmakefile.c).  I don't know if "as -J" would be a better
choice in this case.



home help back first fref pref prev next nref lref last post