1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * arch/alpha/lib/strncpy.S 4 * Contributed by Richard Henderson (rth@tamu. 5 * 6 * Copy no more than COUNT bytes of the null-t 7 * SRC to DST. If SRC does not cover all of C 8 * zeroed. 9 * 10 * Or, rather, if the kernel cared about that 11 * version has cropped that bit o' nastiness a 12 * __stxncpy is in range of a branch. 13 */ 14 #include <linux/export.h> 15 .set noat 16 .set noreorder 17 18 .text 19 20 .align 4 21 .globl strncpy 22 .ent strncpy 23 strncpy: 24 .frame $30, 0, $26 25 .prologue 0 26 27 mov $16, $0 # set return v 28 beq $18, $zerolen 29 unop 30 bsr $23, __stxncpy # do the work 31 32 unop 33 bne $18, $multiword # do we have f 34 subq $24, 1, $3 # nope 35 subq $27, 1, $4 36 37 or $3, $24, $3 # clear the bi 38 or $4, $27, $4 # written byte 39 andnot $3, $4, $4 40 zap $1, $4, $1 41 42 stq_u $1, 0($16) 43 ret 44 45 .align 4 46 $multiword: 47 subq $27, 1, $2 # clear the fi 48 or $2, $27, $2 49 zapnot $1, $2, $1 50 subq $18, 1, $18 51 52 stq_u $1, 0($16) 53 addq $16, 8, $16 54 unop 55 beq $18, 1f 56 57 nop 58 unop 59 nop 60 blbc $18, 0f 61 62 stq_u $31, 0($16) # zero one wor 63 subq $18, 1, $18 64 addq $16, 8, $16 65 beq $18, 1f 66 67 0: stq_u $31, 0($16) # zero two wor 68 subq $18, 2, $18 69 stq_u $31, 8($16) 70 addq $16, 16, $16 71 bne $18, 0b 72 73 1: ldq_u $1, 0($16) # clear the le 74 subq $24, 1, $2 75 or $2, $24, $2 76 77 zap $1, $2, $1 78 stq_u $1, 0($16) 79 $zerolen: 80 ret 81 82 .end strncpy 83 EXPORT_SYMBOL(strncpy)
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.