summaryrefslogtreecommitdiffstats
path: root/sys/lib/libkern/arch/i386
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>1995-10-18 08:37:01 +0000
committerderaadt <deraadt@openbsd.org>1995-10-18 08:37:01 +0000
commitdf930be708d50e9715f173caa26ffe1b7599b157 (patch)
treeaa317e49e28cb999c9cf3db7f00c20903fe6010a /sys/lib/libkern/arch/i386
downloadwireguard-openbsd-df930be708d50e9715f173caa26ffe1b7599b157.tar.xz
wireguard-openbsd-df930be708d50e9715f173caa26ffe1b7599b157.zip
initial import of NetBSD tree
Diffstat (limited to 'sys/lib/libkern/arch/i386')
-rw-r--r--sys/lib/libkern/arch/i386/DEFS.h3
-rw-r--r--sys/lib/libkern/arch/i386/Makefile.inc5
-rw-r--r--sys/lib/libkern/arch/i386/SYS.h48
-rw-r--r--sys/lib/libkern/arch/i386/bcmp.S35
-rw-r--r--sys/lib/libkern/arch/i386/bzero.S46
-rw-r--r--sys/lib/libkern/arch/i386/ffs.S20
-rw-r--r--sys/lib/libkern/arch/i386/htonl.S52
-rw-r--r--sys/lib/libkern/arch/i386/htons.S50
-rw-r--r--sys/lib/libkern/arch/i386/locc.S47
-rw-r--r--sys/lib/libkern/arch/i386/ntohl.S52
-rw-r--r--sys/lib/libkern/arch/i386/ntohs.S50
-rw-r--r--sys/lib/libkern/arch/i386/scanc.S56
-rw-r--r--sys/lib/libkern/arch/i386/setjmp.S92
-rw-r--r--sys/lib/libkern/arch/i386/skpc.S47
-rw-r--r--sys/lib/libkern/arch/i386/strcat.S69
-rw-r--r--sys/lib/libkern/arch/i386/strcmp.S84
-rw-r--r--sys/lib/libkern/arch/i386/strcpy.S59
-rw-r--r--sys/lib/libkern/arch/i386/strlen.S23
18 files changed, 838 insertions, 0 deletions
diff --git a/sys/lib/libkern/arch/i386/DEFS.h b/sys/lib/libkern/arch/i386/DEFS.h
new file mode 100644
index 00000000000..78bb4a0872a
--- /dev/null
+++ b/sys/lib/libkern/arch/i386/DEFS.h
@@ -0,0 +1,3 @@
+/* $Id: DEFS.h,v 1.1.1.1 1995/10/18 08:52:51 deraadt Exp $ */
+
+#include <machine/asm.h>
diff --git a/sys/lib/libkern/arch/i386/Makefile.inc b/sys/lib/libkern/arch/i386/Makefile.inc
new file mode 100644
index 00000000000..533df315a66
--- /dev/null
+++ b/sys/lib/libkern/arch/i386/Makefile.inc
@@ -0,0 +1,5 @@
+# $NetBSD: Makefile.inc,v 1.7 1995/10/07 09:52:48 mycroft Exp $
+
+SRCS+= __main.c imax.c imin.c lmax.c lmin.c max.c min.c ulmax.c ulmin.c \
+ bcmp.S ffs.S strcat.S strcmp.S strcpy.S strlen.S strncmp.c \
+ strncpy.c scanc.S skpc.S locc.S htonl.S htons.S ntohl.S ntohs.S
diff --git a/sys/lib/libkern/arch/i386/SYS.h b/sys/lib/libkern/arch/i386/SYS.h
new file mode 100644
index 00000000000..16751278d92
--- /dev/null
+++ b/sys/lib/libkern/arch/i386/SYS.h
@@ -0,0 +1,48 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * from: @(#)SYS.h 5.5 (Berkeley) 5/7/91
+ * $Id: SYS.h,v 1.1.1.1 1995/10/18 08:52:51 deraadt Exp $
+ */
+
+#include <machine/asm.h>
+#include <sys/syscall.h>
+
+#define SYSCALL(x) .text; .align 2; 2: jmp PIC_PLT(cerror); ENTRY(x); movl $(SYS_/**/x),%eax; int $0x80; jc 2b
+#define RSYSCALL(x) SYSCALL(x); ret
+#define PSEUDO(x,y) ENTRY(x); movl $(SYS_/**/y),%eax; int $0x80; ret
+#define CALL(x,y) call PIC_PLT(_/**/y); addl $4*x,%esp
+
+ .globl cerror
diff --git a/sys/lib/libkern/arch/i386/bcmp.S b/sys/lib/libkern/arch/i386/bcmp.S
new file mode 100644
index 00000000000..12d344216cc
--- /dev/null
+++ b/sys/lib/libkern/arch/i386/bcmp.S
@@ -0,0 +1,35 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+ RCSID("$NetBSD: bcmp.S,v 1.5 1995/10/07 09:27:01 mycroft Exp $")
+#endif
+
+ENTRY(bcmp)
+ pushl %edi
+ pushl %esi
+ movl 12(%esp),%edi
+ movl 16(%esp),%esi
+ xorl %eax,%eax /* clear return value */
+ cld /* set compare direction forward */
+
+ movl 20(%esp),%ecx /* compare by words */
+ shrl $2,%ecx
+ repe
+ cmpsl
+ jne L1
+
+ movl 20(%esp),%ecx /* compare remainder by bytes */
+ andl $3,%ecx
+ repe
+ cmpsb
+ je L2
+
+L1: incl %eax
+L2: popl %esi
+ popl %edi
+ ret
diff --git a/sys/lib/libkern/arch/i386/bzero.S b/sys/lib/libkern/arch/i386/bzero.S
new file mode 100644
index 00000000000..64a96c519bb
--- /dev/null
+++ b/sys/lib/libkern/arch/i386/bzero.S
@@ -0,0 +1,46 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+ RCSID("$NetBSD: bzero.S,v 1.5 1995/10/07 09:27:02 mycroft Exp $")
+#endif
+
+ENTRY(bzero)
+ pushl %edi
+ movl 8(%esp),%edi
+ movl 12(%esp),%edx
+
+ cld /* set fill direction forward */
+ xorl %eax,%eax /* set fill data to 0 */
+
+ /*
+ * if the string is too short, it's really not worth the overhead
+ * of aligning to word boundries, etc. So we jump to a plain
+ * unaligned set.
+ */
+ cmpl $16,%edx
+ jb L1
+
+ movl %edi,%ecx /* compute misalignment */
+ negl %ecx
+ andl $3,%ecx
+ subl %ecx,%edx
+ rep /* zero until word aligned */
+ stosb
+
+ movl %edx,%ecx /* zero by words */
+ shrl $2,%ecx
+ andl $3,%edx
+ rep
+ stosl
+
+L1: movl %edx,%ecx /* zero remainder by bytes */
+ rep
+ stosb
+
+ popl %edi
+ ret
diff --git a/sys/lib/libkern/arch/i386/ffs.S b/sys/lib/libkern/arch/i386/ffs.S
new file mode 100644
index 00000000000..cf4daaa7fbb
--- /dev/null
+++ b/sys/lib/libkern/arch/i386/ffs.S
@@ -0,0 +1,20 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+ RCSID("$NetBSD: ffs.S,v 1.5 1995/10/07 09:27:03 mycroft Exp $")
+#endif
+
+ENTRY(ffs)
+ bsfl 4(%esp),%eax
+ jz L1 /* ZF is set if all bits are 0 */
+ incl %eax /* bits numbered from 1, not 0 */
+ ret
+
+ .align 2
+L1: xorl %eax,%eax /* clear result */
+ ret
diff --git a/sys/lib/libkern/arch/i386/htonl.S b/sys/lib/libkern/arch/i386/htonl.S
new file mode 100644
index 00000000000..c150521a8c2
--- /dev/null
+++ b/sys/lib/libkern/arch/i386/htonl.S
@@ -0,0 +1,52 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * from: @(#)htonl.s 5.3 (Berkeley) 12/17/90
+ * $Id: htonl.S,v 1.1.1.1 1995/10/18 08:52:51 deraadt Exp $
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+RCSID("$Id: htonl.S,v 1.1.1.1 1995/10/18 08:52:51 deraadt Exp $")
+#endif
+
+/* netorder = htonl(hostorder) */
+ENTRY(htonl)
+ movl 4(%esp),%eax
+ rorw $8,%ax
+ roll $16,%eax
+ rorw $8,%ax
+ ret
diff --git a/sys/lib/libkern/arch/i386/htons.S b/sys/lib/libkern/arch/i386/htons.S
new file mode 100644
index 00000000000..fa12dedb3c3
--- /dev/null
+++ b/sys/lib/libkern/arch/i386/htons.S
@@ -0,0 +1,50 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * from: @(#)htons.s 5.2 (Berkeley) 12/17/90
+ * $Id: htons.S,v 1.1.1.1 1995/10/18 08:52:52 deraadt Exp $
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+RCSID("$Id: htons.S,v 1.1.1.1 1995/10/18 08:52:52 deraadt Exp $")
+#endif
+
+/* netorder = htons(hostorder) */
+ENTRY(htons)
+ movzwl 4(%esp),%eax
+ rorw $8,%ax
+ ret
diff --git a/sys/lib/libkern/arch/i386/locc.S b/sys/lib/libkern/arch/i386/locc.S
new file mode 100644
index 00000000000..ad63e8864dc
--- /dev/null
+++ b/sys/lib/libkern/arch/i386/locc.S
@@ -0,0 +1,47 @@
+/* $NetBSD: locc.S,v 1.2 1994/10/26 06:39:10 cgd Exp $ */
+
+/*
+ * Copyright (c) 1994 Charles Hannum. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Charles Hannum.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "DEFS.h"
+
+ENTRY(locc)
+ pushl %edi
+ movl 16(%esp),%edi
+ movl 12(%esp),%ecx
+ movl 8(%esp),%eax
+ cld
+ repne
+ scasb
+ jne 1f
+ incl %ecx
+1:
+ movl %ecx,%eax
+ popl %edi
+ ret
diff --git a/sys/lib/libkern/arch/i386/ntohl.S b/sys/lib/libkern/arch/i386/ntohl.S
new file mode 100644
index 00000000000..48a6b51b2fb
--- /dev/null
+++ b/sys/lib/libkern/arch/i386/ntohl.S
@@ -0,0 +1,52 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * from: @(#)ntohl.s 5.2 (Berkeley) 12/17/90
+ * $Id: ntohl.S,v 1.1.1.1 1995/10/18 08:52:52 deraadt Exp $
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+RCSID("$Id: ntohl.S,v 1.1.1.1 1995/10/18 08:52:52 deraadt Exp $")
+#endif
+
+/* hostorder = ntohl(netorder) */
+ENTRY(ntohl)
+ movl 4(%esp),%eax
+ rorw $8,%ax
+ roll $16,%eax
+ rorw $8,%ax
+ ret
diff --git a/sys/lib/libkern/arch/i386/ntohs.S b/sys/lib/libkern/arch/i386/ntohs.S
new file mode 100644
index 00000000000..98b6e5b191d
--- /dev/null
+++ b/sys/lib/libkern/arch/i386/ntohs.S
@@ -0,0 +1,50 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * from: @(#)ntohs.s 5.2 (Berkeley) 12/17/90
+ * $Id: ntohs.S,v 1.1.1.1 1995/10/18 08:52:52 deraadt Exp $
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+RCSID("$Id: ntohs.S,v 1.1.1.1 1995/10/18 08:52:52 deraadt Exp $")
+#endif
+
+/* hostorder = ntohs(netorder) */
+ENTRY(ntohs)
+ movzwl 4(%esp),%eax
+ rorw $8,%ax
+ ret
diff --git a/sys/lib/libkern/arch/i386/scanc.S b/sys/lib/libkern/arch/i386/scanc.S
new file mode 100644
index 00000000000..e3beedb52a2
--- /dev/null
+++ b/sys/lib/libkern/arch/i386/scanc.S
@@ -0,0 +1,56 @@
+/* $NetBSD: scanc.S,v 1.5 1994/10/26 06:39:13 cgd Exp $ */
+
+/*
+ * Copyright (c) 1994 Charles Hannum. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Charles Hannum.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "DEFS.h"
+
+ENTRY(scanc)
+ movl 4(%esp),%ecx
+ testl %ecx,%ecx
+ jz 3f
+ pushl %esi
+ pushl %edi
+ movl 16(%esp),%esi
+ movl 20(%esp),%edi
+ movb 24(%esp),%dl
+ xorl %eax,%eax
+ cld
+1:
+ lodsb
+ testb %dl,(%eax,%edi)
+ jnz 2f
+ decl %ecx
+ jnz 1b
+2:
+ popl %edi
+ popl %esi
+3:
+ movl %ecx,%eax
+ ret
diff --git a/sys/lib/libkern/arch/i386/setjmp.S b/sys/lib/libkern/arch/i386/setjmp.S
new file mode 100644
index 00000000000..e81206cc623
--- /dev/null
+++ b/sys/lib/libkern/arch/i386/setjmp.S
@@ -0,0 +1,92 @@
+/* $NetBSD: setjmp.S,v 1.5 1994/10/26 06:39:14 cgd Exp $ */
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)setjmp.s 5.1 (Berkeley) 4/23/90
+ */
+
+#if defined(LIBC_SCCS)
+ .text
+ .asciz "$NetBSD: setjmp.S,v 1.5 1994/10/26 06:39:14 cgd Exp $"
+#endif
+
+/*
+ * C library -- _setjmp, _longjmp
+ *
+ * longjmp(a,v)
+ * will generate a "return(v)" from the last call to
+ * setjmp(a)
+ * by restoring registers from the stack.
+ * The previous signal state is restored.
+ */
+
+#include "DEFS.h"
+#include "SYS.h"
+
+ENTRY(setjmp)
+ pushl $0
+ call PIC_PLT(_sigblock)
+ popl %edx
+ movl 4(%esp),%ecx
+ movl 0(%esp),%edx
+ movl %edx, 0(%ecx)
+ movl %ebx, 4(%ecx)
+ movl %esp, 8(%ecx)
+ movl %ebp,12(%ecx)
+ movl %esi,16(%ecx)
+ movl %edi,20(%ecx)
+ movl %eax,24(%ecx)
+ xorl %eax,%eax
+ ret
+
+ENTRY(longjmp)
+ movl 4(%esp),%edx
+ pushl 24(%edx)
+ call PIC_PLT(_sigsetmask)
+ popl %eax
+ movl 4(%esp),%edx
+ movl 8(%esp),%eax
+ movl 0(%edx),%ecx
+ movl 4(%edx),%ebx
+ movl 8(%edx),%esp
+ movl 12(%edx),%ebp
+ movl 16(%edx),%esi
+ movl 20(%edx),%edi
+ testl %eax,%eax
+ jnz 1f
+ incl %eax
+1: movl %ecx,0(%esp)
+ ret
diff --git a/sys/lib/libkern/arch/i386/skpc.S b/sys/lib/libkern/arch/i386/skpc.S
new file mode 100644
index 00000000000..99e0e07b1ed
--- /dev/null
+++ b/sys/lib/libkern/arch/i386/skpc.S
@@ -0,0 +1,47 @@
+/* $NetBSD: skpc.S,v 1.2 1994/10/26 06:39:15 cgd Exp $ */
+
+/*
+ * Copyright (c) 1994 Charles Hannum. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Charles Hannum.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "DEFS.h"
+
+ENTRY(skpc)
+ pushl %edi
+ movl 16(%esp),%edi
+ movl 12(%esp),%ecx
+ movl 8(%esp),%eax
+ cld
+ repe
+ scasb
+ je 1f
+ incl %ecx
+1:
+ movl %ecx,%eax
+ popl %edi
+ ret
diff --git a/sys/lib/libkern/arch/i386/strcat.S b/sys/lib/libkern/arch/i386/strcat.S
new file mode 100644
index 00000000000..bd4c63914f2
--- /dev/null
+++ b/sys/lib/libkern/arch/i386/strcat.S
@@ -0,0 +1,69 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+ RCSID("$NetBSD: strcat.S,v 1.6 1995/10/07 09:27:08 mycroft Exp $")
+#endif
+
+/*
+ * NOTE: I've unrolled the loop eight times: large enough to make a
+ * significant difference, and small enough not to totally trash the
+ * cache.
+ */
+
+ENTRY(strcat)
+ pushl %edi /* save edi */
+ movl 8(%esp),%edi /* dst address */
+ movl 12(%esp),%edx /* src address */
+ pushl %edi /* push destination address */
+
+ cld /* set search forward */
+ xorl %eax,%eax /* set search for null terminator */
+ movl $-1,%ecx /* set search for lots of characters */
+ repne /* search! */
+ scasb
+
+ leal -1(%edi),%ecx /* correct dst address */
+
+ .align 2,0x90
+L1: movb (%edx),%al /* unroll loop, but not too much */
+ movb %al,(%ecx)
+ testb %al,%al
+ jz L2
+ movb 1(%edx),%al
+ movb %al,1(%ecx)
+ testb %al,%al
+ jz L2
+ movb 2(%edx),%al
+ movb %al,2(%ecx)
+ testb %al,%al
+ jz L2
+ movb 3(%edx),%al
+ movb %al,3(%ecx)
+ testb %al,%al
+ jz L2
+ movb 4(%edx),%al
+ movb %al,4(%ecx)
+ testb %al,%al
+ jz L2
+ movb 5(%edx),%al
+ movb %al,5(%ecx)
+ testb %al,%al
+ jz L2
+ movb 6(%edx),%al
+ movb %al,6(%ecx)
+ testb %al,%al
+ jz L2
+ movb 7(%edx),%al
+ movb %al,7(%ecx)
+ addl $8,%edx
+ addl $8,%ecx
+ testb %al,%al
+ jnz L1
+L2: popl %eax /* pop destination address */
+ popl %edi /* restore edi */
+ ret
diff --git a/sys/lib/libkern/arch/i386/strcmp.S b/sys/lib/libkern/arch/i386/strcmp.S
new file mode 100644
index 00000000000..963aa14b0a5
--- /dev/null
+++ b/sys/lib/libkern/arch/i386/strcmp.S
@@ -0,0 +1,84 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+ RCSID("$NetBSD: strcmp.S,v 1.6 1995/10/07 09:27:10 mycroft Exp $")
+#endif
+
+/*
+ * NOTE: I've unrolled the loop eight times: large enough to make a
+ * significant difference, and small enough not to totally trash the
+ * cache.
+ */
+
+ENTRY(strcmp)
+ movl 0x04(%esp),%eax
+ movl 0x08(%esp),%edx
+ jmp L2 /* Jump into the loop! */
+
+ .align 2,0x90
+L1: incl %eax
+ incl %edx
+L2: movb (%eax),%cl
+ testb %cl,%cl /* null terminator??? */
+ jz L3
+ cmpb %cl,(%edx) /* chars match??? */
+ jne L3
+ incl %eax
+ incl %edx
+ movb (%eax),%cl
+ testb %cl,%cl
+ jz L3
+ cmpb %cl,(%edx)
+ jne L3
+ incl %eax
+ incl %edx
+ movb (%eax),%cl
+ testb %cl,%cl
+ jz L3
+ cmpb %cl,(%edx)
+ jne L3
+ incl %eax
+ incl %edx
+ movb (%eax),%cl
+ testb %cl,%cl
+ jz L3
+ cmpb %cl,(%edx)
+ jne L3
+ incl %eax
+ incl %edx
+ movb (%eax),%cl
+ testb %cl,%cl
+ jz L3
+ cmpb %cl,(%edx)
+ jne L3
+ incl %eax
+ incl %edx
+ movb (%eax),%cl
+ testb %cl,%cl
+ jz L3
+ cmpb %cl,(%edx)
+ jne L3
+ incl %eax
+ incl %edx
+ movb (%eax),%cl
+ testb %cl,%cl
+ jz L3
+ cmpb %cl,(%edx)
+ jne L3
+ incl %eax
+ incl %edx
+ movb (%eax),%cl
+ testb %cl,%cl
+ jz L3
+ cmpb %cl,(%edx)
+ je L1
+ .align 2, 0x90
+L3: movzbl (%eax),%eax /* unsigned comparison */
+ movzbl (%edx),%edx
+ subl %edx,%eax
+ ret
diff --git a/sys/lib/libkern/arch/i386/strcpy.S b/sys/lib/libkern/arch/i386/strcpy.S
new file mode 100644
index 00000000000..e1531c1935a
--- /dev/null
+++ b/sys/lib/libkern/arch/i386/strcpy.S
@@ -0,0 +1,59 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+ RCSID("$NetBSD: strcpy.S,v 1.6 1995/10/07 09:27:11 mycroft Exp $")
+#endif
+
+/*
+ * NOTE: I've unrolled the loop eight times: large enough to make a
+ * significant difference, and small enough not to totally trash the
+ * cache.
+ */
+
+ENTRY(strcpy)
+ movl 4(%esp),%ecx /* dst address */
+ movl 8(%esp),%edx /* src address */
+ pushl %ecx /* push dst address */
+
+ .align 2,0x90
+L1: movb (%edx),%al /* unroll loop, but not too much */
+ movb %al,(%ecx)
+ testb %al,%al
+ jz L2
+ movb 1(%edx),%al
+ movb %al,1(%ecx)
+ testb %al,%al
+ jz L2
+ movb 2(%edx),%al
+ movb %al,2(%ecx)
+ testb %al,%al
+ jz L2
+ movb 3(%edx),%al
+ movb %al,3(%ecx)
+ testb %al,%al
+ jz L2
+ movb 4(%edx),%al
+ movb %al,4(%ecx)
+ testb %al,%al
+ jz L2
+ movb 5(%edx),%al
+ movb %al,5(%ecx)
+ testb %al,%al
+ jz L2
+ movb 6(%edx),%al
+ movb %al,6(%ecx)
+ testb %al,%al
+ jz L2
+ movb 7(%edx),%al
+ movb %al,7(%ecx)
+ addl $8,%edx
+ addl $8,%ecx
+ testb %al,%al
+ jnz L1
+L2: popl %eax /* pop dst address */
+ ret
diff --git a/sys/lib/libkern/arch/i386/strlen.S b/sys/lib/libkern/arch/i386/strlen.S
new file mode 100644
index 00000000000..766385c6a89
--- /dev/null
+++ b/sys/lib/libkern/arch/i386/strlen.S
@@ -0,0 +1,23 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+ RCSID("$NetBSD: strlen.S,v 1.5 1995/10/07 09:27:12 mycroft Exp $")
+#endif
+
+ENTRY(strlen)
+ pushl %edi
+ movl 8(%esp),%edi /* string address */
+ cld /* set search forward */
+ xorl %eax,%eax /* set search for null terminator */
+ movl $-1,%ecx /* set search for lots of characters */
+ repne /* search! */
+ scasb
+ notl %ecx /* get length by taking complement */
+ leal -1(%ecx),%eax /* and subtracting one */
+ popl %edi
+ ret