1 /* SPDX-License-Identifier: GPL-2.0 */
3 * arch/alpha/lib/strncpy.S
4 * Contributed by Richard Henderson (rth@tamu.edu)
6 * Copy no more than COUNT bytes of the null-terminated string from
7 * SRC to DST. If SRC does not cover all of COUNT, the balance is
10 * Or, rather, if the kernel cared about that weird ANSI quirk. This
11 * version has cropped that bit o' nastiness as well as assuming that
12 * __stxncpy is in range of a branch.
14 #include <asm/export.h>
27 mov $16, $0 # set return value now
30 bsr $23, __stxncpy # do the work of the copy
33 bne $18, $multiword # do we have full words left?
34 subq $24, 1, $3 # nope
37 or $3, $24, $3 # clear the bits between the last
38 or $4, $27, $4 # written byte and the last byte in COUNT
47 subq $27, 1, $2 # clear the final bits in the prev word
62 stq_u $31, 0($16) # zero one word
67 0: stq_u $31, 0($16) # zero two words
73 1: ldq_u $1, 0($16) # clear the leading bits in the final word
83 EXPORT_SYMBOL(strncpy)