diff options
| author | Siva Chandra Reddy <sivachandra@google.com> | 2023-01-23 18:18:08 +0000 |
|---|---|---|
| committer | Siva Chandra Reddy <sivachandra@google.com> | 2023-01-24 00:37:09 +0000 |
| commit | 6363320ba6beeb7a014163aeb5a53b3ad362d844 (patch) | |
| tree | 730ca6f7af69b3a12d483a2ab962fd21d515c8d9 /libc/src/string/string_utils.h | |
| parent | 2b0322ed566dfb6b111fdb46b2e2631c39716dac (diff) | |
[libc][NFC] Another round of replacement of static inline with LIBC_INLINE.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D142398
Diffstat (limited to 'libc/src/string/string_utils.h')
| -rw-r--r-- | libc/src/string/string_utils.h | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/libc/src/string/string_utils.h b/libc/src/string/string_utils.h index 24be2ab889b5..c6f0acb6949f 100644 --- a/libc/src/string/string_utils.h +++ b/libc/src/string/string_utils.h @@ -58,7 +58,7 @@ template <typename Word> constexpr bool has_zeroes(Word block) { } template <typename Word> -static inline size_t string_length_wide_read(const char *src) { +LIBC_INLINE size_t string_length_wide_read(const char *src) { const char *char_ptr = src; // Step 1: read 1 byte at a time to align to block size for (; reinterpret_cast<uintptr_t>(char_ptr) % sizeof(Word) != 0; @@ -78,7 +78,7 @@ static inline size_t string_length_wide_read(const char *src) { return char_ptr - src; } -static inline size_t string_length_byte_read(const char *src) { +LIBC_INLINE size_t string_length_byte_read(const char *src) { size_t length; for (length = 0; *src; ++src, ++length) ; @@ -87,7 +87,7 @@ static inline size_t string_length_byte_read(const char *src) { // Returns the length of a string, denoted by the first occurrence // of a null terminator. -static inline size_t string_length(const char *src) { +LIBC_INLINE size_t string_length(const char *src) { #ifdef LIBC_UNSAFE_STRING_WIDE_READ // Unsigned int is the default size for most processors, and on x86-64 it // performs better than larger sizes when the src pointer can't be assumed to @@ -100,8 +100,8 @@ static inline size_t string_length(const char *src) { } template <typename Word> -static inline void *find_first_character_wide_read(const unsigned char *src, - unsigned char ch, size_t n) { +LIBC_INLINE void *find_first_character_wide_read(const unsigned char *src, + unsigned char ch, size_t n) { const unsigned char *char_ptr = src; size_t cur = 0; @@ -132,8 +132,8 @@ static inline void *find_first_character_wide_read(const unsigned char *src, return const_cast<unsigned char *>(char_ptr); } -static inline void *find_first_character_byte_read(const unsigned char *src, - unsigned char ch, size_t n) { +LIBC_INLINE void *find_first_character_byte_read(const unsigned char *src, + unsigned char ch, size_t n) { for (; n && *src != ch; --n, ++src) ; return n ? const_cast<unsigned char *>(src) : nullptr; @@ -141,8 +141,8 @@ static inline void *find_first_character_byte_read(const unsigned char *src, // Returns the first occurrence of 'ch' within the first 'n' characters of // 'src'. If 'ch' is not found, returns nullptr. -static inline void *find_first_character(const unsigned char *src, - unsigned char ch, size_t max_strlen) { +LIBC_INLINE void *find_first_character(const unsigned char *src, + unsigned char ch, size_t max_strlen) { #ifdef LIBC_UNSAFE_STRING_WIDE_READ // If the maximum size of the string is small, the overhead of aligning to a // word boundary and generating a bitmask of the appropriate size may be @@ -161,7 +161,7 @@ static inline void *find_first_character(const unsigned char *src, // Returns the maximum length span that contains only characters not found in // 'segment'. If no characters are found, returns the length of 'src'. -static inline size_t complementary_span(const char *src, const char *segment) { +LIBC_INLINE size_t complementary_span(const char *src, const char *segment) { const char *initial = src; cpp::bitset<256> bitset; @@ -181,9 +181,9 @@ static inline size_t complementary_span(const char *src, const char *segment) { // is found is then stored within 'context' for subsequent calls. Subsequent // calls will use 'context' when a nullptr is passed in for 'src'. Once the null // terminating character is reached, returns a nullptr. -static inline char *string_token(char *__restrict src, - const char *__restrict delimiter_string, - char **__restrict saveptr) { +LIBC_INLINE char *string_token(char *__restrict src, + const char *__restrict delimiter_string, + char **__restrict saveptr) { // Return nullptr immediately if both src AND saveptr are nullptr if (unlikely(src == nullptr && ((src = *saveptr) == nullptr))) return nullptr; @@ -210,8 +210,8 @@ static inline char *string_token(char *__restrict src, return token; } -static inline size_t strlcpy(char *__restrict dst, const char *__restrict src, - size_t size) { +LIBC_INLINE size_t strlcpy(char *__restrict dst, const char *__restrict src, + size_t size) { size_t len = internal::string_length(src); if (!size) return len; |
