0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 #include <asm/export.h>
0025 .text
0026
0027 .align 4
0028 .globl strncat
0029 .ent strncat
0030 strncat:
0031 .frame $30, 0, $26
0032 .prologue 0
0033
0034 mov $16, $0 # set up return value
0035 beq $18, $zerocount # U :
0036
0037 ldq_u $1, 0($16) # L : load first quadword ($16 may be misaligned)
0038 lda $2, -1($31) # E :
0039
0040 insqh $2, $0, $2 # U :
0041 andnot $16, 7, $16 # E :
0042 nop # E :
0043 or $2, $1, $1 # E :
0044
0045 nop # E :
0046 nop # E :
0047 cmpbge $31, $1, $2 # E : bits set iff byte == 0
0048 bne $2, $found # U :
0049
0050 $loop: ldq $1, 8($16) # L :
0051 addq $16, 8, $16 # E :
0052 cmpbge $31, $1, $2 # E :
0053 beq $2, $loop # U :
0054
0055 $found: cttz $2, $3 # U0 :
0056 addq $16, $3, $16 # E :
0057 nop # E :
0058 bsr $23, __stxncpy # L0 :
0059
0060
0061
0062 zapnot $1, $27, $2 # U : was last byte a null?
0063 cmplt $27, $24, $5 # E : did we fill the buffer completely?
0064 bne $2, 0f # U :
0065 ret # L0 :
0066
0067 0: or $5, $18, $2 # E :
0068 nop
0069 bne $2, 2f # U :
0070 and $24, 0x80, $3 # E : no zero next byte
0071
0072 nop # E :
0073 bne $3, 1f # U :
0074
0075 addq $24, $24, $24 # E : end-of-count bit <<= 1
0076 nop # E :
0077
0078 2: zap $1, $24, $1 # U :
0079 nop # E :
0080 stq_u $1, 0($16) # L :
0081 ret # L0 :
0082
0083 1:
0084 stb $31, 8($16) # L :
0085 nop # E :
0086 nop # E :
0087 ret # L0 :
0088
0089 $zerocount:
0090 nop # E :
0091 nop # E :
0092 nop # E :
0093 ret # L0 :
0094
0095 .end strncat
0096 EXPORT_SYMBOL(strncat)