Sync with libc strncpy.S 1.11: optimized code by Hiroshi Horimoto.

This commit is contained in:
is 2000-11-27 22:38:33 +00:00
parent a3a6f324e6
commit c8071d4fac
1 changed files with 15 additions and 8 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: strncpy.S,v 1.5 1999/11/11 01:32:14 thorpej Exp $ */
/* $NetBSD: strncpy.S,v 1.6 2000/11/27 22:38:33 is Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@ -43,7 +43,7 @@
#if 0
RCSID("from: @(#)strncpy.s 5.1 (Berkeley) 5/12/90")
#else
RCSID("$NetBSD: strncpy.S,v 1.5 1999/11/11 01:32:14 thorpej Exp $")
RCSID("$NetBSD: strncpy.S,v 1.6 2000/11/27 22:38:33 is Exp $")
#endif
#endif /* LIBC_SCCS and not lint */
@ -53,18 +53,25 @@ ENTRY(strncpy)
jeq Lscdone | nothing to do
movl %sp@(8),%a0 | a0 = fromaddr
movl %d0,%a1 | a1 = toaddr
subql #1,%d1
Lscloop:
movb %a0@+,%a1@+ | copy a byte
jeq Lscploop | copied null, go pad if necessary
subql #1,%d1 | adjust count
jne Lscloop | more room, keep going
dbeq %d1,Lscloop | loop through low word of d1
jeq Lscpadding | copied null, padding if necessary
clrw %d1 | clear low word of d1
subql #1,%d1 | adjust count for long copies
jcc Lscloop | more room, keep going
Lscdone:
#ifdef __SVR4_ABI__
moveal %d0,%a0
#endif
rts
Lscploop:
subql #1,%d1 | adjust count
jeq Lscdone | no more room, all done
clrb %a1@+ | clear a byte
jra Lscploop | keep going
dbra %d1,Lscploop | keep going
clrw %d1
Lscpadding:
subql #1,%d1
jcc Lscploop
jra Lscdone