add directory gnu

This commit is contained in:
gohigh
2024-02-19 00:24:47 -05:00
parent 32616db5a4
commit a40f4cadb0
5086 changed files with 1860970 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
/*
* Copyright (c) 1982 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that: (1) source distributions retain this entire copyright
* notice and comment, and (2) distributions including binaries display
* the following acknowledgement: ``This product includes software
* developed by the University of California, Berkeley and its contributors''
* in the documentation or other materials provided with the distribution
* and in all advertising materials mentioning features or use of this
* software. 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* @(#)DEFS.h 5.3 (Berkeley) 6/1/90
*/
#define R0 0x001
#define R1 0x002
#define R2 0x004
#define R3 0x008
#define R4 0x010
#define R5 0x020
#define R6 0x040
#define R7 0x080
#define R8 0x100
#define R9 0x200
#define R10 0x400
#define R11 0x800
#ifdef PROF
#define ENTRY(x, regs) \
.globl _/**/x; .align 2; _/**/x: .word regs; \
.data; 1:; .long 0; .text; moval 1b,r0; jsb mcount
#define ASENTRY(x, regs) \
.globl x; .align 2; x: .word regs; \
.data; 1:; .long 0; .text; moval 1b,r0; jsb mcount
#else
#define ENTRY(x, regs) \
.globl _/**/x; .align 2; _/**/x: .word regs
#define ASENTRY(x, regs) \
.globl x; .align 2; x: .word regs
#endif

View File

@@ -0,0 +1 @@
DEFS.h

View File

@@ -0,0 +1,33 @@
# Copyright (C) 1991 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# The GNU C Library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
# The GNU C Library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library General Public License for more details.
# You should have received a copy of the GNU Library General Public
# License along with the GNU C Library; see the file COPYING.LIB. If
# not, write to the Free Software Foundation, Inc., 675 Mass Ave,
# Cambridge, MA 02139, USA.
ifeq ($(subdir),math)
ifndef math-twiddled
routines:= $(filter-out acos asin cos sin ceil rint hypot \
__copysign __scalb __drem __logb __finite,$(routines))\
asincos sincos
aux := $(aux) argred support exp__E log__L
math-twiddled := t
endif
bsdmath_dirs := $(bsdmath_dirs) vax
endif

View File

@@ -0,0 +1,60 @@
/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#ifndef __GNUC__
#error This file uses GNU C extensions; you must compile with GCC.
#else
#include <ansidecl.h>
#include <errno.h>
#include <math.h>
/* Deal with an infinite or NaN result.
If ERROR is ERANGE, result is +Inf;
if ERROR is - ERANGE, result is -Inf;
otherwise result is NaN.
This will set `errno' to either ERANGE or EDOM,
and may return an infinity or NaN, or may do something else. */
double
DEFUN(__infnan, (error), int error)
{
switch (error)
{
case ERANGE:
errno = ERANGE;
break;
case - ERANGE:
errno = ERANGE;
break;
default:
errno = EDOM;
break;
}
/* Trigger a reserved operand fault. */
{
double result;
asm volatile("emodd %1, %1, %2, %0, %0" : "=r" (result) :
"i" (0), "i" (0x8000));
return result;
}
}
#endif

View File

