Plan 9 from Bell Labs’s /usr/web/sources/contrib/uriel/changes/2005/1027/10

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


64-bit safety, minor cleanups.
 [rsc] --rw-rw-r-- M 320859 glenda sys 439 Oct 27 10:52 sys/src/libc/9sys/sbrk.c
	/n/sourcesdump/2005/1027/plan9/sys/src/libc/9sys/sbrk.c:13,21 - 
	/n/sourcesdump/2005/1028/plan9/sys/src/libc/9sys/sbrk.c:13,21
	  int
	  brk(void *p)
	  {
	- 	ulong bl;
	+ 	uintptr bl;
	  
	- 	bl = ((ulong)p + Round) & ~Round;
	+ 	bl = ((uintptr)p + Round) & ~Round;
	  	if(brk_((void*)bl) < 0)
	  		return -1;
	  	bloc = (char*)bl;
	/n/sourcesdump/2005/1027/plan9/sys/src/libc/9sys/sbrk.c:25,33 - 
	/n/sourcesdump/2005/1028/plan9/sys/src/libc/9sys/sbrk.c:25,33
	  void*
	  sbrk(ulong n)
	  {
	- 	ulong bl;
	+ 	uintptr bl;
	  
	- 	bl = ((ulong)bloc + Round) & ~Round;
	+ 	bl = ((uintptr)bloc + Round) & ~Round;
	  	if(brk_((void*)(bl+n)) < 0)
	  		return (void*)-1;
	  	bloc = (char*)bl + n;
 [rsc] --rw-rw-r-- M 320859 glenda sys 2625 Oct 27 10:52 sys/src/libc/9syscall/mkfile
	/n/sourcesdump/2005/1027/plan9/sys/src/libc/9syscall/mkfile:59,65 - 
	/n/sourcesdump/2005/1028/plan9/sys/src/libc/9syscall/mkfile:59,74
	  				MOVL AX,4(CX)'
	  			}
	  			echo RET
	- 		case sparc
	+ 		case amd64
	+ 			if(~ $i seek)
	+ 				echo TEXT _seek'(SB)', 1, '$0'
	+ 			if not
	+ 				echo TEXT $i'(SB)', 1, '$0'
	+ 			echo MOVQ RARG, 'a0+0(FP)'
	+ 			echo MOVQ '$'$n, RARG
	+ 			echo SYSCALL
	+ 			echo RET
	+ 		case sparc sparc64
	  			echo TEXT $i'(SB)', 1, '$0'
	  			echo MOVW R7, '0(FP)'
	  			echo MOVW '$'$n, R7
 [rsc] --rw-rw-r-- M 320859 glenda sys 180 Oct 27 10:51 sys/src/libc/alpha/_seek.c
	/n/sourcesdump/2005/1027/plan9/sys/src/libc/alpha/_seek.c:1,7 - 
	/n/sourcesdump/2005/1028/plan9/sys/src/libc/alpha/_seek.c:1,7
	  #include <u.h>
	  #include <libc.h>
	  
	- extern	long	_seek(vlong*, int, vlong, int);
	+ extern	int	_seek(vlong*, int, vlong, int);
	  
	  vlong
	  seek(int fd, vlong o, int p)
	/n/sourcesdump/2005/1027/plan9/sys/src/libc/alpha/_seek.c:9,14 - 
	/n/sourcesdump/2005/1028/plan9/sys/src/libc/alpha/_seek.c:9,14
	  	vlong l;
	  
	  	if(_seek(&l, fd, o, p) < 0)
	- 		l = -1;
	+ 		l = -1LL;
	  	return l;
	  }
 [rsc] --rw-rw-r-- M 320859 glenda sys 772 Oct 27 10:52 sys/src/libc/port/atexit.c
	/n/sourcesdump/2005/1027/plan9/sys/src/libc/port/atexit.c:3,14 - 
	/n/sourcesdump/2005/1028/plan9/sys/src/libc/port/atexit.c:3,16
	  
	  #define	NEXIT	33
	  
	- static Lock onexlock;
	- static struct
	- {
	+ typedef struct Onex Onex;
	+ struct Onex{
	  	void	(*f)(void);
	  	int	pid;
	- }onex[NEXIT];
	+ };
	+ 
	+ static Lock onexlock;
	+ Onex onex[NEXIT];
	  
	  atexit(void (*f)(void))
	  {
 [rsc] --rw-rw-r-- M 320859 glenda sys 30938 Oct 27 10:52 sys/src/libc/port/pool.c
	/n/sourcesdump/2005/1027/plan9/sys/src/libc/port/pool.c:435,440 - 
	/n/sourcesdump/2005/1028/plan9/sys/src/libc/port/pool.c:435,442
	  	sz += sizeof(Bhdr)+sizeof(Btail);
	  	if(sz < p->minblock)
	  		sz = p->minblock;
	+ 	if(sz < MINBLOCKSIZE)
	+ 		sz = MINBLOCKSIZE;
	  	sz = (sz+p->quantum-1)&~(p->quantum-1);
	  	return sz;
	  }
	/n/sourcesdump/2005/1027/plan9/sys/src/libc/port/pool.c:524,530 - 
	/n/sourcesdump/2005/1028/plan9/sys/src/libc/port/pool.c:526,532
	  	if(eq > q+4)
	  		eq = q+4;
	  	for(; q<eq; q++)
	- 		*q = datamagic[((ulong)q)%nelem(datamagic)];
	+ 		*q = datamagic[((ulong)(uintptr)q)%nelem(datamagic)];
	  
	  	return b;
	  }
	/n/sourcesdump/2005/1027/plan9/sys/src/libc/port/pool.c:834,840 - 
	/n/sourcesdump/2005/1028/plan9/sys/src/libc/port/pool.c:836,842
	  		if(eq > bq+4)
	  			eq = bq+4;
	  		for(q=bq; q<eq; q++){
	- 			if(*q != datamagic[((ulong)q)%nelem(datamagic)]){
	+ 			if(*q != datamagic[((uintptr)q)%nelem(datamagic)]){
	  				if(q == bq && *q == 0 && (p->flags & POOL_TOLERANCE)){
	  					printblock(p, b, "mem user overflow");
	  					continue;
	/n/sourcesdump/2005/1027/plan9/sys/src/libc/port/pool.c:962,969 - 
	/n/sourcesdump/2005/1028/plan9/sys/src/libc/port/pool.c:964,971
	  	Alloc *a;
	  	ulong *u;
	  
	- 	if((ulong)v&(sizeof(ulong)-1))
	- 		v = (char*)v - ((ulong)v&(sizeof(ulong)-1));
	+ 	if((uintptr)v&(sizeof(ulong)-1))
	+ 		v = (char*)v - ((uintptr)v&(sizeof(ulong)-1));
	  	u = v;
	  	while(u[-1] == ALIGN_MAGIC)
	  		u--;
	/n/sourcesdump/2005/1027/plan9/sys/src/libc/port/pool.c:1088,1094 - 
	/n/sourcesdump/2005/1028/plan9/sys/src/libc/port/pool.c:1090,1096
	  
	  	c = v;
	  	if(align){
	- 		off = (ulong)c%align;
	+ 		off = (uintptr)c%align;
	  		if(off != offset){
	  			c += offset - off;
	  			if(off > offset)
	/n/sourcesdump/2005/1027/plan9/sys/src/libc/port/pool.c:1133,1139 - 
	/n/sourcesdump/2005/1028/plan9/sys/src/libc/port/pool.c:1135,1141
	  	v = poolallocl(p, asize);
	  	if(v == nil)
	  		return nil;
	- 	if(span && (ulong)v/span != ((ulong)v+asize)/span){
	+ 	if(span && (uintptr)v/span != ((uintptr)v+asize)/span){
	  		/* try again */
	  		poolfreel(p, v);
	  		v = poolallocl(p, 2*asize);
	/n/sourcesdump/2005/1027/plan9/sys/src/libc/port/pool.c:1145,1154 - 
	/n/sourcesdump/2005/1028/plan9/sys/src/libc/port/pool.c:1147,1156
	  	 * figure out what pointer we want to return
	  	 */
	  	c = alignptr(v, align, offset);
	- 	if(span && (ulong)c/span != (ulong)(c+dsize-1)/span){
	- 		c += span - (ulong)c%span;
	+ 	if(span && (uintptr)c/span != (uintptr)(c+dsize-1)/span){
	+ 		c += span - (uintptr)c%span;
	  		c = alignptr(c, align, offset);
	- 		if((ulong)c/span != (ulong)(c+dsize-1)/span){
	+ 		if((uintptr)c/span != (uintptr)(c+dsize-1)/span){
	  			poolfreel(p, v);
	  			werrstr("cannot satisfy dsize %lud span %lud with align %lud+%ld", dsize, span, align, offset);
	  			return nil;
	/n/sourcesdump/2005/1027/plan9/sys/src/libc/port/pool.c:1455,1461 - 
	/n/sourcesdump/2005/1028/plan9/sys/src/libc/port/pool.c:1457,1463
	  	lp = v;
	  	elp = lp+size/4;
	  	while(lp < elp)
	- 		*lp++ = (sig<<24) ^ (long)v;
	+ 		*lp++ = (sig<<24) ^ (ulong)(uintptr)v;
	  	p = (uchar*)lp;
	  	ep = (uchar*)v+size;
	  	while(p<ep)


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].