Browse Source

delinted, added chstack.c

ceriel 35 years ago
parent
commit
d6878e6125
4 changed files with 88 additions and 14 deletions
  1. 1 0
      mach/xenix3/cv/.distr
  2. 8 3
      mach/xenix3/cv/Makefile
  3. 75 0
      mach/xenix3/cv/chstack.c
  4. 4 11
      mach/xenix3/cv/cv.c

+ 1 - 0
mach/xenix3/cv/.distr

@@ -1,2 +1,3 @@
 cv.c
+chstack.c
 Makefile

+ 8 - 3
mach/xenix3/cv/Makefile

@@ -2,24 +2,29 @@ EMHOME =	../../..
 LIBOBJ =	$(EMHOME)/modules/lib/libobject.a
 INCLUDE =	$(EMHOME)/h
 CFLAGS =	-I. -I$(INCLUDE) -O
-TARGETS =	cv
+TARGETS =	cv chstack
 
 all:		$(TARGETS)
 
 install:	all
 		../../install cv
+		../../install chstack
 
 cmp:		all
-		../../compare cv
+		-../../compare cv
+		-../../compare chstack
 
 cv:	cv.o
 		$(CC) $(LDFLAGS) -o cv cv.o $(LIBOBJ)
 
+chstack:	chstack.o
+		$(CC) $(LDFLAGS) -o chstack chstack.o
+
 clean:
 		rm -f $(TARGETS) *.o nohup.out Out
 
 pr:
-		@pr Makefile cv.c
+		@pr Makefile cv.c chstack.c
 
 opr:
 		make pr | opr

+ 75 - 0
mach/xenix3/cv/chstack.c

@@ -0,0 +1,75 @@
+/* chstack - set stack size */
+
+#include <stdio.h>
+
+#define OFF         48L		/* offset of stacksize in file */
+#define MAX	    32768L	/* maximum accepted stacksize */
+
+main(argc, argv)
+int argc;
+char *argv[];
+{
+  char *p;
+  long n;
+  int fd;
+  long current;
+  long old;
+  long atol(), lseek();
+
+  p = argv[1];
+  if (argc != 3 || (*p != '=' && *p != '+' && *p != '-')) {
+  	fprintf(stderr, "Usage: %s {=+-}amount file\n", argv[0]);
+	exit(1);
+  }
+  n = atol(p+1);
+
+  fd = open(argv[2], 2);
+  if (fd < 0) {
+	fprintf(stderr, "%s: cannot open %s\n", argv[0], argv[2]);
+	exit(1);
+  }
+
+  if (lseek(fd, OFF, 0) < 0 || getlong(fd, &current) < 0) {
+	fprintf(stderr, "%s: cannot read %s\n", argv[0], argv[2]);
+	exit(1);
+  }
+  old = current;
+  if (*p == '=') current = n;
+  else if (*p == '-') current -= n;
+  else current += n;
+
+  if (current > MAX || current <= 0) {
+	fprintf(stderr, "%s: resulting stack size %ld too large or too small\n", argv[0], current);
+	exit(1);
+  }
+  if (lseek(fd, OFF, 0) < 0 || putlong(fd, &current) < 0) {
+	fprintf(stderr, "%s: can't modify %s\n", argv[0], argv[2]);
+	exit(1);
+  }
+  printf("%s: Stack area changed from %ld to %ld bytes.\n",
+			 argv[2],  old, current);
+  exit(0);
+}
+
+getlong(fd, l)
+	long *l;
+{
+	char buf[4];
+
+	if (read(fd, buf, 4) < 4) return -1;
+	*l = ((((long)(buf[3]&0377)<<8)|(long)(buf[2]&0377)<<8)|(long)(buf[1]&0377)<<8)|(long)(buf[0]&0377);
+	return 0;
+}
+
+putlong(fd, l)
+	long *l;
+{
+	char buf[4];
+
+	buf[3] = *l >> 24;
+	buf[2] = *l >> 16;
+	buf[1] = *l >> 8;
+	buf[0] = *l;
+	if (write(fd, buf, 4) < 4) return -1;
+	return 0;
+}

+ 4 - 11
mach/xenix3/cv/cv.c

@@ -97,10 +97,9 @@ int	output;
 
 char *program ;
 
-char flag ;
-
 int sep_id;
 
+extern long lseek();
 #define TEXTSG	0
 #define ROMSG	1
 #define DATASG	2
@@ -114,12 +113,6 @@ main(argc, argv)
 	int	argc;
 	char	*argv[];
 {
-	register int		nsect;
-	long			magic ;
-	long			textsize ;
-	long			datasize ;
-	long			bsssize;
-	long			symstart;
 	long			stacksize = 0x1000;
 
 	output = 1;
@@ -373,7 +366,7 @@ emit_symtab()
 	long off = OFF_CHAR(outhead);
 	register char *p;
 
-	chars = malloc(outhead.oh_nchar);
+	chars = malloc((unsigned)(outhead.oh_nchar));
 	if (! chars) return 0;
 	names = (struct outname *)
 		malloc(outhead.oh_nname * sizeof(struct outname));
@@ -381,7 +374,7 @@ emit_symtab()
 		free(chars);
 		return 0;
 	}
-	xptr = malloc(outhead.oh_nchar + 9 * outhead.oh_nname);
+	xptr = malloc((unsigned)(outhead.oh_nchar) + 9 * outhead.oh_nname);
 	if (! xptr) {
 		free(chars);
 		free((char *) names);
@@ -427,7 +420,7 @@ emit_symtab()
 				break;
 			default:
 				fprintf(stderr,"warning: unknown s_type: %d\n",
-					names[i].on_type & S_TYP);
+					(int)(names[i].on_type) & S_TYP);
 			}
 		}
 		if (names[i].on_type & S_EXT) xnm.s_type |= 0x20;