1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * arch/alpha/lib/strncat.S 4 * Contributed by Richard Henderson (rth@tamu. 5 * 6 * Append no more than COUNT characters from t 7 * to the null-terminated string DST. Always 8 * 9 * This differs slightly from the semantics in 10 * past count, whereas libc may write to count 11 * implementation in lib/string.c and is, IMHO 12 */ 13 #include <linux/export.h> 14 .text 15 16 .align 3 17 .globl strncat 18 .ent strncat 19 strncat: 20 .frame $30, 0, $26 21 .prologue 0 22 23 mov $16, $0 # set up retur 24 beq $18, $zerocount 25 26 /* Find the end of the string. */ 27 28 ldq_u $1, 0($16) # load first q 29 lda $2, -1($31) 30 insqh $2, $16, $2 31 andnot $16, 7, $16 32 or $2, $1, $1 33 cmpbge $31, $1, $2 # bits set iff 34 bne $2, $found 35 36 $loop: ldq $1, 8($16) 37 addq $16, 8, $16 38 cmpbge $31, $1, $2 39 beq $2, $loop 40 41 $found: negq $2, $3 # clear all bu 42 and $2, $3, $2 43 44 and $2, 0xf0, $3 # binary searc 45 and $2, 0xcc, $4 46 and $2, 0xaa, $5 47 cmovne $3, 4, $3 48 cmovne $4, 2, $4 49 cmovne $5, 1, $5 50 addq $3, $4, $3 51 addq $16, $5, $16 52 addq $16, $3, $16 53 54 /* Now do the append. */ 55 56 bsr $23, __stxncpy 57 58 /* Worry about the null termination. 59 60 zapnot $1, $27, $2 # was last byt 61 bne $2, 0f 62 ret 63 64 0: cmplt $27, $24, $2 # did we fill 65 or $2, $18, $2 66 bne $2, 2f 67 68 and $24, 0x80, $2 # no zero next 69 bne $2, 1f 70 71 /* Here there are bytes left in the cu 72 addq $24, $24, $24 # end-of-count 73 2: zap $1, $24, $1 74 stq_u $1, 0($16) 75 ret 76 77 1: /* Here we must read the next DST word 78 ldq_u $1, 8($16) 79 zap $1, 1, $1 80 stq_u $1, 8($16) 81 82 $zerocount: 83 ret 84 85 .end strncat 86 EXPORT_SYMBOL(strncat)
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.