1 /* Optimized strpbrk implementation for PowerPC64.
2 Copyright (C) 2014-2016 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
21 /* char [r3] *strpbrk(const char [r4] *s, const char [r5] *accept) */
23 EALIGN (strpbrk, 4, 0)
27 cmpdi cr7,r10,0 /* accept[0] == '\0' ? */
30 /* The idea to speed up the algorithm is to create a lookup table
31 for fast check if input character should be considered. For ASCII
32 or ISO-8859-X character sets it has 256 positions. */
34 /* PPC64 ELF ABI stack is aligned to 16 bytes. */
36 /* Clear the table with 0 values */
54 /* Initialize the table as:
55 for (i=0; accept[i]; i++
56 table[accept[i]]] = 1 */
65 /* set table[0] = 1 */
70 /* Unrool the loop 4 times and check using the table as:
74 if (table[input[i++]] == 1)
75 return (s[i -1] ? s + i - 1: NULL);
76 if (table[input[i++]] == 1)
77 return (s[i -1] ? s + i - 1: NULL);
78 if (table[input[i++]] == 1)
79 return (s[i -1] ? s + i - 1: NULL);
80 if (table[input[i++]] == 1)
81 return (s[i -1] ? s + i - 1: NULL);
135 libc_hidden_builtin_def (strpbrk)