Update copyright notices with scripts/update-copyrights
[glibc.git] / ports / sysdeps / alpha / alphaev67 / stpncpy.S
blob451b2e03c42739fc81f64478ce4ca310c8a174ea
1 /* Copyright (C) 2000-2014 Free Software Foundation, Inc.
2    Contributed by Richard Henderson (rth@redhat.com)
3    This file is part of the GNU C Library.
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library.  If not, see
17    <http://www.gnu.org/licenses/>.  */
19 /* Copy no more than N bytes from SRC to DEST, returning the address of
20    the terminating '\0' in DEST.  */
22 #include <sysdep.h>
24         .arch ev6
25         .set noat
26         .set noreorder
27         .text
29 ENTRY(__stpncpy)
30         ldgp    gp, 0(pv)
31 #ifdef PROF
32         lda     AT, _mcount
33         jsr     AT, (AT), _mcount
34 #endif
35         .prologue 1
37         mov     a0, v0
38         beq     a2, $zerocount
40         .align 4
41         nop
42         nop
43         jsr     t9, __stxncpy   # do the work of the copy
45         cttz    t8, t4
46         zapnot  t0, t8, t5
47         andnot  a0, 7, a0
48         bne     a2, $multiword  # do we have full words left?
50         subq    t8, 1, t2
51         subq    t10, 1, t3
52         cmpult  zero, t5, t5
53         addq    a0, t4, v0
55         or      t2, t8, t2
56         or      t3, t10, t3
57         addq    v0, t5, v0
58         andnot  t3, t2, t3
60         zap     t0, t3, t0
61         nop
62         stq     t0, 0(a0)
63         ret
65 $multiword:
66         subq    t8, 1, t7       # clear the final bits in the prev word
67         cmpult  zero, t5, t5
68         or      t7, t8, t7
69         zapnot  t0, t7, t0
71         subq    a2, 1, a2
72         stq     t0, 0(a0)
73         addq    a0, 8, a1
74         beq     a2, 1f          # loop over full words remaining
76         nop
77         nop
78         nop
79         blbc    a2, 0f
81         stq     zero, 0(a1)
82         subq    a2, 1, a2
83         addq    a1, 8, a1
84         beq     a2, 1f
86 0:      stq     zero, 0(a1)
87         subq    a2, 2, a2
88         nop
89         nop
91         stq     zero, 8(a1)
92         addq    a1, 16, a1
93         nop
94         bne     a2, 0b
96 1:      ldq     t0, 0(a1)       # clear the leading bits in the final word
97         subq    t10, 1, t7
98         addq    a0, t4, v0
99         nop
101         or      t7, t10, t7
102         addq    v0, t5, v0
103         zap     t0, t7, t0
104         stq     t0, 0(a1)
106 $zerocount:
107         nop
108         nop
109         nop
110         ret
112         END(__stpncpy)
114 libc_hidden_def (__stpncpy)
115 weak_alias (__stpncpy, stpncpy)