Bell 32V development
authorTom London <tbl@research.uucp>
Wed, 29 Nov 1978 04:52:50 +0000 (23:52 -0500)
committerTom London <tbl@research.uucp>
Wed, 29 Nov 1978 04:52:50 +0000 (23:52 -0500)
Work on file usr/src/libc/sys/setuid.s
Work on file usr/src/libc/sys/signal.s
Work on file usr/src/libc/sys/stat.s
Work on file usr/src/libc/sys/stime.s
Work on file usr/src/libc/gen/strcat.c
Work on file usr/src/libc/gen/strcatn.c
Work on file usr/src/libc/gen/strcmp.c
Work on file usr/src/libc/gen/strcmpn.c
Work on file usr/src/libc/gen/strcpy.c
Work on file usr/src/libc/gen/strcpyn.c
Work on file usr/src/libc/gen/strlen.c
Work on file usr/src/libc/gen/swab.c
Work on file usr/src/libc/sys/sync.s
Work on file usr/src/libc/sys/syscall.s

Co-Authored-By: John Reiser <jfr@research.uucp>
Synthesized-from: 32v

14 files changed:
usr/src/libc/gen/strcat.c [new file with mode: 0755]
usr/src/libc/gen/strcatn.c [new file with mode: 0644]
usr/src/libc/gen/strcmp.c [new file with mode: 0755]
usr/src/libc/gen/strcmpn.c [new file with mode: 0644]
usr/src/libc/gen/strcpy.c [new file with mode: 0644]
usr/src/libc/gen/strcpyn.c [new file with mode: 0644]
usr/src/libc/gen/strlen.c [new file with mode: 0644]
usr/src/libc/gen/swab.c [new file with mode: 0755]
usr/src/libc/sys/setuid.s [new file with mode: 0755]
usr/src/libc/sys/signal.s [new file with mode: 0644]
usr/src/libc/sys/stat.s [new file with mode: 0755]
usr/src/libc/sys/stime.s [new file with mode: 0755]
usr/src/libc/sys/sync.s [new file with mode: 0755]
usr/src/libc/sys/syscall.s [new file with mode: 0644]

