|
14 | 14 | #ifndef LLVM_LIBC_SRC_STRING_STRING_UTILS_H
|
15 | 15 | #define LLVM_LIBC_SRC_STRING_STRING_UTILS_H
|
16 | 16 |
|
| 17 | +#include "hdr/limits_macros.h" |
17 | 18 | #include "hdr/types/size_t.h"
|
18 | 19 | #include "src/__support/CPP/bitset.h"
|
19 | 20 | #include "src/__support/CPP/type_traits.h" // cpp::is_same_v
|
20 | 21 | #include "src/__support/macros/config.h"
|
21 | 22 | #include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
|
22 |
| -#include "src/string/memory_utils/inline_bzero.h" |
23 |
| -#include "src/string/memory_utils/inline_memcpy.h" |
24 | 23 |
|
25 | 24 | namespace LIBC_NAMESPACE_DECL {
|
26 | 25 | namespace internal {
|
27 | 26 |
|
28 | 27 | template <typename Word> LIBC_INLINE constexpr Word repeat_byte(Word byte) {
|
29 |
| - constexpr size_t BITS_IN_BYTE = 8; |
| 28 | + static_assert(CHAR_BIT == 8, "repeat_byte assumes a byte is 8 bits."); |
| 29 | + constexpr size_t BITS_IN_BYTE = CHAR_BIT; |
30 | 30 | constexpr size_t BYTE_MASK = 0xff;
|
31 | 31 | Word result = 0;
|
32 | 32 | byte = byte & BYTE_MASK;
|
@@ -189,8 +189,7 @@ LIBC_INLINE char *string_token(char *__restrict src,
|
189 | 189 | if (LIBC_UNLIKELY(src == nullptr && ((src = *saveptr) == nullptr)))
|
190 | 190 | return nullptr;
|
191 | 191 |
|
192 |
| - static_assert(sizeof(char) == sizeof(cpp::byte), |
193 |
| - "bitset of 256 assumes char is 8 bits"); |
| 192 | + static_assert(CHAR_BIT == 8, "bitset of 256 assumes char is 8 bits"); |
194 | 193 | cpp::bitset<256> delimiter_set;
|
195 | 194 | for (; *delimiter_string != '\0'; ++delimiter_string)
|
196 | 195 | delimiter_set.set(static_cast<size_t>(*delimiter_string));
|
@@ -220,7 +219,7 @@ LIBC_INLINE size_t strlcpy(char *__restrict dst, const char *__restrict src,
|
220 | 219 | if (!size)
|
221 | 220 | return len;
|
222 | 221 | size_t n = len < size - 1 ? len : size - 1;
|
223 |
| - inline_memcpy(dst, src, n); |
| 222 | + __builtin_memcpy(dst, src, n); |
224 | 223 | dst[n] = '\0';
|
225 | 224 | return len;
|
226 | 225 | }
|
|
0 commit comments