| /* SPDX-License-Identifier: GPL-2.0 */ |
| * Taken from Linux arch/riscv/lib/strlen.S |
| #include <linux/linkage.h> |
| #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ |
| /* Number of irrelevant bytes in the first word. */ |
| /* Get the first word. */ |
| * Shift away the partial data we loaded to remove the irrelevant bytes |
| * preceding the string with the effect of adding NUL bytes at the |
| * end of the string's first word. |
| /* Convert non-NUL into 0xff and NUL into 0x00. */ |
| /* Convert non-NUL into 0x00 and NUL into 0xff. */ |
| * Search for the first set bit (corresponding to a NUL byte in the |
| * The first chunk is special: compare against the number |
| * of valid bytes in this chunk. |
| /* Prepare for the word comparison loop. */ |
| * Our critical loop is 4 instructions and processes data in |
| * 4 byte or 8 byte chunks. |
| /* Get number of processed bytes. */ |
| /* Add number of characters in the first word. */ |
| /* Add number of characters in the last word. */ |