aboutsummaryrefslogtreecommitdiffstats
path: root/arch/alpha/lib/strncpy.S
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/alpha/lib/strncpy.S
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'arch/alpha/lib/strncpy.S')
-rw-r--r--arch/alpha/lib/strncpy.S81
1 files changed, 81 insertions, 0 deletions
diff --git a/arch/alpha/lib/strncpy.S b/arch/alpha/lib/strncpy.S
new file mode 100644
index 000000000000..338551c7113c
--- /dev/null
+++ b/arch/alpha/lib/strncpy.S
@@ -0,0 +1,81 @@
1/*
2 * arch/alpha/lib/strncpy.S
3 * Contributed by Richard Henderson (rth@tamu.edu)
4 *
5 * Copy no more than COUNT bytes of the null-terminated string from
6 * SRC to DST. If SRC does not cover all of COUNT, the balance is
7 * zeroed.
8 *
9 * Or, rather, if the kernel cared about that weird ANSI quirk. This
10 * version has cropped that bit o' nastiness as well as assuming that
11 * __stxncpy is in range of a branch.
12 */
13
14 .set noat
15 .set noreorder
16
17 .text
18
19 .align 4
20 .globl strncpy
21 .ent strncpy
22strncpy:
23 .frame $30, 0, $26
24 .prologue 0
25
26 mov $16, $0 # set return value now
27 beq $18, $zerolen
28 unop
29 bsr $23, __stxncpy # do the work of the copy
30
31 unop
32 bne $18, $multiword # do we have full words left?
33 subq $24, 1, $3 # nope
34 subq $27, 1, $4
35
36 or $3, $24, $3 # clear the bits between the last
37 or $4, $27, $4 # written byte and the last byte in COUNT
38 andnot $4, $3, $4
39 zap $1, $4, $1
40
41 stq_u $1, 0($16)
42 ret
43
44 .align 4
45$multiword:
46 subq $24, 1, $2 # clear the final bits in the prev word
47 or $2, $24, $2
48 zapnot $1, $2, $1
49 subq $18, 1, $18
50
51 stq_u $1, 0($16)
52 addq $16, 8, $16
53 unop
54 beq $18, 1f
55
56 nop
57 unop
58 nop
59 blbc $18, 0f
60
61 stq_u $31, 0($16) # zero one word
62 subq $18, 1, $18
63 addq $16, 8, $16
64 beq $18, 1f
65
660: stq_u $31, 0($16) # zero two words
67 subq $18, 2, $18
68 stq_u $31, 8($16)
69 addq $16, 16, $16
70 bne $18, 0b
71
721: ldq_u $1, 0($16) # clear the leading bits in the final word
73 subq $27, 1, $2
74 or $2, $27, $2
75
76 zap $1, $2, $1
77 stq_u $1, 0($16)
78$zerolen:
79 ret
80
81 .end strncpy