CVS commit: src/common/lib/libc/arch/arm/string
Module Name:src Committed By: skrll Date: Sun Jan 15 08:43:04 UTC 2023 Modified Files: src/common/lib/libc/arch/arm/string: strlen_arm.S Log Message: Fix strnlen with a large maxlen argument by using unsigned comparison conditions - from mlelstv. I had a similar, but not quite as good patch. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/common/lib/libc/arch/arm/string/strlen_arm.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/common/lib/libc/arch/arm/string
Module Name:src Committed By: skrll Date: Sun Jan 15 08:43:04 UTC 2023 Modified Files: src/common/lib/libc/arch/arm/string: strlen_arm.S Log Message: Fix strnlen with a large maxlen argument by using unsigned comparison conditions - from mlelstv. I had a similar, but not quite as good patch. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/common/lib/libc/arch/arm/string/strlen_arm.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/common/lib/libc/arch/arm/string/strlen_arm.S diff -u src/common/lib/libc/arch/arm/string/strlen_arm.S:1.10 src/common/lib/libc/arch/arm/string/strlen_arm.S:1.11 --- src/common/lib/libc/arch/arm/string/strlen_arm.S:1.10 Sat Dec 3 11:34:38 2022 +++ src/common/lib/libc/arch/arm/string/strlen_arm.S Sun Jan 15 08:43:03 2023 @@ -29,7 +29,7 @@ #include -RCSID("$NetBSD: strlen_arm.S,v 1.10 2022/12/03 11:34:38 skrll Exp $") +RCSID("$NetBSD: strlen_arm.S,v 1.11 2023/01/15 08:43:03 skrll Exp $") #if defined(__thumb__) && !defined(_ARM_ARCH_T2) #error Only Thumb2 or ARM supported @@ -102,7 +102,7 @@ ENTRY(FUNCNAME) .Lmain_loop: #ifdef STRNLEN cmp r0, r5 /* gone too far? */ - bge .Lmaxed_out /* yes, return maxlen */ + bhs .Lmaxed_out /* yes, return maxlen */ #endif ldr r3, [r0], #4 /* load next word */ #if defined(_ARM_ARCH_6) @@ -164,9 +164,9 @@ ENTRY(FUNCNAME) #ifdef STRNLEN cmp r0, r4 /* is it larger than maxlen? */ #ifdef __thumb__ - it gt + it hi #endif - movgt r0, r4 /* yes, return maxlen */ + movhi r0, r4 /* yes, return maxlen */ pop {r4, r5} /* restore registers */ #endif RET/* return */
CVS commit: src/common/lib/libc/arch/arm/string
Module Name:src Committed By: mlelstv Date: Thu Jan 19 18:03:03 UTC 2023 Modified Files: src/common/lib/libc/arch/arm/string: memcpy_arm.S memcpy_neon.S memcpy_xscale.S memmove.S memset.S memset_naive.S strlen_neon.S Log Message: Use unsigned comparisons for pointers and size_t values. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/common/lib/libc/arch/arm/string/memcpy_arm.S \ src/common/lib/libc/arch/arm/string/memcpy_xscale.S cvs rdiff -u -r1.1 -r1.2 src/common/lib/libc/arch/arm/string/memcpy_neon.S \ src/common/lib/libc/arch/arm/string/memset_naive.S cvs rdiff -u -r1.10 -r1.11 src/common/lib/libc/arch/arm/string/memmove.S cvs rdiff -u -r1.8 -r1.9 src/common/lib/libc/arch/arm/string/memset.S cvs rdiff -u -r1.3 -r1.4 src/common/lib/libc/arch/arm/string/strlen_neon.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/common/lib/libc/arch/arm/string/memcpy_arm.S diff -u src/common/lib/libc/arch/arm/string/memcpy_arm.S:1.5 src/common/lib/libc/arch/arm/string/memcpy_arm.S:1.6 --- src/common/lib/libc/arch/arm/string/memcpy_arm.S:1.5 Mon Dec 2 21:21:33 2013 +++ src/common/lib/libc/arch/arm/string/memcpy_arm.S Thu Jan 19 18:03:03 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: memcpy_arm.S,v 1.5 2013/12/02 21:21:33 joerg Exp $ */ +/* $NetBSD: memcpy_arm.S,v 1.6 2023/01/19 18:03:03 mlelstv Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -66,7 +66,7 @@ ENTRY(memcpy) push {r0, lr} /* memcpy() returns dest addr */ subs r2, r2, #4 - blt .Lmemcpy_l4 /* less than 4 bytes */ + blo .Lmemcpy_l4 /* less than 4 bytes */ ands r12, r0, #3 bne .Lmemcpy_destul /* oh unaligned destination addr */ ands r12, r1, #3 @@ -75,9 +75,9 @@ ENTRY(memcpy) .Lmemcpy_t8: /* We have aligned source and destination */ subs r2, r2, #8 - blt .Lmemcpy_l12 /* less than 12 bytes (4 from above) */ + blo .Lmemcpy_l12 /* less than 12 bytes (4 from above) */ subs r2, r2, #0x14 - blt .Lmemcpy_l32 /* less than 32 bytes (12 from above) */ + blo .Lmemcpy_l32 /* less than 32 bytes (12 from above) */ push {r4} /* borrow r4 */ /* blat 32 bytes at a time */ @@ -88,12 +88,12 @@ ENTRY(memcpy) ldmia r1!, {r3, r4, r12, lr} stmia r0!, {r3, r4, r12, lr} subs r2, r2, #0x20 - bge .Lmemcpy_loop32 + bhs .Lmemcpy_loop32 cmn r2, #0x10 - ldmiage r1!, {r3, r4, r12, lr} /* blat a remaining 16 bytes */ - stmiage r0!, {r3, r4, r12, lr} - subge r2, r2, #0x10 + ldmiahs r1!, {r3, r4, r12, lr} /* blat a remaining 16 bytes */ + stmiahs r0!, {r3, r4, r12, lr} + subhs r2, r2, #0x10 pop {r4} /* return r4 */ .Lmemcpy_l32: @@ -101,21 +101,21 @@ ENTRY(memcpy) /* blat 12 bytes at a time */ .Lmemcpy_loop12: - ldmiage r1!, {r3, r12, lr} - stmiage r0!, {r3, r12, lr} - subsge r2, r2, #0x0c - bge .Lmemcpy_loop12 + ldmiahs r1!, {r3, r12, lr} + stmiahs r0!, {r3, r12, lr} + subshs r2, r2, #0x0c + bhs .Lmemcpy_loop12 .Lmemcpy_l12: adds r2, r2, #8 - blt .Lmemcpy_l4 + blo .Lmemcpy_l4 subs r2, r2, #4 ldrlt r3, [r1], #4 strlt r3, [r0], #4 - ldmiage r1!, {r3, r12} - stmiage r0!, {r3, r12} - subge r2, r2, #4 + ldmiahs r1!, {r3, r12} + stmiahs r0!, {r3, r12} + subhs r2, r2, #4 .Lmemcpy_l4: /* less than 4 bytes to go */ @@ -129,10 +129,10 @@ ENTRY(memcpy) cmp r2, #2 ldrb r3, [r1], #1 strb r3, [r0], #1 - ldrbge r3, [r1], #1 - strbge r3, [r0], #1 - ldrbgt r3, [r1], #1 - strbgt r3, [r0], #1 + ldrbhs r3, [r1], #1 + strbhs r3, [r0], #1 + ldrbhi r3, [r1], #1 + strbhi r3, [r0], #1 pop {r0, pc} /* erg - unaligned destination */ @@ -143,12 +143,12 @@ ENTRY(memcpy) /* align destination with byte copies */ ldrb r3, [r1], #1 strb r3, [r0], #1 - ldrbge r3, [r1], #1 - strbge r3, [r0], #1 - ldrbgt r3, [r1], #1 - strbgt r3, [r0], #1 + ldrbhs r3, [r1], #1 + strbhs r3, [r0], #1 + ldrbhi r3, [r1], #1 + strbhi r3, [r0], #1 subs r2, r2, r12 - blt .Lmemcpy_l4 /* less the 4 bytes */ + blo .Lmemcpy_l4 /* less the 4 bytes */ ands r12, r1, #3 beq .Lmemcpy_t8 /* we have an aligned source */ @@ -159,10 +159,10 @@ ENTRY(memcpy) bic r1, r1, #3 ldr lr, [r1], #4 cmp r12, #2 - bgt .Lmemcpy_srcul3 + bhi .Lmemcpy_srcul3 beq .Lmemcpy_srcul2 cmp r2, #0x0c - blt .Lmemcpy_srcul1loop4 + blo .Lmemcpy_srcul1loop4 sub r2, r2, #0x0c push {r4, r5} @@ -192,10 +192,10 @@ ENTRY(memcpy) #endif stmia r0!, {r3-r5, r12} subs r2, r2, #0x10 - bge .Lmemcpy_srcul1loop16 + bhs .Lmemcpy_srcul1loop16 pop {r4, r5} adds r2, r2, #0x0c - blt .Lmemcpy_srcul1l4 + blo .Lmemcpy_srcul1l4 .Lmemcpy_srcul1loop4: #ifdef __ARMEB__ @@ -211,7 +211,7 @@ ENTRY(memcpy) #endif str r12, [r0], #4 subs r2, r2, #4 - bge .Lmemcpy_srcul1loop4 + bhs .Lmemcpy_srcul1loop4 .Lmemcpy_srcul1l4: sub r1, r1, #3 @@ -219,7 +219,7 @@ ENTRY(memcpy) .Lmemcpy_srcul2: cmp r2, #0x0c - blt .Lmemcpy_srcul2loop4 + blo .Lmemcpy_srcul2loop4 sub r2, r2, #0x0c push {r4, r5} @@ -249,10 +249,10 @@ ENTRY(m
CVS commit: src/common/lib/libc/arch/arm/string
Module Name:src Committed By: mlelstv Date: Thu Jan 19 18:03:03 UTC 2023 Modified Files: src/common/lib/libc/arch/arm/string: memcpy_arm.S memcpy_neon.S memcpy_xscale.S memmove.S memset.S memset_naive.S strlen_neon.S Log Message: Use unsigned comparisons for pointers and size_t values. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/common/lib/libc/arch/arm/string/memcpy_arm.S \ src/common/lib/libc/arch/arm/string/memcpy_xscale.S cvs rdiff -u -r1.1 -r1.2 src/common/lib/libc/arch/arm/string/memcpy_neon.S \ src/common/lib/libc/arch/arm/string/memset_naive.S cvs rdiff -u -r1.10 -r1.11 src/common/lib/libc/arch/arm/string/memmove.S cvs rdiff -u -r1.8 -r1.9 src/common/lib/libc/arch/arm/string/memset.S cvs rdiff -u -r1.3 -r1.4 src/common/lib/libc/arch/arm/string/strlen_neon.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/common/lib/libc/arch/arm/string
Module Name:src Committed By: mlelstv Date: Tue Jan 24 07:04:27 UTC 2023 Modified Files: src/common/lib/libc/arch/arm/string: memcpy_arm.S Log Message: Fix two signed comparisons that were missed in the last patch. Found be rillig@ To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/common/lib/libc/arch/arm/string/memcpy_arm.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/common/lib/libc/arch/arm/string
Module Name:src Committed By: mlelstv Date: Tue Jan 24 07:04:27 UTC 2023 Modified Files: src/common/lib/libc/arch/arm/string: memcpy_arm.S Log Message: Fix two signed comparisons that were missed in the last patch. Found be rillig@ To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/common/lib/libc/arch/arm/string/memcpy_arm.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/common/lib/libc/arch/arm/string/memcpy_arm.S diff -u src/common/lib/libc/arch/arm/string/memcpy_arm.S:1.6 src/common/lib/libc/arch/arm/string/memcpy_arm.S:1.7 --- src/common/lib/libc/arch/arm/string/memcpy_arm.S:1.6 Thu Jan 19 18:03:03 2023 +++ src/common/lib/libc/arch/arm/string/memcpy_arm.S Tue Jan 24 07:04:27 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: memcpy_arm.S,v 1.6 2023/01/19 18:03:03 mlelstv Exp $ */ +/* $NetBSD: memcpy_arm.S,v 1.7 2023/01/24 07:04:27 mlelstv Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -111,8 +111,8 @@ ENTRY(memcpy) blo .Lmemcpy_l4 subs r2, r2, #4 - ldrlt r3, [r1], #4 - strlt r3, [r0], #4 + ldrlo r3, [r1], #4 + strlo r3, [r0], #4 ldmiahs r1!, {r3, r12} stmiahs r0!, {r3, r12} subhs r2, r2, #4
CVS commit: src/common/lib/libc/arch/arm/string
Module Name:src Committed By: skrll Date: Sat Dec 3 11:30:24 UTC 2022 Modified Files: src/common/lib/libc/arch/arm/string: strlen_naive.S Log Message: improve a comment To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/common/lib/libc/arch/arm/string/strlen_naive.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/common/lib/libc/arch/arm/string
Module Name:src Committed By: skrll Date: Sat Dec 3 11:30:24 UTC 2022 Modified Files: src/common/lib/libc/arch/arm/string: strlen_naive.S Log Message: improve a comment To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/common/lib/libc/arch/arm/string/strlen_naive.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/common/lib/libc/arch/arm/string/strlen_naive.S diff -u src/common/lib/libc/arch/arm/string/strlen_naive.S:1.8 src/common/lib/libc/arch/arm/string/strlen_naive.S:1.9 --- src/common/lib/libc/arch/arm/string/strlen_naive.S:1.8 Mon Aug 19 17:02:25 2013 +++ src/common/lib/libc/arch/arm/string/strlen_naive.S Sat Dec 3 11:30:24 2022 @@ -28,7 +28,7 @@ */ #include -RCSID("$NetBSD: strlen_naive.S,v 1.8 2013/08/19 17:02:25 matt Exp $") +RCSID("$NetBSD: strlen_naive.S,v 1.9 2022/12/03 11:30:24 skrll Exp $") #ifdef STRNLEN /* LINTSTUB: size_t strnlen(const char *, size_t) */ @@ -40,7 +40,7 @@ ENTRY(strnlen) #else adds ip, r0, r1 /* &src[maxlen] */ #endif -1: cmp r0, ip /* is this of string? */ +1: cmp r0, ip /* is this the end of string? */ beq 2f /* yes it is */ #ifdef __thumb__ ldrb r2, [r0] /* read a byte */
CVS commit: src/common/lib/libc/arch/arm/string
Module Name:src Committed By: skrll Date: Sat Dec 3 11:34:38 UTC 2022 Modified Files: src/common/lib/libc/arch/arm/string: strlen_arm.S Log Message: Fix some comments To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/common/lib/libc/arch/arm/string/strlen_arm.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/common/lib/libc/arch/arm/string
Module Name:src Committed By: skrll Date: Sat Dec 3 11:34:38 UTC 2022 Modified Files: src/common/lib/libc/arch/arm/string: strlen_arm.S Log Message: Fix some comments To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/common/lib/libc/arch/arm/string/strlen_arm.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/common/lib/libc/arch/arm/string/strlen_arm.S diff -u src/common/lib/libc/arch/arm/string/strlen_arm.S:1.9 src/common/lib/libc/arch/arm/string/strlen_arm.S:1.10 --- src/common/lib/libc/arch/arm/string/strlen_arm.S:1.9 Tue May 6 16:02:11 2014 +++ src/common/lib/libc/arch/arm/string/strlen_arm.S Sat Dec 3 11:34:38 2022 @@ -29,7 +29,7 @@ #include -RCSID("$NetBSD: strlen_arm.S,v 1.9 2014/05/06 16:02:11 joerg Exp $") +RCSID("$NetBSD: strlen_arm.S,v 1.10 2022/12/03 11:34:38 skrll Exp $") #if defined(__thumb__) && !defined(_ARM_ARCH_T2) #error Only Thumb2 or ARM supported @@ -121,9 +121,9 @@ ENTRY(FUNCNAME) * (other tests for NULs in a word take more instructions/cycles). */ tst r3, #BYTE0 /* is this byte 0? */ - tstne r3, #BYTE1 /* no, is this byte 0? */ - tstne r3, #BYTE2 /* no, is this byte 0? */ - tstne r3, #BYTE3 /* no, is this byte 0? */ + tstne r3, #BYTE1 /* no, is this byte 1? */ + tstne r3, #BYTE2 /* no, is this byte 2? */ + tstne r3, #BYTE3 /* no, is this byte 3? */ bne .Lmain_loop /* no, then get next word */ #endif #if defined(_ARM_ARCH_6)
Re: CVS commit: src/common/lib/libc/arch/arm/string
On Tue, Jan 15, 2013 at 02:03:31AM +, Matt Thomas wrote: > Module Name: src > Committed By: matt > Date: Tue Jan 15 02:03:31 UTC 2013 > > Added Files: > src/common/lib/libc/arch/arm/string: strchr_naive.S strrchr_naive.S > > Log Message: > Add simple/small versions of strchr/strrchr for ARM. If you use 'preindex with writeback' you can remove an instruction from the loop (in strchr at least). I'm also intrigued that these are the very simple/small versions whereas the memcpy() (I think) was one that did all the alignment and double-word copies! David -- David Laight: da...@l8s.co.uk
Re: CVS commit: src/common/lib/libc/arch/arm/string
On Jan 15, 2013, at 12:10 AM, David Laight wrote: > On Tue, Jan 15, 2013 at 02:03:31AM +, Matt Thomas wrote: >> Module Name: src >> Committed By:matt >> Date:Tue Jan 15 02:03:31 UTC 2013 >> >> Added Files: >> src/common/lib/libc/arch/arm/string: strchr_naive.S strrchr_naive.S >> >> Log Message: >> Add simple/small versions of strchr/strrchr for ARM. > > If you use 'preindex with writeback' you can remove an instruction > from the loop (in strchr at least). I pretty much already do that. > I'm also intrigued that these are the very simple/small versions > whereas the memcpy() (I think) was one that did all the alignment > and double-word copies! As I said in its commit, the stupid version was very very slow.