summaryrefslogtreecommitdiff
path: root/na/lib/string/arm/__aeabi_memcpy.s
diff options
context:
space:
mode:
authorRichard Qin <richard.qin.x@gmail.com>2026-04-21 23:16:50 +0800
committerRichard Qin <richard.qin.x@gmail.com>2026-04-21 23:16:50 +0800
commit5278f6def4248391a481382bd7b0042b04c829f2 (patch)
tree6b41347c2675dfda2da34c3aec6cea11ad033fe0 /na/lib/string/arm/__aeabi_memcpy.s
parente7b6e9453800ecf15bee5f8f1763fd8c4862f70c (diff)
downloadlume-5278f6def4248391a481382bd7b0042b04c829f2.tar.gz
lume-5278f6def4248391a481382bd7b0042b04c829f2.tar.xz
feat: add string manipulation functions derived from musl libc
This commit introduces a variety of string manipulation functions, including: - `memmem`: Searches for a substring in a memory area. - `memmove`: Safely copies memory areas, handling overlaps. - `mempcpy`: Copies memory and returns a pointer to the end of the destination. - `memrchr`: Finds the last occurrence of a character in a memory area. - `memset`: Fills a memory area with a specified value. - `rindex`: Returns the last occurrence of a character in a string. - `stpcpy` and `stpncpy`: Copies strings and returns a pointer to the end. - `strcat`, `strchr`, `strcspn`, `strlcat`, `strlcpy`, `strlen`, `strncat`, `strncmp`, `strncpy`, `strnlen`, `strpbrk`, `strrchr`, `strstr`, `strtok`, and `strtok_r`: Various string manipulation functions for concatenation, searching, and tokenization. Assembly implementations for `memcpy`, `memmove`, and `memset` are also included for optimized performance on x86_64 architectures.
Diffstat (limited to 'na/lib/string/arm/__aeabi_memcpy.s')
-rw-r--r--na/lib/string/arm/__aeabi_memcpy.s45
1 files changed, 45 insertions, 0 deletions
diff --git a/na/lib/string/arm/__aeabi_memcpy.s b/na/lib/string/arm/__aeabi_memcpy.s
new file mode 100644
index 0000000..3a527e4
--- /dev/null
+++ b/na/lib/string/arm/__aeabi_memcpy.s
@@ -0,0 +1,45 @@
+.syntax unified
+
+.global __aeabi_memcpy8
+.global __aeabi_memcpy4
+.global __aeabi_memcpy
+.global __aeabi_memmove8
+.global __aeabi_memmove4
+.global __aeabi_memmove
+
+.type __aeabi_memcpy8,%function
+.type __aeabi_memcpy4,%function
+.type __aeabi_memcpy,%function
+.type __aeabi_memmove8,%function
+.type __aeabi_memmove4,%function
+.type __aeabi_memmove,%function
+
+__aeabi_memmove8:
+__aeabi_memmove4:
+__aeabi_memmove:
+ cmp r0, r1
+ bls 3f
+ cmp r2, #0
+ beq 2f
+ adds r0, r0, r2
+ adds r2, r1, r2
+1: subs r2, r2, #1
+ ldrb r3, [r2]
+ subs r0, r0, #1
+ strb r3, [r0]
+ cmp r1, r2
+ bne 1b
+2: bx lr
+__aeabi_memcpy8:
+__aeabi_memcpy4:
+__aeabi_memcpy:
+3: cmp r2, #0
+ beq 2f
+ adds r2, r1, r2
+1: ldrb r3, [r1]
+ adds r1, r1, #1
+ strb r3, [r0]
+ adds r0, r0, #1
+ cmp r1, r2
+ bne 1b
+2: bx lr