stpcpy.S 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* Copyright (C) 1996-2026 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library. If not, see
  13. <https://www.gnu.org/licenses/>. */
  14. /* Copy a null-terminated string from SRC to DST. Return a pointer
  15. to the null-terminator in the source. */
  16. #include <sysdep.h>
  17. .text
  18. ENTRY(__stpcpy)
  19. ldgp gp, 0(pv)
  20. #ifdef PROF
  21. .set noat
  22. lda AT, _mcount
  23. jsr AT, (AT), _mcount
  24. .set at
  25. #endif
  26. .prologue 1
  27. jsr t9, __stxcpy # do the work of the copy
  28. and t8, 0xf0, t2 # binary search for byte offset of the
  29. and t8, 0xcc, t1 # last byte written.
  30. and t8, 0xaa, t0
  31. andnot a0, 7, a0
  32. cmovne t2, 4, t2
  33. cmovne t1, 2, t1
  34. cmovne t0, 1, t0
  35. addq a0, t2, v0
  36. addq t0, t1, t0
  37. addq v0, t0, v0
  38. ret
  39. END(__stpcpy)
  40. weak_alias (__stpcpy, stpcpy)
  41. libc_hidden_def (__stpcpy)
  42. libc_hidden_builtin_def (stpcpy)