1 The alpha assembly version of various string functions do not work
2 correctly on some corner cases, and thus doesn't pass the testsuite.
3 This patch removes them.
6 sysdeps/alpha/alphaev67/stpncpy.S | 114 ---------------
7 sysdeps/alpha/alphaev67/strncat.S | 85 -----------
8 sysdeps/alpha/stpncpy.S | 105 --------------
9 sysdeps/alpha/strcmp.S | 193 --------------------------
10 sysdeps/alpha/strncat.S | 93 ------------
11 sysdeps/alpha/strncmp.S | 276 --------------------------------------
12 sysdeps/alpha/strncpy.S | 86 -----------
13 7 files changed, 952 deletions(-)
15 --- a/sysdeps/alpha/alphaev67/stpncpy.S
18 -/* Copyright (C) 2000-2022 Free Software Foundation, Inc.
19 - This file is part of the GNU C Library.
21 - The GNU C Library is free software; you can redistribute it and/or
22 - modify it under the terms of the GNU Lesser General Public
23 - License as published by the Free Software Foundation; either
24 - version 2.1 of the License, or (at your option) any later version.
26 - The GNU C Library is distributed in the hope that it will be useful,
27 - but WITHOUT ANY WARRANTY; without even the implied warranty of
28 - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29 - Lesser General Public License for more details.
31 - You should have received a copy of the GNU Lesser General Public
32 - License along with the GNU C Library. If not, see
33 - <https://www.gnu.org/licenses/>. */
35 -/* Copy no more than N bytes from SRC to DEST, returning the address of
36 - the terminating '\0' in DEST. */
49 - jsr AT, (AT), _mcount
59 - jsr t9, __stxncpy # do the work of the copy
64 - bne a2, $multiword # do we have full words left?
82 - subq t8, 1, t7 # clear the final bits in the prev word
90 - beq a2, 1f # loop over full words remaining
112 -1: ldq t0, 0(a1) # clear the leading bits in the final word
130 -libc_hidden_def (__stpncpy)
131 -weak_alias (__stpncpy, stpncpy)
132 --- a/sysdeps/alpha/alphaev67/strncat.S
135 -/* Copyright (C) 2000-2022 Free Software Foundation, Inc.
136 - This file is part of the GNU C Library.
138 - The GNU C Library is free software; you can redistribute it and/or
139 - modify it under the terms of the GNU Lesser General Public
140 - License as published by the Free Software Foundation; either
141 - version 2.1 of the License, or (at your option) any later version.
143 - The GNU C Library is distributed in the hope that it will be useful,
144 - but WITHOUT ANY WARRANTY; without even the implied warranty of
145 - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
146 - Lesser General Public License for more details.
148 - You should have received a copy of the GNU Lesser General Public
149 - License along with the GNU C Library. If not, see
150 - <https://www.gnu.org/licenses/>. */
152 -/* Append no more than COUNT characters from the null-terminated string SRC
153 - to the null-terminated string DST. Always null-terminate the new DST. */
166 - jsr AT, (AT), _mcount
171 - mov a0, v0 # set up return value
172 - beq a2, $zerocount # U :
173 - /* Find the end of the string. */
174 - ldq_u t0, 0(a0) # L : load first quadword (a0 may be misaligned)
177 - insqh t1, v0, t1 # U :
178 - andnot a0, 7, a0 # E :
180 - or t1, t0, t0 # E :
184 - cmpbge zero, t0, t1 # E : bits set iff byte == 0
185 - bne t1, $found # U :
187 -$loop: ldq t0, 8(a0) # L :
188 - addq a0, 8, a0 # E :
189 - cmpbge zero, t0, t1 # E :
190 - beq t1, $loop # U :
192 -$found: cttz t1, t2 # U0 :
193 - addq a0, t2, a0 # E :
194 - jsr t9, __stxncpy # L0 : Now do the append.
196 - /* Worry about the null termination. */
198 - cttz t10, t2 # U0: byte offset of end-of-count.
199 - bic a0, 7, a0 # E : word align the last write address.
200 - zapnot t0, t8, t1 # U : was last byte a null?
208 -0: addq t2, a0, a0 # E : address of end-of-count
209 - stb zero, 1(a0) # L :
220 --- a/sysdeps/alpha/stpncpy.S
223 -/* Copyright (C) 1996-2022 Free Software Foundation, Inc.
224 - This file is part of the GNU C Library.
226 - The GNU C Library is free software; you can redistribute it and/or
227 - modify it under the terms of the GNU Lesser General Public
228 - License as published by the Free Software Foundation; either
229 - version 2.1 of the License, or (at your option) any later version.
231 - The GNU C Library is distributed in the hope that it will be useful,
232 - but WITHOUT ANY WARRANTY; without even the implied warranty of
233 - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
234 - Lesser General Public License for more details.
236 - You should have received a copy of the GNU Lesser General Public
237 - License along with the GNU C Library. If not, see
238 - <https://www.gnu.org/licenses/>. */
240 -/* Copy no more than COUNT bytes of the null-terminated string from
241 - SRC to DST. If SRC does not cover all of COUNT, the balance is
242 - zeroed. Return the address of the terminating null in DEST, if
243 - any, else DEST + COUNT. */
256 - jsr AT, (AT), _mcount
261 - jsr t9, __stxncpy # do the work of the copy
263 - and t8, 0xf0, t3 # binary search for byte offset of the
264 - and t8, 0xcc, t2 # last byte written.
274 - bne a2, $multiword # do we have full words left?
277 - zapnot t0, t8, t4 # e0 : was last byte a null?
278 - subq t8, 1, t2 # .. e1 :
279 - addq v0, 1, t5 # e0 :
280 - subq t10, 1, t3 # .. e1 :
281 - or t2, t8, t2 # e0 : clear the bits between the last
282 - or t3, t10, t3 # .. e1 : written byte and the last byte in
283 - andnot t3, t2, t3 # e0 : COUNT
284 - cmovne t4, t5, v0 # .. e1 : if last written wasnt null, inc v0
285 - zap t0, t3, t0 # e0 :
286 - stq_u t0, 0(a0) # e1 :
291 - subq t8, 1, t7 # e0 : clear the final bits in the prev
292 - or t7, t8, t7 # e1 : word
293 - zapnot t0, t7, t0 # e0 :
294 - subq a2, 1, a2 # .. e1 :
295 - stq_u t0, 0(a0) # e0 :
296 - addq a0, 8, a0 # .. e1 :
301 - stq_u zero, 0(a0) # e0 : zero one word
302 - subq a2, 1, a2 # .. e1 :
303 - addq a0, 8, a0 # e0 :
304 - beq a2, 1f # .. e1 :
306 -0: stq_u zero, 0(a0) # e0 : zero two words
307 - subq a2, 2, a2 # .. e1 :
308 - stq_u zero, 8(a0) # e0 :
309 - addq a0, 16, a0 # .. e1 :
313 -1: ldq_u t0, 0(a0) # e0 : clear the leading bits in the final
314 - subq t10, 1, t7 # .. e1 : word
315 - or t7, t10, t7 # e0 :
316 - zap t0, t7, t0 # e1 (stall)
317 - stq_u t0, 0(a0) # e0 :
326 -libc_hidden_def (__stpncpy)
327 -weak_alias (__stpncpy, stpncpy)
328 --- a/sysdeps/alpha/strcmp.S
331 -/* Copyright (C) 1996-2022 Free Software Foundation, Inc.
332 - This file is part of the GNU C Library.
334 - The GNU C Library is free software; you can redistribute it and/or
335 - modify it under the terms of the GNU Lesser General Public
336 - License as published by the Free Software Foundation; either
337 - version 2.1 of the License, or (at your option) any later version.
339 - The GNU C Library is distributed in the hope that it will be useful,
340 - but WITHOUT ANY WARRANTY; without even the implied warranty of
341 - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
342 - Lesser General Public License for more details.
344 - You should have received a copy of the GNU Lesser General Public
345 - License along with the GNU C Library. If not, see
346 - <https://www.gnu.org/licenses/>. */
348 -/* Bytewise compare two null-terminated strings. */
361 - jmp AT, (AT), _mcount
367 - ldq_u t0, 0(a0) # e0 : give cache time to catch up
368 - xor a0, a1, t2 # .. e1 : are s1 and s2 co-aligned?
369 - ldq_u t1, 0(a1) # e0 :
370 - and t2, 7, t2 # .. e1 :
372 - bne t2, $unaligned # .. e1 :
374 - /* On entry to this basic block:
375 - t0 == the first destination word for masking back in
376 - t1 == the first source word.
380 - mskqh t3, a0, t3 # e0 :
382 - ornot t1, t3, t1 # e0 :
383 - ornot t0, t3, t0 # .. e1 :
384 - cmpbge zero, t1, t7 # e0 : bits set iff null found
385 - bne t7, $eos # e1 (zdb)
387 - /* Aligned compare main loop.
388 - On entry to this basic block:
390 - t1 == an s2 word not containing a null. */
393 - xor t0, t1, t2 # e0 :
394 - bne t2, $wordcmp # .. e1 (zdb)
395 - ldq_u t1, 8(a1) # e0 :
396 - ldq_u t0, 8(a0) # .. e1 :
397 - addq a1, 8, a1 # e0 :
398 - addq a0, 8, a0 # .. e1 :
399 - cmpbge zero, t1, t7 # e0 :
400 - beq t7, $a_loop # .. e1 (zdb)
403 - /* The two strings are not co-aligned. Align s1 and cope. */
406 - and a0, 7, t4 # e0 : find s1 misalignment
407 - and a1, 7, t5 # .. e1 : find s2 misalignment
408 - subq a1, t4, a1 # e0 :
410 - /* If s2 misalignment is larger than s2 misalignment, we need
411 - extra startup checks to avoid SEGV. */
413 - cmplt t4, t5, t8 # .. e1 :
414 - beq t8, $u_head # e1 :
416 - mskqh t3, t5, t3 # e0 :
417 - ornot t1, t3, t3 # e0 :
418 - cmpbge zero, t3, t7 # e1 : is there a zero?
419 - beq t7, $u_head # e1 :
421 - /* We've found a zero in the first partial word of s2. Align
422 - our current s1 and s2 words and compare what we've got. */
424 - extql t1, t5, t1 # e0 :
425 - extql t0, a0, t0 # e0 :
426 - cmpbge zero, t1, t7 # .. e1 : find that zero again
427 - br $eos # e1 : and finish up
431 - /* We know just enough now to be able to assemble the first
432 - full word of s2. We can still find a zero at the end of it.
434 - On entry to this basic block:
435 - t0 == first word of s1
436 - t1 == first partial word of s2. */
438 - ldq_u t2, 8(a1) # e0 : load second partial s2 word
439 - lda t3, -1 # .. e1 : create leading garbage mask
440 - extql t1, a1, t1 # e0 : create first s2 word
441 - mskqh t3, a0, t3 # e0 :
442 - extqh t2, a1, t4 # e0 :
443 - ornot t0, t3, t0 # .. e1 : kill s1 garbage
444 - or t1, t4, t1 # e0 : s2 word now complete
445 - cmpbge zero, t0, t7 # .. e1 : find zero in first s1 word
446 - ornot t1, t3, t1 # e0 : kill s2 garbage
447 - lda t3, -1 # .. e1 :
448 - mskql t3, a1, t3 # e0 : mask for s2[1] bits we have seen
449 - bne t7, $eos # .. e1 :
450 - xor t0, t1, t4 # e0 : compare aligned words
451 - bne t4, $wordcmp # .. e1 (zdb)
452 - or t2, t3, t3 # e0 :
453 - cmpbge zero, t3, t7 # e1 :
454 - bne t7, $u_final # e1 :
456 - /* Unaligned copy main loop. In order to avoid reading too much,
457 - the loop is structured to detect zeros in aligned words from s2.
458 - This has, unfortunately, effectively pulled half of a loop
459 - iteration out into the head and half into the tail, but it does
460 - prevent nastiness from accumulating in the very thing we want
461 - to run as fast as possible.
463 - On entry to this basic block:
464 - t2 == the unshifted low-bits from the next s2 word. */
468 - extql t2, a1, t3 # e0 :
469 - ldq_u t2, 16(a1) # .. e1 : load next s2 high bits
470 - ldq_u t0, 8(a0) # e0 : load next s1 word
471 - addq a1, 8, a1 # .. e1 :
472 - addq a0, 8, a0 # e0 :
474 - extqh t2, a1, t1 # e0 :
475 - cmpbge zero, t0, t7 # .. e1 : find zero in current s1 word
476 - or t1, t3, t1 # e0 :
477 - bne t7, $eos # .. e1 :
478 - xor t0, t1, t4 # e0 : compare the words
479 - bne t4, $wordcmp # .. e1 (zdb)
480 - cmpbge zero, t2, t4 # e0 : find zero in next low bits
481 - beq t4, $u_loop # .. e1 (zdb)
483 - /* We've found a zero in the low bits of the last s2 word. Get
484 - the next s1 word and align them. */
486 - ldq_u t0, 8(a0) # e1 :
487 - extql t2, a1, t1 # .. e0 :
488 - cmpbge zero, t1, t7 # e0 :
490 - /* We've found a zero somewhere in a word we just read.
491 - On entry to this basic block:
494 - t7 == cmpbge mask containing the zero. */
498 - negq t7, t6 # e0 : create bytemask of valid data
499 - and t6, t7, t8 # e1 :
500 - subq t8, 1, t6 # e0 :
501 - or t6, t8, t7 # e1 :
502 - zapnot t0, t7, t0 # e0 : kill the garbage
503 - zapnot t1, t7, t1 # .. e1 :
504 - xor t0, t1, v0 # e0 : and compare
505 - beq v0, $done # .. e1 :
507 - /* Here we have two differing co-aligned words in t0 & t1.
508 - Bytewise compare them and return (t0 > t1 ? 1 : -1). */
510 - cmpbge t0, t1, t2 # e0 : comparison yields bit mask of ge
511 - cmpbge t1, t0, t3 # .. e1 :
512 - xor t2, t3, t0 # e0 : bits set iff t0/t1 bytes differ
513 - negq t0, t1 # e1 : clear all but least bit
514 - and t0, t1, t0 # e0 :
515 - lda v0, -1 # .. e1 :
516 - and t0, t2, t1 # e0 : was bit set in t0 > t1?
517 - cmovne t1, 1, v0 # .. e1 (zdb)
523 -libc_hidden_builtin_def (strcmp)
524 --- a/sysdeps/alpha/strncat.S
527 -/* Copyright (C) 1996-2022 Free Software Foundation, Inc.
528 - This file is part of the GNU C Library.
530 - The GNU C Library is free software; you can redistribute it and/or
531 - modify it under the terms of the GNU Lesser General Public
532 - License as published by the Free Software Foundation; either
533 - version 2.1 of the License, or (at your option) any later version.
535 - The GNU C Library is distributed in the hope that it will be useful,
536 - but WITHOUT ANY WARRANTY; without even the implied warranty of
537 - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
538 - Lesser General Public License for more details.
540 - You should have received a copy of the GNU Lesser General Public
541 - License along with the GNU C Library. If not, see
542 - <https://www.gnu.org/licenses/>. */
544 -/* Append no more than COUNT characters from the null-terminated string SRC
545 - to the null-terminated string DST. Always null-terminate the new DST. */
556 - jsr AT, (AT), _mcount
561 - mov a0, v0 # set up return value
564 - /* Find the end of the string. */
566 - ldq_u t0, 0(a0) # load first quadword (a0 may be misaligned)
571 - cmpbge zero, t0, t1 # t1 <- bitmask: bit i == 1 <==> i-th byte == 0
574 -$loop: ldq t0, 8(a0)
575 - addq a0, 8, a0 # addr += 8
576 - cmpbge zero, t0, t1
579 -$found: negq t1, t2 # clear all but least set bit
582 - and t1, 0xf0, t2 # binary search for that set bit
592 - /* Now do the append. */
596 - /* Worry about the null termination. */
598 - zapnot t0, t8, t1 # was last byte a null?
602 -0: and t10, 0x80, t1
605 - /* Here there are bytes left in the current word. Clear one. */
606 - addq t10, t10, t10 # end-of-count bit <<= 1
611 -1: /* Here we must read the next DST word and clear the first byte. */
620 --- a/sysdeps/alpha/strncmp.S
623 -/* Copyright (C) 1996-2022 Free Software Foundation, Inc.
624 - This file is part of the GNU C Library.
626 - The GNU C Library is free software; you can redistribute it and/or
627 - modify it under the terms of the GNU Lesser General Public
628 - License as published by the Free Software Foundation; either
629 - version 2.1 of the License, or (at your option) any later version.
631 - The GNU C Library is distributed in the hope that it will be useful,
632 - but WITHOUT ANY WARRANTY; without even the implied warranty of
633 - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
634 - Lesser General Public License for more details.
636 - You should have received a copy of the GNU Lesser General Public
637 - License along with the GNU C Library. If not, see
638 - <https://www.gnu.org/licenses/>. */
640 -/* Bytewise compare two null-terminated strings of length no longer than N. */
647 -/* EV6 only predicts one branch per octaword. We'll use these to push
648 - subsequent branches back to the next bundle. This will generally add
649 - a fetch+decode cycle to older machines, so skip in that case. */
650 -#ifdef __alpha_fix__
651 -# define ev6_unop unop
662 - jsr AT, (AT), _mcount
668 - xor a0, a1, t2 # are s1 and s2 co-aligned?
669 - beq a2, $zerolength
670 - ldq_u t0, 0(a0) # load asap to give cache time to catch up
675 - and a0, 7, t4 # find s1 misalignment
676 - and a1, 7, t5 # find s2 misalignment
677 - cmovlt a2, t6, a2 # bound neg count to LONG_MAX
678 - addq a1, a2, a3 # s2+count
679 - addq a2, t4, a2 # bias count by s1 misalignment
680 - and a2, 7, t10 # ofs of last byte in s1 last word
681 - srl a2, 3, a2 # remaining full words in s1 count
684 - /* On entry to this basic block:
685 - t0 == the first word of s1.
686 - t1 == the first word of s2.
689 - mskqh t3, a1, t8 # mask off leading garbage
692 - cmpbge zero, t1, t7 # bits set iff null found
693 - beq a2, $eoc # check end of count
697 - /* Aligned compare main loop.
698 - On entry to this basic block:
700 - t1 == an s2 word not containing a null. */
704 - xor t0, t1, t2 # e0 :
705 - bne t2, $wordcmp # .. e1 (zdb)
706 - ldq_u t1, 8(a1) # e0 :
707 - ldq_u t0, 8(a0) # .. e1 :
709 - subq a2, 1, a2 # e0 :
710 - addq a1, 8, a1 # .. e1 :
711 - addq a0, 8, a0 # e0 :
712 - beq a2, $eoc # .. e1 :
714 - cmpbge zero, t1, t7 # e0 :
715 - beq t7, $a_loop # .. e1 :
719 - /* Alternate aligned compare loop, for when there's no trailing
720 - bytes on the count. We have to avoid reading too much data. */
723 - xor t0, t1, t2 # e0 :
726 - bne t2, $wordcmp # .. e1 (zdb)
728 - subq a2, 1, a2 # e0 :
729 - beq a2, $zerolength # .. e1 :
730 - ldq_u t1, 8(a1) # e0 :
731 - ldq_u t0, 8(a0) # .. e1 :
733 - addq a1, 8, a1 # e0 :
734 - addq a0, 8, a0 # .. e1 :
735 - cmpbge zero, t1, t7 # e0 :
736 - beq t7, $ant_loop # .. e1 :
740 - /* The two strings are not co-aligned. Align s1 and cope. */
741 - /* On entry to this basic block:
742 - t0 == the first word of s1.
743 - t1 == the first word of s2.
745 - t4 == misalignment of s1.
746 - t5 == misalignment of s2.
747 - t10 == misalignment of s1 end. */
750 - /* If s1 misalignment is larger than s2 misalignment, we need
751 - extra startup checks to avoid SEGV. */
752 - subq a1, t4, a1 # adjust s2 for s1 misalignment
754 - subq a3, 1, a3 # last byte of s2
756 - mskqh t3, t5, t7 # mask garbage in s2
759 - srl a3, 3, a3 # remaining full words in s2 count
762 - /* Failing that, we need to look for both eos and eoc within the
763 - first word of s2. If we find either, we can continue by
764 - pretending that the next word of s2 is all zeros. */
765 - lda t2, 0 # next = zero
766 - cmpeq a3, 0, t8 # eoc in the first word of s2?
767 - cmpbge zero, t7, t7 # eos in the first word of s2?
771 - /* We know just enough now to be able to assemble the first
772 - full word of s2. We can still find a zero at the end of it.
774 - On entry to this basic block:
775 - t0 == first word of s1
776 - t1 == first partial word of s2.
778 - t10 == ofs of last byte in s1 last word.
779 - t11 == ofs of last byte in s2 last word. */
781 - ldq_u t2, 8(a1) # load second partial s2 word
784 - extql t1, a1, t1 # create first s2 word
787 - ornot t0, t8, t0 # kill s1 garbage
788 - or t1, t4, t1 # s2 word now complete
789 - cmpbge zero, t0, t7 # find eos in first s1 word
790 - ornot t1, t8, t1 # kill s2 garbage
794 - mskql t3, a1, t8 # mask out s2[1] bits we have seen
795 - xor t0, t1, t4 # compare aligned words
798 - cmpbge zero, t8, t7 # eos in high bits of s2[1]?
799 - cmpeq a3, 0, t8 # eoc in s2[1]?
803 - /* Unaligned copy main loop. In order to avoid reading too much,
804 - the loop is structured to detect zeros in aligned words from s2.
805 - This has, unfortunately, effectively pulled half of a loop
806 - iteration out into the head and half into the tail, but it does
807 - prevent nastiness from accumulating in the very thing we want
808 - to run as fast as possible.
810 - On entry to this basic block:
811 - t2 == the unshifted low-bits from the next s2 word.
812 - t10 == ofs of last byte in s1 last word.
813 - t11 == ofs of last byte in s2 last word. */
816 - extql t2, a1, t3 # e0 :
817 - ldq_u t2, 16(a1) # .. e1 : load next s2 high bits
818 - ldq_u t0, 8(a0) # e0 : load next s1 word
819 - addq a1, 8, a1 # .. e1 :
821 - addq a0, 8, a0 # e0 :
822 - subq a3, 1, a3 # .. e1 :
823 - extqh t2, a1, t1 # e0 :
824 - cmpbge zero, t0, t7 # .. e1 : eos in current s1 word
826 - or t1, t3, t1 # e0 :
827 - beq a2, $eoc # .. e1 : eoc in current s1 word
828 - subq a2, 1, a2 # e0 :
829 - cmpbge zero, t2, t4 # .. e1 : eos in s2[1]
831 - xor t0, t1, t3 # e0 : compare the words
834 - bne t7, $eos # .. e1 :
836 - cmpeq a3, 0, t5 # e0 : eoc in s2[1]
839 - bne t3, $wordcmp # .. e1 :
841 - or t4, t5, t4 # e0 : eos or eoc in s2[1].
842 - beq t4, $u_loop # .. e1 (zdb)
844 - /* We've found a zero in the low bits of the last s2 word. Get
845 - the next s1 word and align them. */
850 - cmpbge zero, t1, t7
853 - /* We've hit end of count. Zero everything after the count
854 - and compare whats left. */
859 - cmpbge zero, t1, t7
861 - /* We've found a zero somewhere in a word we just read.
862 - On entry to this basic block:
865 - t7 == cmpbge mask containing the zero. */
868 - negq t7, t6 # create bytemask of valid data
872 - zapnot t0, t7, t0 # kill the garbage
874 - xor t0, t1, v0 # ... and compare
877 - /* Here we have two differing co-aligned words in t0 & t1.
878 - Bytewise compare them and return (t0 > t1 ? 1 : -1). */
881 - cmpbge t0, t1, t2 # comparison yields bit mask of ge
883 - xor t2, t3, t0 # bits set iff t0/t1 bytes differ
884 - negq t0, t1 # clear all but least bit
887 - and t0, t2, t1 # was bit set in t0 > t1?
898 -libc_hidden_builtin_def (strncmp)
899 --- a/sysdeps/alpha/strncpy.S
902 -/* Copyright (C) 1996-2022 Free Software Foundation, Inc.
903 - This file is part of the GNU C Library.
905 - The GNU C Library is free software; you can redistribute it and/or
906 - modify it under the terms of the GNU Lesser General Public
907 - License as published by the Free Software Foundation; either
908 - version 2.1 of the License, or (at your option) any later version.
910 - The GNU C Library is distributed in the hope that it will be useful,
911 - but WITHOUT ANY WARRANTY; without even the implied warranty of
912 - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
913 - Lesser General Public License for more details.
915 - You should have received a copy of the GNU Lesser General Public
916 - License along with the GNU C Library. If not, see
917 - <https://www.gnu.org/licenses/>. */
919 -/* Copy no more than COUNT bytes of the null-terminated string from
920 - SRC to DST. If SRC does not cover all of COUNT, the balance is
934 - jsr AT, (AT), _mcount
938 - mov a0, v0 # set return value now
940 - jsr t9, __stxncpy # do the work of the copy
942 - bne a2, $multiword # do we have full words left?
945 - subq t8, 1, t2 # e0 : guess not
946 - subq t10, 1, t3 # .. e1 :
947 - or t2, t8, t2 # e0 : clear the bits between the last
948 - or t3, t10, t3 # .. e1 : written byte and the last byte in
949 - andnot t3, t2, t3 # e0 : COUNT
950 - zap t0, t3, t0 # e1 :
951 - stq_u t0, 0(a0) # e0 :
955 - subq t8, 1, t7 # e0 : clear the final bits in the prev
956 - or t7, t8, t7 # e1 : word
957 - zapnot t0, t7, t0 # e0 :
958 - subq a2, 1, a2 # .. e1 :
959 - stq_u t0, 0(a0) # e0 :
960 - addq a0, 8, a0 # .. e1 :
965 - stq_u zero, 0(a0) # e0 : zero one word
966 - subq a2, 1, a2 # .. e1 :
967 - addq a0, 8, a0 # e0 :
968 - beq a2, 1f # .. e1 :
970 -0: stq_u zero, 0(a0) # e0 : zero two words
971 - subq a2, 2, a2 # .. e1 :
972 - stq_u zero, 8(a0) # e0 :
973 - addq a0, 16, a0 # .. e1 :
977 -1: ldq_u t0, 0(a0) # e0 : clear the leading bits in the final
978 - subq t10, 1, t7 # .. e1 : word
979 - or t7, t10, t7 # e0 :
980 - zap t0, t7, t0 # e1 (stall)
981 - stq_u t0, 0(a0) # e0 :
987 -libc_hidden_builtin_def (strncpy)