diff --git a/usr/src/libc/gen/strcat.c b/usr/src/libc/gen/strcat.c
new file mode 100755 (executable)
index 0000000..9d2a52c
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Concatenate s2 on the end of s1.  S1's space must be large enough.
+ * Return s1.
+ */
+
+char *
+strcat(s1, s2)
+register char *s1, *s2;
+{
+       register char *os1;
+
+       os1 = s1;
+       while (*s1++)
+               ;
+       --s1;
+       while (*s1++ = *s2++)
+               ;
+       return(os1);
+}
diff --git a/usr/src/libc/gen/strcatn.c b/usr/src/libc/gen/strcatn.c
new file mode 100644 (file)
index 0000000..80e4a99
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Concatenate s2 on the end of s1.  S1's space must be large enough.
+ * At most n characters are moved.
+ * Return s1.
+ */
+
+char *
+strcatn(s1, s2, n)
+register char *s1, *s2;
+register n;
+{
+       register char *os1;
+
+       os1 = s1;
+       while (*s1++)
+               ;
+       --s1;
+       while (*s1++ = *s2++)
+               if (--n < 0) {
+                       *--s1 = '\0';
+                       break;
+               }
+       return(os1);
+}
diff --git a/usr/src/libc/gen/strcmp.c b/usr/src/libc/gen/strcmp.c
new file mode 100755 (executable)
index 0000000..3159719
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Compare strings:  s1>s2: >0  s1==s2: 0  s1<s2: <0
+ */
+
+strcmp(s1, s2)
+register char *s1, *s2;
+{
+
+       while (*s1 == *s2++)
+               if (*s1++=='\0')
+                       return(0);
+       return(*s1 - *--s2);
+}
diff --git a/usr/src/libc/gen/strcmpn.c b/usr/src/libc/gen/strcmpn.c
new file mode 100644 (file)
index 0000000..625fd15
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * Compare strings (at most n bytes):  s1>s2: >0  s1==s2: 0  s1<s2: <0
+ */
+
+strcmpn(s1, s2, n)
+register char *s1, *s2;
+register n;
+{
+
+       while (--n >= 0 && *s1 == *s2++)
+               if (*s1++ == '\0')
+                       return(0);
+       return(n<0 ? 0 : *s1 - *--s2);
+}
diff --git a/usr/src/libc/gen/strcpy.c b/usr/src/libc/gen/strcpy.c
new file mode 100644 (file)
index 0000000..da2acb5
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * Copy string s2 to s1.  s1 must be large enough.
+ * return s1
+ */
+
+char *
+strcpy(s1, s2)
+register char *s1, *s2;
+{
+       register char *os1;
+
+       os1 = s1;
+       while (*s1++ = *s2++)
+               ;
+       return(os1);
+}
diff --git a/usr/src/libc/gen/strcpyn.c b/usr/src/libc/gen/strcpyn.c
new file mode 100644 (file)
index 0000000..eebf2ac
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Copy s2 to s1, truncating or null-padding to always copy n bytes
+ * return s1
+ */
+
+char *
+strcpyn(s1, s2, n)
+register char *s1, *s2;
+{
+       register i;
+       register char *os1;
+
+       os1 = s1;
+       for (i = 0; i < n; i++)
+               if ((*s1++ = *s2++) == '\0') {
+                       while (++i < n)
+                               *s1++ = '\0';
+                       return(os1);
+               }
+       return(os1);
+}
diff --git a/usr/src/libc/gen/strlen.c b/usr/src/libc/gen/strlen.c
new file mode 100644 (file)
index 0000000..2abf6a5
--- /dev/null
@@ -0,0 +1,15 @@
+/*
+ * Returns the number of
+ * non-NULL bytes in string argument.
+ */
+
+strlen(s)
+register char *s;
+{
+       register n;
+
+       n = 0;
+       while (*s++)
+               n++;
+       return(n);
+}
diff --git a/usr/src/libc/gen/swab.c b/usr/src/libc/gen/swab.c
new file mode 100755 (executable)
index 0000000..9b11fe9
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * Swap bytes in 16-bit [half-]words
+ * for going between the 11 and the interdata
+ */
+
+swab(pf, pt, n)
+register short *pf, *pt;
+register n;
+{
+
+       n /= 2;
+       while (--n >= 0) {
+               *pt++ = (*pf << 8) + ((*pf >> 8) & 0377);
+               pf++;
+       }
+}
diff --git a/usr/src/libc/sys/setuid.s b/usr/src/libc/sys/setuid.s
new file mode 100755 (executable)
index 0000000..a866677
--- /dev/null
@@ -0,0 +1,16 @@
+# C library -- setuid
+
+# error = setuid(uid);
+
+       .set    setuid,23
+.globl _setuid
+.globl  cerror
+
+_setuid:
+       .word   0x0000
+       chmk    $setuid
+       bcc     noerror
+       jmp     cerror
+noerror:
+       clrl    r0
+       ret
diff --git a/usr/src/libc/sys/signal.s b/usr/src/libc/sys/signal.s
new file mode 100644 (file)
index 0000000..e365336
--- /dev/null
@@ -0,0 +1,19 @@
+# C library -- signal
+
+# signal(n, 0); /* default action on signal(n) */
+# signal(n, odd); /* ignore signal(n) */
+# signal(n, label); /* goto label on signal(n) */
+# returns old label, only one level.
+
+       .set    signal,48
+.globl _signal
+.globl  cerror
+
+       .align  1
+_signal:
+       .word   0x0000
+       chmk    $signal
+       bcc     noerror
+       jmp     cerror
+noerror:
+       ret
diff --git a/usr/src/libc/sys/stat.s b/usr/src/libc/sys/stat.s
new file mode 100755 (executable)
index 0000000..3d59d7e
--- /dev/null
@@ -0,0 +1,18 @@
+# C library -- stat
+
+# error = stat(string, statbuf);
+
+# char statbuf[36]
+
+       .set    stat,18
+.globl _stat
+.globl  cerror
+
+_stat:
+       .word   0x0000
+       chmk    $stat
+       bcc     noerror
+       jmp     cerror
+noerror:
+       clrl    r0
+       ret
diff --git a/usr/src/libc/sys/stime.s b/usr/src/libc/sys/stime.s
new file mode 100755 (executable)
index 0000000..294d0c5
--- /dev/null
@@ -0,0 +1,13 @@
+       .set    stime,25
+.globl _stime
+.globl  cerror
+
+_stime:
+       .word   0x0000
+       movl    *4(ap),4(ap)    # copy time to set
+       chmk    $stime
+       bcc     noerror
+       jmp     cerror
+noerror:
+       clrl    r0
+       ret
diff --git a/usr/src/libc/sys/sync.s b/usr/src/libc/sys/sync.s
new file mode 100755 (executable)
index 0000000..0617de7
--- /dev/null
@@ -0,0 +1,7 @@
+       .set    sync,36
+.globl _sync
+
+_sync:
+       .word   0x0000
+       chmk    $sync
+       ret
diff --git a/usr/src/libc/sys/syscall.s b/usr/src/libc/sys/syscall.s
new file mode 100644 (file)
index 0000000..8beda64
--- /dev/null
@@ -0,0 +1,11 @@
+       .globl  _syscall
+       .globl  cerror
+_syscall:
+       .word   0x0000
+       movl    4(ap),r0                # syscall number
+       subl3   $1,(ap)+,(ap)   # one fewer arguments
+       chmk    r0                              # do it
+       bcs             L1
+       ret
+L1:
+       jmp             cerror