Plan 9 from Bell Labs’s /usr/web/sources/contrib/uriel/changes/2005/1106/7

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


64-bit fixes, also fix handling of times in archives.
 [rsc] --rw-rw-r-- M 451989 glenda sys 826 Nov  6 10:05 sys/src/cmd/mk/arc.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/arc.c:41,47 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/arc.c:41,47
	  
	  	sym = symlook("NREP", S_VAR, 0);
	  	if(sym){
	- 		w = (Word *) sym->value;
	+ 		w = sym->u.ptr;
	  		if (w && w->s && *w->s)
	  			nreps = atoi(w->s);
	  	}
 [rsc] --rw-rw-r-- M 451989 glenda sys 3071 Nov  6 10:05 sys/src/cmd/mk/archive.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/archive.c:18,38 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/archive.c:18,38
	  	t = mtime(archive);
	  	sym = symlook(archive, S_AGG, 0);
	  	if(sym){
	- 		if(force || (t > (long)sym->value)){
	+ 		if(force || t > sym->u.value){
	  			atimes(archive);
	- 			sym->value = (void *)t;
	+ 			sym->u.value = t;
	  		}
	  	}
	  	else{
	  		atimes(archive);
	  		/* mark the aggegate as having been done */
	- 		symlook(strdup(archive), S_AGG, "")->value = (void *)t;
	+ 		symlook(strdup(archive), S_AGG, "")->u.value = t;
	  	}
	  		/* truncate long member name to sizeof of name field in archive header */
	  	snprint(buf, sizeof(buf), "%s(%.*s)", archive, utfnlen(member, SARNAME), member);
	  	sym = symlook(buf, S_TIME, 0);
	  	if (sym)
	- 		return (long)sym->value;	/* uggh */
	+ 		return sym->u.value;
	  	return 0;
	  }
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/archive.c:82,91 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/archive.c:82,92
	  atimes(char *ar)
	  {
	  	struct ar_hdr h;
	- 	long t;
	+ 	long at, t;
	  	int fd, i;
	  	char buf[BIGBLOCK];
	- 
	+ 	Dir *d;
	+ 	
	  	fd = open(ar, OREAD);
	  	if(fd < 0)
	  		return;
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/archive.c:94,102 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/archive.c:95,111
	  		close(fd);
	  		return;
	  	}
	+ 	if((d = dirfstat(fd)) == nil){
	+ 		close(fd);
	+ 		return;
	+ 	}
	+ 	at = d->mtime;
	+ 	free(d);
	  	while(read(fd, (char *)&h, sizeof(h)) == sizeof(h)){
	  		t = atol(h.date);
	- 		if(t == 0)	/* as it sometimes happens; thanks ken */
	+ 		if(t >= at)	/* new things in old archives confuses mk */
	+ 			t = at-1;
	+ 		if(t <= 0)	/* as it sometimes happens; thanks ken */
	  			t = 1;
	  		for(i = sizeof(h.name)-1; i > 0 && h.name[i] == ' '; i--)
	  				;
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/archive.c:104,110 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/archive.c:113,119
	  			i--;
	  		h.name[i+1]=0;		/* can stomp on date field */
	  		sprint(buf, "%s(%s)", ar, h.name);
	- 		symlook(strdup(buf), S_TIME, (void *)t)->value = (void *)t;
	+ 		symlook(strdup(buf), S_TIME, (void*)t)->u.value = t;
	  		t = atol(h.size);
	  		if(t&01) t++;
	  		LSEEK(fd, t, 1);
 [rsc] --rw-rw-r-- M 451989 glenda sys 2281 Nov  6 10:05 sys/src/cmd/mk/env.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/env.c:79,85 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/env.c:79,85
	  	for(p = myenv; *p; p++)
	  		if(strcmp(*p, s->name) == 0)
	  			return;
	- 	envinsert(s->name, (Word *) s->value);
	+ 	envinsert(s->name, s->u.ptr);
	  }
	  
	  void
 [rsc] --rw-rw-r-- M 451989 glenda sys 1299 Nov  6 10:05 sys/src/cmd/mk/file.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/file.c:22,28 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/file.c:22,28
	  
	  	sym = symlook(name, S_TIME, 0);
	  	if (sym)
	- 		return (long) sym->value;		/* uggh */
	+ 		return sym->u.value;		/* uggh */
	  
	  	t = mkmtime(name, 0);
	  	if(t == 0)
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/file.c:76,82 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/file.c:76,82
	  		} while(*s);
	  		c = *s;
	  		*s = 0;
	- 		symlook(strdup(cp), S_TIME, (void *)t)->value = (void *)t;
	+ 		symlook(strdup(cp), S_TIME, (void *)t)->u.value = t;
	  		if (c)
	  			*s++ = c;
	  		while(*s){
 [rsc] --rw-rw-r-- M 451989 glenda sys 5822 Nov  6 10:05 sys/src/cmd/mk/graph.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/graph.c:40,46 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/graph.c:40,46
	  /*	print("applyrules(%lux='%s')\n", target, target);/**/
	  	sym = symlook(target, S_NODE, 0);
	  	if(sym)
	- 		return (Node *)(sym->value);
	+ 		return sym->u.ptr;
	  	target = strdup(target);
	  	node = newnode(target);
	  	head.n = 0;
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/graph.c:47,53 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/graph.c:47,53
	  	head.next = 0;
	  	sym = symlook(target, S_TARGET, 0);
	  	memset((char*)rmatch, 0, sizeof(rmatch));
	- 	for(r = sym? (Rule *)(sym->value):0; r; r = r->chain){
	+ 	for(r = sym? sym->u.ptr:0; r; r = r->chain){
	  		if(r->attr&META) continue;
	  		if(strcmp(target, r->target)) continue;
	  		if((!r->recipe || !*r->recipe) && (!r->tail || !r->tail->s || !*r->tail->s)) continue;	/* no effect; ignore */
 [rsc] --rw-rw-r-- M 451989 glenda sys 5330 Nov  6 10:05 sys/src/cmd/mk/mk.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/mk.c:217,227 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/mk.c:217,227
	  				str = strdup(buf);
	  			ret = pcmp(arc->prog, node->name, arc->n->name);
	  			if(sym)
	- 				sym->value = (void *)ret;
	+ 				sym->u.value = ret;
	  			else
	  				symlook(str, S_OUTOFDATE, (void *)ret);
	  		} else
	- 			ret = (int)(uintptr)sym->value;
	+ 			ret = sym->u.value;
	  		return(ret-1);
	  	} else if(strchr(arc->n->name, '(') && arc->n->time == 0)  /* missing archive member */
	  		return 1;
 [rsc] --rw-rw-r-- M 451989 glenda sys 3765 Nov  6 10:05 sys/src/cmd/mk/mk.h
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/mk.h:116,122 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/mk.h:116,125
	  {
	  	short		space;
	  	char		*name;
	- 	void		*value;
	+ 	union{
	+ 		void		*ptr;
	+ 		uintptr	value;
	+ 	} u;
	  	struct Symtab	*next;
	  } Symtab;
	  
 [rsc] --rw-rw-r-- M 451989 glenda sys 6941 Nov  6 10:05 sys/src/cmd/mk/plan9.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/plan9.c:49,55 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/plan9.c:49,55
	  			free(p);
	  			p = strdup(e[i].name);
	  			setvar(p, (void *) w);
	- 			symlook(p, S_EXPORTED, (void*)"")->value = (void*)"";
	+ 			symlook(p, S_EXPORTED, (void*)"")->u.ptr = "";
	  		}
	  		free(e);
	  	}
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/plan9.c:346,352 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/plan9.c:346,351
	  dirtime(char *dir, char *path)
	  {
	  	int i, fd, n;
	- 	void *t;
	  	Dir *d;
	  	char buf[4096];
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/plan9.c:354,366 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/plan9.c:353,364
	  	if(fd >= 0){
	  		while((n = dirread(fd, &d)) > 0){
	  			for(i=0; i<n; i++){
	- 				t = (void*)d[i].mtime;
	- 				if(t == nil)
	+ 				if(d[i].mtime == 0)	/* yeah, this is likely */
	  					continue;
	  				sprint(buf, "%s%s", path, d[i].name);
	  				if(symlook(buf, S_TIME, 0))
	  					continue;
	- 				symlook(strdup(buf), S_TIME, t)->value = t;
	+ 				symlook(strdup(buf), S_TIME, (void*)d[i].mtime)->u.value = d[i].mtime;
	  			}
	  			free(d);
	  		}
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/plan9.c:423,429 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/plan9.c:421,427
	  	if(!force){
	  		sym = symlook(name, S_TIME, 0);
	  		if(sym)
	- 			return (ulong)sym->value;
	+ 			return sym->u.value;
	  		return 0;
	  	}
	  	if((d = dirstat(name)) == nil)
 [rsc] --rw-rw-r-- M 451989 glenda sys 2543 Nov  6 10:05 sys/src/cmd/mk/recipe.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/recipe.c:63,69 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/recipe.c:63,69
	  			aw = aw->next;
	  			if((s = symlook(buf, S_NODE, 0)) == 0)
	  				continue;	/* not a node we are interested in */
	- 			n = (Node *)s->value;
	+ 			n = s->u.ptr;
	  			if(aflag == 0 && n->time) {
	  				for(a = n->prereqs; a; a = a->next)
	  					if(a->n && outofdate(n, a, 0))
 [rsc] --rw-rw-r-- M 451989 glenda sys 1946 Nov  6 10:05 sys/src/cmd/mk/rule.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/rule.c:15,21 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/rule.c:15,21
	  	r = 0;
	  	reuse = 0;
	  	if(sym = symlook(head, S_TARGET, 0)){
	- 		for(r = (Rule *)sym->value; r; r = r->chain)
	+ 		for(r = sym->u.ptr; r; r = r->chain)
	  			if(rcmp(r, head, tail) == 0){
	  				reuse = 1;
	  				break;
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/rule.c:34,40 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/rule.c:34,40
	  	r->rule = nrules++;
	  
	  	if(!reuse){
	- 		rr = (Rule *)symlook(head, S_TARGET, (void *)r)->value;
	+ 		rr = symlook(head, S_TARGET, r)->u.ptr;
	  		if(rr != r){
	  			r->chain = rr->chain;
	  			rr->chain = r;
 [rsc] --rw-rw-r-- M 451989 glenda sys 5063 Nov  6 10:05 sys/src/cmd/mk/run.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/run.c:169,175 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/run.c:169,175
	  	for(w = j->t; w; w = w->next){
	  		if((s = symlook(w->s, S_NODE, 0)) == 0)
	  			continue;	/* not interested in this node */
	- 		update(uarg, (Node *)s->value);
	+ 		update(uarg, s->u.ptr);
	  	}
	  	if(nrunning < nproclimit)
	  		sched();
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/run.c:183,189 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/run.c:183,189
	  	Word *w;
	  
	  	if(sym = symlook("NPROC", S_VAR, 0)) {
	- 		w = (Word *) sym->value;
	+ 		w = sym->u.ptr;
	  		if (w && w->s && w->s[0])
	  			nproclimit = atoi(w->s);
	  	}
 [rsc] --rw-rw-r-- M 451989 glenda sys 1581 Nov  6 10:05 sys/src/cmd/mk/symtab.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/symtab.c:36,42 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/symtab.c:36,42
	  	s = (Symtab *)Malloc(sizeof(Symtab));
	  	s->space = space;
	  	s->name = sym;
	- 	s->value = install;
	+ 	s->u.ptr = install;
	  	s->next = hash[h];
	  	hash[h] = s;
	  	return(s);
 [rsc] --rw-rw-r-- M 451989 glenda sys 530 Nov  6 10:05 sys/src/cmd/mk/var.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/var.c:3,9 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/var.c:3,9
	  void
	  setvar(char *name, void *value)
	  {
	- 	symlook(name, S_VAR, value)->value = value;
	+ 	symlook(name, S_VAR, value)->u.ptr = value;
	  	symlook(name, S_MAKEVAR, (void*)"");
	  }
	  
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/var.c:13,19 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/var.c:13,19
	  	Word *w;
	  
	  	Bprint(&bout, "\t%s=", s->name);
	- 	for (w = (Word *) s->value; w; w = w->next)
	+ 	for (w = s->u.ptr; w; w = w->next)
	  		Bprint(&bout, "'%s'", w->s);
	  	Bprint(&bout, "\n");
	  }
 [rsc] --rw-rw-r-- M 451989 glenda sys 4425 Nov  6 10:05 sys/src/cmd/mk/varsub.c
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/varsub.c:66,72 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/varsub.c:66,72
	  	sym = symlook(name, S_VAR, 0);
	  	if(sym){
	  			/* check for at least one non-NULL value */
	- 		for (w = (Word*)sym->value; w; w = w->next)
	+ 		for (w = sym->u.ptr; w; w = w->next)
	  			if(w->s && *w->s)
	  				return wdup(w);
	  	}
	/n/sourcesdump/2005/1106/plan9/sys/src/cmd/mk/varsub.c:113,122 - 
	/n/sourcesdump/2005/1107/plan9/sys/src/cmd/mk/varsub.c:113,122
	  	*s = end+1;
	  	
	  	sym = symlook(buf->start, S_VAR, 0);
	- 	if(sym == 0 || sym->value == 0)
	+ 	if(sym == 0 || sym->u.value == 0)
	  		w = newword(buf->start);
	  	else
	- 		w = subsub((Word*) sym->value, cp, end);
	+ 		w = subsub(sym->u.ptr, cp, end);
	  	freebuf(buf);
	  	return w;
	  }


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.