]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blame - arch/powerpc/lib/string.S
Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[mirror_ubuntu-zesty-kernel.git] / arch / powerpc / lib / string.S
CommitLineData
14cf11af
PM
1/*
2 * String handling functions for PowerPC.
3 *
4 * Copyright (C) 1996 Paul Mackerras.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
14cf11af
PM
11#include <asm/processor.h>
12#include <asm/errno.h>
13#include <asm/ppc_asm.h>
14
14cf11af 15 .section __ex_table,"a"
76bfdcf7 16 PPC_LONG_ALIGN
14cf11af
PM
17 .text
18
14cf11af
PM
19/* This clears out any unused part of the destination buffer,
20 just as the libc version does. -- paulus */
21_GLOBAL(strncpy)
ca5d0674 22 PPC_LCMPI 0,r5,0
14cf11af
PM
23 beqlr
24 mtctr r5
25 addi r6,r3,-1
26 addi r4,r4,-1
87a156fb 27 .balign 16
14cf11af
PM
281: lbzu r0,1(r4)
29 cmpwi 0,r0,0
30 stbu r0,1(r6)
31 bdnzf 2,1b /* dec ctr, branch if ctr != 0 && !cr0.eq */
32 bnelr /* if we didn't hit a null char, we're done */
33 mfctr r5
ca5d0674 34 PPC_LCMPI 0,r5,0 /* any space left in destination buffer? */
14cf11af
PM
35 beqlr /* we know r0 == 0 here */
362: stbu r0,1(r6) /* clear it out if so */
37 bdnz 2b
38 blr
39
0119536c 40_GLOBAL(strncmp)
ca5d0674
AS
41 PPC_LCMPI 0,r5,0
42 beq- 2f
0119536c
SR
43 mtctr r5
44 addi r5,r3,-1
45 addi r4,r4,-1
87a156fb 46 .balign 16
0119536c
SR
471: lbzu r3,1(r5)
48 cmpwi 1,r3,0
49 lbzu r0,1(r4)
50 subf. r3,r0,r3
51 beqlr 1
52 bdnzt eq,1b
53 blr
637a9902
JM
542: li r3,0
55 blr
0119536c 56
15c2d45d 57#ifdef CONFIG_PPC32
14cf11af 58_GLOBAL(memcmp)
ca5d0674
AS
59 PPC_LCMPI 0,r5,0
60 beq- 2f
14cf11af
PM
61 mtctr r5
62 addi r6,r3,-1
63 addi r4,r4,-1
641: lbzu r3,1(r6)
65 lbzu r0,1(r4)
66 subf. r3,r0,r3
67 bdnzt 2,1b
68 blr
692: li r3,0
70 blr
15c2d45d 71#endif
14cf11af
PM
72
73_GLOBAL(memchr)
ca5d0674
AS
74 PPC_LCMPI 0,r5,0
75 beq- 2f
14cf11af
PM
76 mtctr r5
77 addi r3,r3,-1
87a156fb 78 .balign 16
14cf11af
PM
791: lbzu r0,1(r3)
80 cmpw 0,r0,r4
81 bdnzf 2,1b
82 beqlr
832: li r3,0
84 blr
85
17968fbb 86#ifdef CONFIG_PPC32
14cf11af
PM
87_GLOBAL(__clear_user)
88 addi r6,r3,-4
89 li r3,0
90 li r5,0
91 cmplwi 0,r4,4
92 blt 7f
93 /* clear a single word */
9411: stwu r5,4(r6)
95 beqlr
96 /* clear word sized chunks */
97 andi. r0,r6,3
98 add r4,r0,r4
99 subf r6,r0,r6
100 srwi r0,r4,2
101 andi. r4,r4,3
102 mtctr r0
103 bdz 7f
1041: stwu r5,4(r6)
105 bdnz 1b
106 /* clear byte sized chunks */
1077: cmpwi 0,r4,0
108 beqlr
109 mtctr r4
110 addi r6,r6,3
1118: stbu r5,1(r6)
112 bdnz 8b
113 blr
11490: mr r3,r4
115 blr
11691: mfctr r3
117 slwi r3,r3,2
118 add r3,r3,r4
119 blr
12092: mfctr r3
121 blr
122
123 .section __ex_table,"a"
76bfdcf7
ME
124 PPC_LONG 11b,90b
125 PPC_LONG 1b,91b
126 PPC_LONG 8b,92b
14cf11af 127 .text
17968fbb 128#endif