@@ -0,0 +1,100 @@
/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
Derived from @(#)_setjmp.s 5.7 (Berkeley) 6/27/88,
Copyright (c) 1980 Regents of the University of California.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <setjmp.h>
#ifndef __GNUC__
#error This file uses GNU C extensions; you must compile with GCC.
#endif
#define REI 02 /* Vax `rei' opcode. */
/* Jump to the position specified by ENV, causing the
setjmp call there to return VAL, or 1 if VAL is 0. */
__NORETURN
void
DEFUN(__longjmp, (env, val), CONST jmp_buf env AND int val)
{
register long int *fp asm("fp");
long int *regsave;
unsigned long int flags;
if (env.__fp == NULL)
__libc_fatal("longjmp: Invalid ENV argument.\n");
if (val == 0)
val = 1;
asm volatile("loop:");
flags = *(long int *) (6 + (char *) fp);
regsave = (long int *) (20 + (char *) fp);
if (flags & 1)
/* R0 was saved by the caller.
Store VAL where it will be restored from. */
*regsave++ = val;
if (flags & 2)
/* R1 was saved by the caller.
Store ENV where it will be restored from. */
*regsave = env;
/* Was the FP saved in the last call the same one in ENV? */
asm volatile("cmpl %0, 12(fp);"
/* Yes, return to it. */
"beql done;"
/* The FP in ENV is less than the one saved in the last call.
This means we have already returned from the function that
called `setjmp' with ENV! */
"blssu latejump;" : /* No outputs. */ : "g" (env.__fp));
/* We are more than one level below the state in ENV.
Return to where we will pop another stack frame. */
asm volatile("movl $loop, 16(fp);"
"ret");
asm volatile("done:");
{
char return_insn asm("*16(fp)");
if (return_insn == REI)
/* We're returning with an `rei' instruction.
Do a return with PSL-PC pop. */
asm volatile("movab 0f, 16(fp)");
else
/* Do a standard return. */
asm volatile("movab 1f, 16(fp)");
/* Return. */
asm volatile("ret");
}
asm volatile("0:" /* `rei' return. */
/* Compensate for PSL-PC push. */
"addl2 %0, sp;"
"1:" /* Standard return. */
/* Return to saved PC. */
"jmp %1" : /* No outputs. */ :
"g" (8), "g" (env.__pc));
/* Jump here when the FP saved in ENV points
to a function that has already returned. */
asm volatile("latejump:");
__libc_fatal("longjmp: Attempt to jump to a function that has returned.\n");
}

View File

@@ -0,0 +1,43 @@
/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <string.h>
/* Copy no more than N bytes of SRC to DEST, stopping when C is found.
Return the position in DEST one byte past where C was copied,
or NULL if C was not found in the first N bytes of SRC. */
PTR
DEFUN(__memccpy, (dest, src, c, n),
PTR dest AND CONST PTR src AND int c AND size_t nbytes)
{
/* Except when N > 65535, this is what a hand-coded version would
do anyway. */
PTR found = memchr (src, c, n);
if (found == NULL)
{
(void) memcpy (dest, src, n);
return NULL;
}
(void) memcpy (dest, src, (char *) found + 1 - (char *) src);
return (PTR) ((char *) dest + ((char *) found + 1 - (char *) src));
}

View File

@@ -0,0 +1,64 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that: (1) source distributions retain this entire copyright
* notice and comment, and (2) distributions including binaries display
* the following acknowledgement: ``This product includes software
* developed by the University of California, Berkeley and its contributors''
* in the documentation or other materials provided with the distribution
* and in all advertising materials mentioning features or use of this
* software. 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
.asciz "@(#)bcopy.s 5.6 (Berkeley) 6/1/90"
#endif /* LIBC_SCCS and not lint */
/* bcopy(from, to, size) */
#include "DEFS.h"
ENTRY(bcopy, R6)
movl 4(ap),r1
movl 8(ap),r3
movl 12(ap),r6
cmpl r1,r3
bgtr 2f # normal forward case
blss 3f # overlapping, must do backwards
ret # equal, nothing to do
1:
subl2 r0,r6
movc3 r0,(r1),(r3)
2:
movzwl $65535,r0
cmpl r6,r0
jgtr 1b
movc3 r6,(r1),(r3)
ret
3:
addl2 r6,r1
addl2 r6,r3
movzwl $65535,r0
jbr 5f
4:
subl2 r0,r6
subl2 r0,r1
subl2 r0,r3
movc3 r0,(r1),(r3)
movzwl $65535,r0
subl2 r0,r1
subl2 r0,r3
5:
cmpl r6,r0
jgtr 4b
subl2 r6,r1
subl2 r6,r3
movc3 r6,(r1),(r3)
ret

View File

@@ -0,0 +1,39 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that: (1) source distributions retain this entire copyright
* notice and comment, and (2) distributions including binaries display
* the following acknowledgement: ``This product includes software
* developed by the University of California, Berkeley and its contributors''
* in the documentation or other materials provided with the distribution
* and in all advertising materials mentioning features or use of this
* software. 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
.asciz "@(#)bzero.s 5.6 (Berkeley) 6/1/90"
#endif /* LIBC_SCCS and not lint */
/* bzero(base, length) */
#include "DEFS.h"
ENTRY(bzero, 0)
movl 4(ap),r3
jbr 2f
1:
subl2 r0,8(ap)
movc5 $0,(r3),$0,r0,(r3)
2:
movzwl $65535,r0
cmpl 8(ap),r0
jgtr 1b
movc5 $0,(r3),$0,8(ap),(r3)
ret

View File

@@ -0,0 +1,34 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that: (1) source distributions retain this entire copyright
* notice and comment, and (2) distributions including binaries display
* the following acknowledgement: ``This product includes software
* developed by the University of California, Berkeley and its contributors''
* in the documentation or other materials provided with the distribution
* and in all advertising materials mentioning features or use of this
* software. 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
.asciz "@(#)ffs.s 5.6 (Berkeley) 6/1/90"
#endif /* LIBC_SCCS and not lint */
/* bit = ffs(value) */
#include "DEFS.h"
ENTRY(ffs, 0)
ffs $0,$32,4(ap),r0
bneq 1f
mnegl $1,r0
1:
incl r0
ret

View File

@@ -0,0 +1,68 @@
/* Copyright (C) 1991 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#ifndef __need_HUGE_VAL
/* Floating-point constants for Vaxen. */
#define FLT_RADIX 2
#define FLT_ROUNDS _FLT_ROUNDS_TONEAREST
#define FLT_MANT_DIG 23
#define DBL_MANT_DIG 55
#define LDBL_MANT_DIG 55
#define FLT_DIG 6
#define DBL_DIG 16
#define LDBL_DIG 16
#define FLT_MIN_EXP (-128)
#define DBL_MIN_EXP (-128)
#define LDBL_MIN_EXP (-128)
#define FLT_MIN_10_EXP (-38)
#define DBL_MIN_10_EXP (-38)
#define LDBL_MIN_10_EXP (-38)
#define FLT_MAX_EXP 127
#define DBL_MAX_EXP 127
#define LDBL_MAX_EXP 127
#define FLT_MAX_10_EXP 38
#define DBL_MAX_10_EXP 38
#define LDBL_MAX_10_EXP 38
#define FLT_MAX 1.7014116e38
#define DBL_MAX 1.70141182460469227e38
#define LDBL_MAX DBL_MAX
#define FLT_EPSILON 2.384186e-7
#define DBL_EPSILON 5.55111512312578270e-17
#define LDBL_EPSILON DBL_EPSILON
#define FLT_MIN 0.2938736e-38
#define DBL_MIN 0.29387358770557187e-38
#define LDBL_MIN DBL_MIN
#else /* Need HUGE_VAL. */
/* Used by <stdlib.h> and <math.h> functions for overflow. */
#define HUGE_VAL 1.70141182460469227e38
#endif /* Don't need HUGE_VAL. */

View File

@@ -0,0 +1,30 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Berkeley. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
.asciz "@(#)htonl.s 5.5 (Berkeley) 6/27/88"
#endif /* LIBC_SCCS and not lint */
/* netorder = htonl(hostorder) */
#include "DEFS.h"
ENTRY(htonl, 0)
rotl $-8,4(ap),r0
insv r0,$16,$8,r0
movb 7(ap),r0
ret

View File

@@ -0,0 +1,30 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Berkeley. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
.asciz "@(#)htons.s 5.5 (Berkeley) 6/27/88"
#endif /* LIBC_SCCS and not lint */
/* hostorder = htons(netorder) */
#include "DEFS.h"
ENTRY(htons, 0)
rotl $8,4(ap),r0
movb 5(ap),r0
movzwl r0,r0
ret

View File

@@ -0,0 +1,11 @@
/* Vax Internet number representation function declarations. */
#undef ntohl
#undef ntohs
#undef htonl
#undef htons
extern unsigned long int EXFUN(ntohl, (unsigned long int));
extern unsigned short int EXFUN(ntohs, (unsigned short int));
extern unsigned long int EXFUN(htonl, (unsigned long int));
extern unsigned short int EXFUN(htons, (unsigned short int));

View File

@@ -0,0 +1,7 @@
/* Define the machine-dependent type `jmp_buf'. Vax version. */
typedef struct
{
PTR __fp;
PTR __pc;
} __jmp_buf[1];

View File

@@ -0,0 +1,28 @@
/* Copyright (C) 1991 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#ifndef FPCONST
#define FPCONST(hi0, lo0, hi1, lo1) { (lo0), (hi0), (lo1), (hi1) }
#endif
static CONST short int ln10[] = FPCONST(0x4113, 0x5d8d, 0xddaa, 0xa8ac);
#define LN10 (*(CONST double *) ln10)
#include <../sysdeps/generic/log10.c>

View File

@@ -0,0 +1,59 @@
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that: (1) source distributions retain this entire copyright
* notice and comment, and (2) distributions including binaries display
* the following acknowledgement: ``This product includes software
* developed by the University of California, Berkeley and its contributors''
* in the documentation or other materials provided with the distribution
* and in all advertising materials mentioning features or use of this
* software. 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
.asciz "@(#)memchr.s 5.1 (Berkeley) 5/29/90"
#endif /* LIBC_SCCS and not lint */
/*
* Find the first occurence of c in the memory at cp (length n).
* Return pointer to match or null pointer.
*
* This code optimises the usual case (0 < n < 65535).
*
* void *
* memchr(cp, c, n)
* char *cp, c;
* size_t n;
*/
#include "DEFS.h"
ENTRY(memchr, 0)
movq 4(ap),r1 # r1 = cp; r2 = c
movl 12(ap),r0 # r0 = n
movzwl $65535,r4 # handy constant
0:
cmpl r0,r4 # check for annoying locc limit
bgtru 3f
/* n <= 65535 */
locc r2,r0,(r1) # search n bytes for c
beql 2f # done if not found (r0 already 0)
1: /* found character c at (r1) */
movl r1,r0
2:
ret
3: /* n > 65535 */
locc r2,r4,(r1) # search 65535 bytes for c
beql 1b # done if found
decw r0 # from 0 to 65535
subl2 r0,r4 # adjust n
brb 0b # and loop

View File

@@ -0,0 +1,47 @@
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that: (1) source distributions retain this entire copyright
* notice and comment, and (2) distributions including binaries display
* the following acknowledgement: ``This product includes software
* developed by the University of California, Berkeley and its contributors''
* in the documentation or other materials provided with the distribution
* and in all advertising materials mentioning features or use of this
* software. 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
.asciz "@(#)memcmp.s 5.1 (Berkeley) 5/15/90"
#endif /* LIBC_SCCS and not lint */
/* int memcmp(s1, s2, n) */
#include "DEFS.h"
ENTRY(memcmp, 0)
movl 4(ap),r1 /* r1 = s1 */
movq 8(ap),r3 /* r3 = s2; r4 = n */
movzwl $65535,r5
0:
cmpl r4,r5
jgtru 3f /* handle stupid cmpc3 limitation */
cmpc3 r4,(r1),(r3) /* compare */
beql 2f /* done if same (r0 = 0) */
1:
movzbl (r1),r0
movzbl (r3),r2
subl2 r2,r0 /* return *s1 - *s2; s1,s2 unsigned chars */
2:
ret
3:
subl2 r5,r4 /* do 64K; adjust count */
cmpc3 r5,(r1),(r3)
jeql 0b /* loop if same */
jbr 1b

View File

@@ -0,0 +1,79 @@
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that: (1) source distributions retain this entire copyright
* notice and comment, and (2) distributions including binaries display
* the following acknowledgement: ``This product includes software
* developed by the University of California, Berkeley and its contributors''
* in the documentation or other materials provided with the distribution
* and in all advertising materials mentioning features or use of this
* software. 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
.asciz "@(#)memmove.s 5.1 (Berkeley) 5/15/90"
#endif /* LIBC_SCCS and not lint */
/*
* void *memmove(dst, src, size)
* returns dst
*
* This optimises the usual case (count < 65536) at the expense
* of some extra memory references and branches when count >= 65536.
*/
#include "DEFS.h"
ENTRY(memmove, 0)
movzwl $65535,r0 /* r0 = 64K (needed below) */
movq 8(ap),r1 /* r1 = src, r2 = length */
movl 4(ap),r3 /* r3 = dst */
cmpl r1,r3
bgtru 1f /* normal forward case */
beql 2f /* equal, nothing to do */
addl2 r2,r1 /* overlaps iff src<dst but src+len>dst */
cmpl r1,r3
bgtru 4f /* overlapping, must move backwards */
subl2 r2,r1
1: /* move forward */
cmpl r2,r0
bgtru 3f /* stupid movc3 limitation */
movc3 r2,(r1),(r3) /* move it all */
2:
movl 4(ap),r0 /* return original dst */
ret
3:
subl2 r0,12(ap) /* adjust length by 64K */
movc3 r0,(r1),(r3) /* move 64K */
movl 12(ap),r2
decw r0 /* from 0 to 65535 */
brb 1b /* retry */
4: /* move backward */
addl2 r2,r3
5:
cmpl r2,r0
bgtru 6f /* stupid movc3 limitation */
subl2 r2,r1
subl2 r2,r3
movc3 r2,(r1),(r3) /* move it all */
movl 4(ap),r0 /* return original dst */
ret
6:
subl2 r0,12(ap) /* adjust length by 64K */
subl2 r0,r1
subl2 r0,r3
movc3 r0,(r1),(r3) /* move 64K */
movl 12(ap),r2
decw r0
subl2 r0,r1
subl2 r0,r3
brb 5b

View File

@@ -0,0 +1,40 @@
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that: (1) source distributions retain this entire copyright
* notice and comment, and (2) distributions including binaries display
* the following acknowledgement: ``This product includes software
* developed by the University of California, Berkeley and its contributors''
* in the documentation or other materials provided with the distribution
* and in all advertising materials mentioning features or use of this
* software. 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
.asciz "@(#)memset.s 5.1 (Berkeley) 5/15/90"
#endif /* LIBC_SCCS and not lint */
/* void *memset(base, c, length) */
#include "DEFS.h"
ENTRY(memset, 0)
movl 4(ap),r3
1:
movzwl $65535,r0
movq 8(ap),r1
cmpl r2,r0
jgtru 2f
movc5 $0,(r3),r1,r2,(r3)
ret
2:
subl2 r0,12(ap)
movc5 $0,(r3),r1,r0,(r3)
jbr 1b

View File

@@ -0,0 +1,30 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Berkeley. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
.asciz "@(#)ntohl.s 5.5 (Berkeley) 6/27/88"
#endif /* LIBC_SCCS and not lint */
/* hostorder = ntohl(netorder) */
#include "DEFS.h"
ENTRY(ntohl, 0)
rotl $-8,4(ap),r0
insv r0,$16,$8,r0
movb 7(ap),r0
ret

View File

@@ -0,0 +1,30 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Berkeley. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
.asciz "@(#)ntohs.s 5.5 (Berkeley) 6/27/88"
#endif /* LIBC_SCCS and not lint */
/* hostorder = ntohs(netorder) */
#include "DEFS.h"
ENTRY(ntohs, 0)
rotl $8,4(ap),r0
movb 5(ap),r0
movzwl r0,r0
ret

View File

@@ -0,0 +1,37 @@
/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
Derived from @(#)_setjmp.s 5.7 (Berkeley) 6/27/88,
Copyright (c) 1980 Regents of the University of California.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <ansidecl.h>
#include <setjmp.h>
#ifndef __GNUC__
#error This file uses GNU C extensions; you must compile with GCC.
#endif
/* Save the current program position in ENV and return 0. */
int
DEFUN(__setjmp, (env), jmp_buf env)
{
/* Save our caller's FP and PC. */
asm("movl 12(fp), %0" : "=g" (env[0].__fp));
asm("movl 16(fp), %0" : "=g" (env[0].__pc));
return 0;
}

View File

@@ -0,0 +1,52 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that: (1) source distributions retain this entire copyright
* notice and comment, and (2) distributions including binaries display
* the following acknowledgement: ``This product includes software
* developed by the University of California, Berkeley and its contributors''
* in the documentation or other materials provided with the distribution
* and in all advertising materials mentioning features or use of this
* software. 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
.asciz "@(#)strcat.s 5.6 (Berkeley) 6/1/90"
#endif /* LIBC_SCCS and not lint */
/*
* Concatenate string s2 to the end of s1
* and return the base of s1.
*
* char *
* strcat(s1, s2)
* char *s1, *s2;
*/
#include "DEFS.h"
ENTRY(strcat, R6|R7)
movq 4(ap), r6 # r6 = s1; r7 = s2
movl r6,r1
0:
locc $0,$65535,(r1) # look for '\0'
beql 0b
movl r1,r3 # save end of s1
1:
locc $0,$65535,(r7) # find length of s2
bneq 2f
movc3 $65535,(r7),(r3)# copy full block
movl r1,r7
jbr 1b
2:
subl2 r7,r1 # calculate length
incl r1
movc3 r1,(r7),(r3) # copy remainder
movl r6,r0
ret

View File

@@ -0,0 +1,91 @@
/*
* Copyright (c) 1988 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that: (1) source distributions retain this entire copyright
* notice and comment, and (2) distributions including binaries display
* the following acknowledgement: ``This product includes software
* developed by the University of California, Berkeley and its contributors''
* in the documentation or other materials provided with the distribution
* and in all advertising materials mentioning features or use of this
* software. 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
.asciz "@(#)strchr.s 5.4 (Berkeley) 6/1/90"
#endif /* LIBC_SCCS and not lint */
/*
* Find the first occurence of c in the string cp.
* Return pointer to match or null pointer.
*
* char *
* strchr(cp, c)
* char *cp, c;
*/
#include "DEFS.h"
.lcomm tbl,256
ENTRY(strchr, 0)
movzwl $65535,r4 /* handy constant */
movq 4(ap),r1 /* r1 = cp; r2 = c */
movzbl r2,r2
beql Lzero /* special case for c == '\0' */
/*
* Fancy scanc version. Alas, it is not reentrant.
*/
movab tbl,r3 /* r3 = base of table */
bbss $0,(r3),Lreent /* ensure not reentering */
movab (r3)[r2],r5
incb (r5) /* mark both '\0' and c */
0:
scanc r4,(r1),(r3),$1 /* look for c or '\0' */
beql 0b /* still looking */
movl r1,r0 /* return whatever we found */
tstb (r0)
bneq 1f # unless it was '\0':
clrl r0 # then return NULL
1:
clrb (r5) /* clean up table */
clrb (r3)
ret
/*
* Special case for \0.
*/
Lzero:
locc r2,r4,(r1) /* just find end of string */
beql Lzero /* still looking */
movl r1,r0 /* found it */
ret
/*
* Slower reentrant version is two two-step searches. The first
* phase runs until we know where the string ends; it locates the
* first occurrence of c within a 65535-byte block. If we find
* the end of the string first, we switch to the second phase,
* were we look only up to the known end of string.
*/
Lreent:
0: /* first phase */
movl r1,r3
locc $0,r4,(r3) /* look for '\0' */
bneq 1f
locc r2,r4,(r3) /* look for c */
beql 0b /* not found: reset pointer and loop */
movl r1,r0 /* found: return it */
ret
1: /* second phase */
subl3 r3,r1,r0 /* length of short block */
locc r2,r0,(r3) /* look for c */
beql 2f /* not found: return NULL */
movl r1,r0
2: ret

View File

@@ -0,0 +1,71 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that: (1) source distributions retain this entire copyright
* notice and comment, and (2) distributions including binaries display
* the following acknowledgement: ``This product includes software
* developed by the University of California, Berkeley and its contributors''
* in the documentation or other materials provided with the distribution
* and in all advertising materials mentioning features or use of this
* software. 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
.asciz "@(#)strcmp.s 5.6 (Berkeley) 6/1/90"
#endif /* LIBC_SCCS and not lint */
/*
* Compare string s1 lexicographically to string s2.
* Return:
* 0 s1 == s2
* > 0 s1 > s2
* < 0 s2 < s2
*
* strcmp(s1, s2)
* char *s1, *s2;
*/
#include "DEFS.h"
ENTRY(strcmp, 0)
movl 4(ap),r1 # r1 = s1
movl 8(ap),r3 # r3 = s2
subb3 (r3),(r1),r0 # quick check for first char different
beql 1f # have to keep checking
cvtbl r0,r0
ret
1:
clrl r5 # calculate min bytes to next page boundry
subb3 r1,$255,r5 # r5 = (bytes - 1) to end of page for s1
subb3 r3,$255,r0 # r0 = (bytes - 1) to end of page for s2
cmpb r0,r5 # r5 = min(r0, r5);
bgtru 2f
movb r0,r5
2:
incl r5 # r5 = min bytes to next page boundry
cmpc3 r5,(r1),(r3) # compare strings
bneq 3f
subl2 r5,r1 # check if found null yet
locc $0,r5,(r1)
beql 1b # not yet done, continue checking
subl2 r0,r3
mnegb (r3),r0 # r0 = '\0' - *s2
cvtbl r0,r0
ret
3:
subl2 r0,r5 # check for null in matching string
subl2 r5,r1
locc $0,r5,(r1)
bneq 4f
subb3 (r3),(r1),r0 # r0 = *s1 - *s2
cvtbl r0,r0
ret
4:
clrl r0 # both the same to null
ret

View File

@@ -0,0 +1,48 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that: (1) source distributions retain this entire copyright
* notice and comment, and (2) distributions including binaries display
* the following acknowledgement: ``This product includes software
* developed by the University of California, Berkeley and its contributors''
* in the documentation or other materials provided with the distribution
* and in all advertising materials mentioning features or use of this
* software. 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
.asciz "@(#)strcpy.s 5.6 (Berkeley) 6/1/90"
#endif /* LIBC_SCCS and not lint */
/*
* Copy string s2 over top of s1.
* Return base of s1.
*
* char *
* strcpy(s1, s2)
* char *s1, *s2;
*/
#include "DEFS.h"
ENTRY(strcpy, R6)
movl 4(ap), r3 # r3 = s1
movl 8(ap), r6 # r6 = s2
1:
locc $0,$65535,(r6) # find length of s2
bneq 2f
movc3 $65535,(r6),(r3)# copy full block
movl r1,r6
jbr 1b
2:
subl2 r6,r1 # calculate length
incl r1
movc3 r1,(r6),(r3) # copy remainder
movl 4(ap),r0 # return base of s1
ret

View File

@@ -0,0 +1,52 @@
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that: (1) source distributions retain this entire copyright
* notice and comment, and (2) distributions including binaries display
* the following acknowledgement: ``This product includes software
* developed by the University of California, Berkeley and its contributors''
* in the documentation or other materials provided with the distribution
* and in all advertising materials mentioning features or use of this
* software. 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
.asciz "@(#)strcspn.s 5.1 (Berkeley) 5/15/90"
#endif /* LIBC_SCCS and not lint */
/*
* Span the complement of string s2 (skip characters that are not in s2).
* Return the number of characters in s1 that were skipped.
*
* size_t
* strcspn(s1, s2)
* const char *s1, *s2;
*/
#include "DEFS.h"
ENTRY(strcspn, 0)
subl2 $32,sp /* make 256 bit table */
movc5 $0,(sp),$0,$32,(sp)
movq 4(ap),r1 /* r1 = s1, r2 = s2 */
/* turn on bit for each character in s2, including '\0' */
1:
movzbl (r2)+,r0
bbss r0,(sp),1b
bneq 1b
movl r1,r0 /* r0 = s (current pos in s1) */
/* look for a character that is in s2 */
2:
movzbl (r0)+,r2 /* c = *s++ */
bbc r2,(sp),2b /* loop until c is in table */
decl r0 /* s-- */
subl2 r1,r0 /* r0 = s - s1 = count */
ret

View File

@@ -0,0 +1,38 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that: (1) source distributions retain this entire copyright
* notice and comment, and (2) distributions including binaries display
* the following acknowledgement: ``This product includes software
* developed by the University of California, Berkeley and its contributors''
* in the documentation or other materials provided with the distribution
* and in all advertising materials mentioning features or use of this
* software. 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
.asciz "@(#)strlen.s 5.6 (Berkeley) 6/1/90"
#endif /* LIBC_SCCS and not lint */
/*
* Return the length of cp (not counting '\0').
*
* strlen(cp)
* char *cp;
*/
#include "DEFS.h"
ENTRY(strlen, 0)
movl 4(ap),r1
1:
locc $0,$65535,(r1) # look for '\0'
beql 1b
subl3 4(ap),r1,r0 # len = cp - base
ret

View File

@@ -0,0 +1,69 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that: (1) source distributions retain this entire copyright
* notice and comment, and (2) distributions including binaries display
* the following acknowledgement: ``This product includes software
* developed by the University of California, Berkeley and its contributors''
* in the documentation or other materials provided with the distribution
* and in all advertising materials mentioning features or use of this
* software. 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
.asciz "@(#)strncat.s 5.6 (Berkeley) 6/1/90"
#endif /* LIBC_SCCS and not lint */
/*
* Concatenate string s2 on the end of s1
* and return the base of s1. The parameter
* n is the maximum length of string s2 to
* concatenate.
*
* char *
* strncat(s1, s2, n)
* char *s1, *s2;
* int n;
*/
#include "DEFS.h"
ENTRY(strncat, R6)
movl 12(ap),r6 # r6 = n
bleq done # n <= 0
movl 4(ap),r3 # r3 = s1
movl r3,r1
0:
locc $0,$65535,(r1)
beql 0b
movl r1,r3 # r3 = index(s1, '\0');
movl 8(ap),r1 # r1 = s2
1:
movzwl $65535,r2 # r2 = bytes in first chunk
cmpl r6,r2 # r2 = min(bytes in chunk, n);
jgeq 2f
movl r6,r2
2:
subl2 r2,r6 # update n
locc $0,r2,(r1) # '\0' found?
jneq 3f
subl2 r2,r1 # back up pointer updated by locc
movc3 r2,(r1),(r3) # copy in next piece
tstl r6 # run out of space?
jneq 1b
clrb (r3) # force '\0' termination
jbr done
3:
subl2 r0,r2 # r2 = number of bytes to move
subl2 r2,r1 # back up pointer updated by locc
incl r2 # copy '\0' as well
movc3 r2,(r1),(r3) # copy in last piece
done:
movl 4(ap),r0 # return s1
ret

View File

@@ -0,0 +1,75 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that: (1) source distributions retain this entire copyright
* notice and comment, and (2) distributions including binaries display
* the following acknowledgement: ``This product includes software
* developed by the University of California, Berkeley and its contributors''
* in the documentation or other materials provided with the distribution
* and in all advertising materials mentioning features or use of this
* software. 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
.asciz "@(#)strncmp.s 5.6 (Berkeley) 6/1/90"
#endif /* LIBC_SCCS and not lint */
/*
* Compare at most n characters of string
* s1 lexicographically to string s2.
* Return:
* 0 s1 == s2
* > 0 s1 > s2
* < 0 s2 < s2
*
* strncmp(s1, s2, n)
* char *s1, *s2;
* int n;
*/
#include "DEFS.h"
ENTRY(strncmp, 0)
movl 4(ap),r1 # r1 = s1
movq 8(ap),r3 # r3 = s2; r4 = n
1:
clrl r5 # calculate min bytes to next page boundry
subb3 r1,$255,r5 # r5 = (bytes - 1) to end of page for s1
subb3 r3,$255,r0 # r0 = (bytes - 1) to end of page for s2
cmpb r0,r5 # r5 = min(r0, r5);
bgtru 2f
movb r0,r5
2:
incl r5 # r5 = min bytes to next page boundry
cmpl r4,r5 # r5 = min(n, r5);
bgeq 3f
movl r4,r5
3:
cmpc3 r5,(r1),(r3) # compare strings
bneq 4f
subl2 r5,r4 # check for end of comparison
beql 5f
subl2 r5,r1 # check if found null yet
locc $0,r5,(r1)
beql 1b # not yet done, continue checking
subl2 r0,r3
mnegb (r3),r0 # r0 = '\0' - *s2
cvtbl r0,r0
ret
4:
subl2 r0,r5 # check for null in matching string
subl2 r5,r1
locc $0,r5,(r1)
bneq 5f
subb3 (r3),(r1),r0 # r0 = *s1 - *s2
cvtbl r0,r0
ret
5:
clrl r0 # both the same to null
ret

View File

@@ -0,0 +1,70 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that: (1) source distributions retain this entire copyright
* notice and comment, and (2) distributions including binaries display
* the following acknowledgement: ``This product includes software
* developed by the University of California, Berkeley and its contributors''
* in the documentation or other materials provided with the distribution
* and in all advertising materials mentioning features or use of this
* software. 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
.asciz "@(#)strncpy.s 5.6 (Berkeley) 6/1/90"
#endif /* LIBC_SCCS and not lint */
/*
* Copy string s2 over top of string s1.
* Truncate or null-pad to n bytes.
*
* char *
* strncpy(s1, s2, n)
* char *s1, *s2;
*/
#include "DEFS.h"
ENTRY(strncpy, R6)
movl 12(ap),r6 # r6 = n
bleq done # n <= 0
movl 4(ap),r3 # r3 = s1
movl 8(ap),r1 # r1 = s2
1:
movzwl $65535,r2 # r2 = bytes in first chunk
cmpl r6,r2 # r2 = min(bytes in chunk, n);
jgeq 2f
movl r6,r2
2:
subl2 r2,r6 # update n
locc $0,r2,(r1) # '\0' found?
jneq 3f
subl2 r2,r1 # back up pointer updated by locc
movc3 r2,(r1),(r3) # copy in next piece
tstl r6 # run out of space?
jneq 1b
jbr done
3: # copy up to '\0' logic
addl2 r0,r6 # r6 = number of null-pad bytes
subl2 r0,r2 # r2 = number of bytes to move
subl2 r2,r1 # back up pointer updated by locc
movc3 r2,(r1),(r3) # copy in last piece
4: # null-pad logic
movzwl $65535,r2 # r2 = bytes in first chunk
cmpl r6,r2 # r2 = min(bytes in chunk, n);
jgeq 5f
movl r6,r2
5:
subl2 r2,r6 # update n
movc5 $0,(r3),$0,r2,(r3)# pad with '\0's
tstl r6 # finished padding?
jneq 4b
done:
movl 4(ap),r0 # return s1
ret

View File

@@ -0,0 +1,54 @@
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that: (1) source distributions retain this entire copyright
* notice and comment, and (2) distributions including binaries display
* the following acknowledgement: ``This product includes software
* developed by the University of California, Berkeley and its contributors''
* in the documentation or other materials provided with the distribution
* and in all advertising materials mentioning features or use of this
* software. 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
.asciz "@(#)strpbrk.s 5.1 (Berkeley) 5/15/90"
#endif /* LIBC_SCCS and not lint */
/*
* Find in s1 the first occurrence of any character from s2.
* If there are none, return NULL.
*
* char *
* strpbrk(s1, s2)
* const char *s1, *s2;
*/
#include "DEFS.h"
ENTRY(strpbrk, 0)
subl2 $32,sp /* make 256 bit table */
movc5 $0,(sp),$0,$32,(sp)
movq 4(ap),r0 /* r0 = s1, r1 = s2 */
/* turn on bit for each character in s2, including '\0' */
1:
movzbl (r1)+,r2
bbss r2,(sp),1b
bneq 1b
/* look for a character that is in s2 */
2:
movzbl (r0)+,r2 /* c = *s++ */
bbc r2,(sp),2b /* loop until c is in table */
beql 3f /* if c==0, go return NULL */
decl r0 /* s-- */
ret
3:
clrl r0
ret

View File

@@ -0,0 +1,100 @@
/*
* Copyright (c) 1988 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that: (1) source distributions retain this entire copyright
* notice and comment, and (2) distributions including binaries display
* the following acknowledgement: ``This product includes software
* developed by the University of California, Berkeley and its contributors''
* in the documentation or other materials provided with the distribution
* and in all advertising materials mentioning features or use of this
* software. 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
.asciz "@(#)strrchr.s 5.4 (Berkeley) 6/1/90"
#endif /* LIBC_SCCS and not lint */
/*
* Find the last occurence of c in the string cp.
* Return pointer to match or null pointer.
*
* char *
* strrchr(cp, c)
* char *cp, c;
*/
#include "DEFS.h"
.lcomm tbl,256
ENTRY(strrchr, 0)
movzwl $65535,r4 /* handy 65535 */
movq 4(ap),r1 /* r1 = cp; r2 = c */
movzbl r2,r2
beql Lzero /* special case for c == '\0' */
clrl r5 /* r5 = pointer to last match */
/*
* Fancy scanc version. Alas, it is not reentrant.
*/
movab tbl,r3 /* r3 = address of table */
bbss $0,(r3),Lreent /* ensure not reentering */
movab (r3)[r2],r4
incb (r4) /* mark both '\0' and c */
0:
scanc $65535,(r1),(r3),$1 /* look for c or '\0' */
beql 0b /* keep looking */
tstb (r1)
beql 1f /* done if '\0' */
movab (r1)+,r5 /* save most recently found, and skip over it */
jbr 0b /* keep looking */
1:
movl r5,r0 /* return last found (if any) */
clrb (r4) /* clean up table */
clrb (r3)
ret
/*
* Special case for \0.
*/
Lzero:
locc $0,r4,(r1) /* just find end of string */
beql Lzero /* still looking */
movl r1,r0 /* found it */
ret
/*
* Slower reentrant version is two two-step searches. The first
* phase runs until we know where the string ends; it locates any
* occurrences of c within a 65535-byte block. Once we have found
* the end of the string, we find any further occurrences before
* that location.
*/
Lreent:
0: /* first phase */
movl r1,r3
locc $0,r4,(r3) /* look for '\0' */
bneq 1f
locc r2,r4,(r3) /* continue phase 1 search for c */
beql 0b
movab (r1)+,r5 /* found c: save and increment pointer */
brb 0b /* and continue */
1: /* second phase */
subl3 r3,r1,r0 /* length of short block */
movl r3,r1
2:
locc r2,r0,(r1) /* look for c */
beql 3f /* skip if not found */
movab (r1)+,r5 /* save pointer as before */
sobgtr r0,2b /* adjust count and loop */
3:
movl r5,r0 /* return stashed pointer */
ret

View File

@@ -0,0 +1,56 @@
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that: (1) source distributions retain this entire copyright
* notice and comment, and (2) distributions including binaries display
* the following acknowledgement: ``This product includes software
* developed by the University of California, Berkeley and its contributors''
* in the documentation or other materials provided with the distribution
* and in all advertising materials mentioning features or use of this
* software. 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
.asciz "@(#)strspn.s 5.1 (Berkeley) 5/15/90"
#endif /* LIBC_SCCS and not lint */
/*
* Span the string s2 (skip characters that are in s2).
* Return the number of characters in s1 that were skipped.
*
* size_t
* strspn(s1, s2)
* const char *s1, *s2;
*/
#include "DEFS.h"
ENTRY(strspn, 0)
subl2 $32,sp /* make 256 bit table */
movc5 $0,(sp),$0,$32,(sp)
movq 4(ap),r1 /* r1 = s1, r2 = s2 */
/* turn on bit for each character in s2, including '\0' */
1:
movzbl (r2)+,r0
bbss r0,(sp),1b
bneq 1b
/* now clear bit for '\0' */
/* (this is easier than avoiding setting it in the first place) */
bicb2 $1,(sp) /* stop at '\0' */
movl r1,r0 /* r0 = s (current pos in s1) */
/* look for a character that is not in s2 */
2:
movzbl (r0)+,r2 /* c = *s++ */
bbs r2,(sp),2b /* loop while c is in table */
decl r0 /* s-- */
subl2 r1,r0 /* r0 = s - s1 = count */
ret

View File

@@ -0,0 +1,99 @@
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that: (1) source distributions retain this entire copyright
* notice and comment, and (2) distributions including binaries display
* the following acknowledgement: ``This product includes software
* developed by the University of California, Berkeley and its contributors''
* in the documentation or other materials provided with the distribution
* and in all advertising materials mentioning features or use of this
* software. 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
.asciz "@(#)strstr.s 5.1 (Berkeley) 5/15/90"
#endif /* LIBC_SCCS and not lint */
/*
* Find the first occurrence of s2 as a substring in s1.
* If s2 is empty, return s1.
*
* char *strstr(s1, s2)
* const char *s1, *s2;
*/
#include "DEFS.h"
ENTRY(strstr, 0)
movq 4(ap),r3 /* r3 = s1, r4 = s2 */
movzwl $65535,r2 /* r2 = locc/matchc limit */
locc $0,r2,(r4) /* find '\0' in s2 */
beql 4f
subl3 r1,r4,r5 /* r5 = strlen(s2) */
beql 1f /* if r5 == 0, return s1 */
/*
* s2 is short enough to apply matchc.
* If s1 is long, we have to do it in stages.
*/
0: locc $0,r2,(r3) /* find '\0' in s1 */
beql 3f
/*
* Both strings are `short'; we can use matchc directly.
*/
subl3 r1,r3,r1 /* r1 = strlen(s1) */
matchc r5,(r4),r1,(r3) /* find substring */
bneq 2f
/*
* r3 points r5 bytes past match. Return the match.
*/
1: subl3 r5,r3,r0 /* return (byte_past_match - strlen(s2)) */
ret
/*
* There is no matching substring.
*/
2: clrl r0 /* return NULL */
ret
/*
* s1 is too long (> 65535 bytes) to apply matchc directly,
* but s2 is short enough. Apply s2 to s1, then (if not
* found yet) advancing s1 by (65536-strlen(s2)) bytes and
* loop.
*/
3: matchc r5,(r4),r2,(r3) /* search */
beql 1b /* if found, go return it */
decw r2 /* from 0 to 65535 */
incl r3 /* already advanced 65535, now 65536 */
subl2 r5,r3 /* ... minus strlen(s2) */
brb 0b
/*
* s2 is too long (> 65535 bytes) to bother with matchc.
*/
4: locc $0,r2,(r1) /* continue working on strlen(s2) */
beql 4b
subl3 r1,r4,r5 /* r5 = strlen(s2) */
movb (r4)+,r2 /* r2 = *s2++ */
decl r5 /* fix up length */
5: movb (r3)+,r0 /* r0 = *s1++ */
beql 2b /* if '\0', return NULL */
cmpb r0,r2
bneq 5b /* loop until first char found */
pushr R5|R4|R3|R2 /* save c, s1, s2, n */
pushr R5|R4|R3 /* strncmp(s1, s2, n) */
calls $3,_strncmp
popr R2|R3|R4|R5 /* restore */
tstl r0
bneq 5b /* loop until strncmp says rest same too */
subl3 $1,r3,r0 /* return previous s1 */
ret