Subject: remember that warning about __syscall()?
To: None <current-users@NetBSD.ORG>
From: Chris G Demetriou <Chris_G_Demetriou@ux2.sp.cs.cmu.edu>
List: current-users
Date: 12/22/1996 22:40:40
So, i goofed: the new stubs that used __syscall()
(i.e. /usr/src/lib/libc/sys/*.c) didn't work properly on big-endian
machines.

If you have a big endian machine, and have updated your source tree
between the time of this morning's (Dec. 22) sup scan (~4AM PST) and
the time of tomorrow morning's (Dec. 23) sup scan (same time 8-), then
you'll need the patch included below to build a working libc.

If you've not updated yet, i suggest you put it off until after
tomorrow morning's update.  You can tell if your system has broken
sources by:

	(1) checking for a prototype for __syscall() in
	    /usr/include/unistd.h, and

	(2) seeing if the sources named in the patch below look like
	    the 'old' revisions in the patches.

If both of those are true, then you might have this problem.


This shouldn't affect people with little-endian machines.


*sigh* I'm really sorry about any trouble i may have caused.  This has
apparently bitten at least one person.  It just wasn't tested on a
enough range of machines before it was checked in, and I should have
known better.  (Every once in a while, you do one or six things like
that, then you fix them and go back to being really cautious... 8-)


later, and happy holidays...


chris
===================================================================
Index: sys/ftruncate.c
===================================================================
RCS file: /cvsroot/src/lib/libc/sys/ftruncate.c,v
retrieving revision 1.5
diff -c -r1.5 ftruncate.c
*** ftruncate.c	1996/12/22 10:40:27	1.5
--- ftruncate.c	1996/12/23 02:51:25
***************
*** 54,59 ****
  	int	fd;
  	off_t	length;
  {
  
! 	return((int)__syscall((quad_t)SYS_ftruncate, fd, 0, length));
  }
--- 54,67 ----
  	int	fd;
  	off_t	length;
  {
+ 	quad_t q;
+ 	int rv;
  
! 	q = __syscall((quad_t)SYS_ftruncate, fd, 0, length);
! 	if (sizeof (quad_t) == sizeof (register_t) ||
! 	    BYTE_ORDER == LITTLE_ENDIAN)
! 		rv = (int)q;
! 	else
! 		rv = (int)(q >> 32);
! 	return rv;
  }
Index: sys/mmap.c
===================================================================
RCS file: /cvsroot/src/lib/libc/sys/mmap.c,v
retrieving revision 1.5
diff -c -r1.5 mmap.c
*** mmap.c	1996/12/20 20:17:26	1.5
--- mmap.c	1996/12/23 02:51:25
***************
*** 59,65 ****
  	int	fd;
  	off_t	offset;
  {
  
! 	return((caddr_t)(long)__syscall((quad_t)SYS_mmap, addr, len, prot,
! 	    flags, fd, 0, offset));
  }
--- 59,72 ----
  	int	fd;
  	off_t	offset;
  {
+ 	quad_t q;
+ 	caddr_t rv;
  
! 	q = __syscall((quad_t)SYS_mmap, addr, len, prot, flags, fd, 0, offset);
! 	if (sizeof (quad_t) == sizeof (register_t) ||
! 	    BYTE_ORDER == LITTLE_ENDIAN)
! 		rv = (caddr_t)(long)q;
! 	else
! 		rv = (caddr_t)(long)(q >> 32);
! 	return rv;
  }
Index: sys/truncate.c
===================================================================
RCS file: /cvsroot/src/lib/libc/sys/truncate.c,v
retrieving revision 1.6
diff -c -r1.6 truncate.c
*** truncate.c	1996/12/22 10:40:30	1.6
--- truncate.c	1996/12/23 02:51:25
***************
*** 54,59 ****
  	const char *path;
  	off_t length;
  {
  
! 	return((int)__syscall((quad_t)SYS_truncate, path, 0, length));
  }
--- 54,67 ----
  	const char *path;
  	off_t length;
  {
+ 	quad_t q;
+ 	int rv;
  
! 	q = __syscall((quad_t)SYS_truncate, path, 0, length);
! 	if (sizeof (quad_t) == sizeof (register_t) ||
! 	    BYTE_ORDER == LITTLE_ENDIAN)
! 		rv = (int)q;
! 	else
! 		rv = (int)(q >> 32);
! 	return rv;
  }