Browse Source

forgot _sbrk(), _fstat(), _times()

eck 34 years ago
parent
commit
caea5fe61b

+ 4 - 0
mach/sun3/libsys/LIST

@@ -34,7 +34,9 @@ flock.s
 fork.s
 _fork.s
 Xstat.c
+_Xstat.c
 fstat.s
+_fstat.s
 fstatfs.s
 fsync.s
 ftime.c
@@ -107,6 +109,7 @@ recvmsg.s
 rename.s
 rmdir.s
 sbrk.s
+_sbrk.s
 select.s
 semsys.s
 send.s
@@ -147,6 +150,7 @@ sync.s
 syscall.s
 time.c
 times.c
+_times.c
 truncate.s
 umask.s
 unlink.s

+ 1 - 1
mach/sun3/libsys/Xstat.c

@@ -37,7 +37,7 @@ fstat(fd, buf)
 	char Xbuf[100];
 	int retval;
 
-	retval = _fstat(fd, Xbuf);
+	retval = __fstat(fd, Xbuf);
 	Xcvt(Xbuf, (char *)buf);
 	return retval;
 }

+ 32 - 0
mach/sun3/libsys/_Xstat.c

@@ -0,0 +1,32 @@
+#include <sys/types.h>
+#include <sys/stat.h>
+
+static	Xcvt();
+
+int
+_fstat(fd, buf)
+	int fd;
+	struct stat *buf;
+{
+	char Xbuf[100];
+	int retval;
+
+	retval = __fstat(fd, Xbuf);
+	Xcvt(Xbuf, (char *)buf);
+	return retval;
+}
+
+static
+Xcvt(buf, statbuf)
+	char *buf, *statbuf;
+{
+	register char *s, *t;
+	register int i;
+
+	s = buf; t = statbuf;
+	*t++ = *s++; *t++ = *s++;
+	*t++ = 0; *t++ = 0;
+	for (i = 14; i; i--) *t++ = *s++;
+	*t++ = 0; *t++ = 0;
+	for (i = 44; i; i--) *t++ = *s++;
+}

+ 41 - 0
mach/sun3/libsys/_sbrk.s

@@ -0,0 +1,41 @@
+#include "syscall.h"
+.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text
+.define __sbrk,__brk
+__sbrk:
+	move.l	(4,sp),d0
+	add.l	#3,d0
+	move.l	#~3,d1
+	and.l	d1,d0
+	move.l	d0,a0
+	move.l	(curbrk),d0
+	add.l	#3,d0
+	and.l	d1,d0
+	move.l	d0,(curbrk)
+	add.l	d0,a0
+	move.l	a0,(4,sp)
+	pea	(17)	! not SYS_sbrk
+	trap	#0
+	bcs	1f
+	move.l	(curbrk),d0
+	move.l	(4,sp),(curbrk)
+	rts
+1:
+	jmp	(cerror)
+
+__brk:
+	move.l	(4,sp),d0
+	add.l	#3,d0
+	move.l	#~3,d1
+	and.l	d1,d0
+	move.l	d0,(4,sp)
+	pea	(17)
+	trap	#0
+	bcs	1f
+	move.l	(4,sp),(curbrk)
+	clr.l	d0
+	rts
+1:
+	jmp	(cerror)
+
+.sect .data
+curbrk:	.data4 endbss

+ 16 - 0
mach/sun3/libsys/_times.c

@@ -0,0 +1,16 @@
+#include <sys/types.h>
+
+#define Xval(xx)	((xx).l1*60+(xx).l2/(100000/6))
+
+_times(bp)
+	struct { time_t l1,l2,l3,l4;} *bp;
+{
+	struct { struct { long l1,l2; }s1,s2; long x[20]; } t;
+	if (_getrusage(0,&t) < 0) return -1;
+	bp->l1 = Xval(t.s1);
+	bp->l2 = Xval(t.s2);
+	if (_getrusage(-1,&t) < 0) return -1;
+	bp->l3 = Xval(t.s1);
+	bp->l4 = Xval(t.s2);
+	return 0;
+}

+ 2 - 2
mach/sun3/libsys/fstat.s

@@ -1,4 +1,4 @@
 #include "syscall.h"
 .sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text
-.define __fstat
-__fstat: SYSTEM(SYS_fstat)
+.define ___fstat
+___fstat: SYSTEM(SYS_fstat)