1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * arch/alpha/lib/ev67-strncat.S 4 * 21264 version contributed by Rick Gorton <ri 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 * Much of the information about 21264 schedul 14 * Compiler Writer's Guide for the Alpha 15 * abbreviated as 'CWG' in other comments 16 * ftp.digital.com/pub/Digital/info/semic 17 * Scheduling notation: 18 * E - either cluster 19 * U - upper subcluster; U0 - subcl 20 * L - lower subcluster; L0 - subcl 21 * Try not to change the actual algorithm if p 22 */ 23 24 #include <linux/export.h> 25 .text 26 27 .align 4 28 .globl strncat 29 .ent strncat 30 strncat: 31 .frame $30, 0, $26 32 .prologue 0 33 34 mov $16, $0 # set up retur 35 beq $18, $zerocount # U : 36 /* Find the end of the string. */ 37 ldq_u $1, 0($16) # L : load fir 38 lda $2, -1($31) # E : 39 40 insqh $2, $0, $2 # U : 41 andnot $16, 7, $16 # E : 42 nop # E : 43 or $2, $1, $1 # E : 44 45 nop # E : 46 nop # E : 47 cmpbge $31, $1, $2 # E : bits set 48 bne $2, $found # U : 49 50 $loop: ldq $1, 8($16) # L : 51 addq $16, 8, $16 # E : 52 cmpbge $31, $1, $2 # E : 53 beq $2, $loop # U : 54 55 $found: cttz $2, $3 # U0 : 56 addq $16, $3, $16 # E : 57 nop # E : 58 bsr $23, __stxncpy # L0 :/* Now d 59 60 /* Worry about the null termination. 61 62 zapnot $1, $27, $2 # U : was last 63 cmplt $27, $24, $5 # E : did we f 64 bne $2, 0f # U : 65 ret # L0 : 66 67 0: or $5, $18, $2 # E : 68 nop 69 bne $2, 2f # U : 70 and $24, 0x80, $3 # E : no zero 71 72 nop # E : 73 bne $3, 1f # U : 74 /* Here there are bytes left in the cu 75 addq $24, $24, $24 # E : end-of-c 76 nop # E : 77 78 2: zap $1, $24, $1 # U : 79 nop # E : 80 stq_u $1, 0($16) # L : 81 ret # L0 : 82 83 1: /* Here we must clear the first byte o 84 stb $31, 8($16) # L : 85 nop # E : 86 nop # E : 87 ret # L0 : 88 89 $zerocount: 90 nop # E : 91 nop # E : 92 nop # E : 93 ret # L0 : 94 95 .end strncat 96 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.