1 /* Copyright (c) 2010-2011, Linaro Limited
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions
8 * Redistributions of source code must retain the above copyright
9 notice, this list of conditions and the following disclaimer.
11 * Redistributions in binary form must reproduce the above copyright
12 notice, this list of conditions and the following disclaimer in the
13 documentation and/or other materials provided with the distribution.
15 * Neither the name of Linaro Limited nor the names of its
16 contributors may be used to endorse or promote products derived
17 from this software without specific prior written permission.
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 Written by Dave Gilbert <david.gilbert@linaro.org>
35 A very simple strchr routine, from benchmarks on A9 it's a bit faster than
36 the current version in eglibc (2.12.1-0ubuntu14 package)
37 I don't think doing a word at a time version is worth it since a lot
38 of strchr cases are very short anyway.
42 @ 2011-02-07 david.gilbert@linaro.org
43 @ Extracted from local git a5b438d861
51 @ ---------------------------------------------------------------------------
57 .type strchr,%function
59 @ r0 = start of string
60 @ r1 = character to match
61 @ returns NULL for no match, or a pointer to the match
70 @ We're here if it matched
76 @ We're here if we ran off the end
77 cmp r1, #0 @ Corner case - you're allowed to search for the nil and get a pointer to it
78 beq 5b @ A bit messy, if it's common we should branch at the start to a special loop