Skip to content

Commit 3b59aa7

Browse files
committed
Handles block_op == BlockOp::kByWord explicitly
1 parent fcb2e5d commit 3b59aa7

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

libc/src/string/memory_utils/arm/common.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ namespace LIBC_NAMESPACE_DECL {
3535

3636
LIBC_INLINE_VAR constexpr size_t kWordSize = sizeof(uint32_t);
3737

38-
enum class BumpSize : bool { kNo = false, kYes = true };
39-
enum class BlockOp : bool { kFull = false, kByWord = true };
38+
enum class BumpSize { kNo, kYes };
39+
enum class BlockOp { kFull, kByWord };
4040

4141
LIBC_INLINE auto misaligned(CPtr ptr) {
4242
return distance_to_align_down<kWordSize>(ptr);

libc/src/string/memory_utils/arm/inline_memcpy.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ template <size_t bytes, BlockOp block_op = BlockOp::kFull>
3030
LIBC_INLINE void copy_block_and_bump_pointers(Ptr &dst, CPtr &src) {
3131
if constexpr (block_op == BlockOp::kFull) {
3232
copy_assume_aligned<bytes>(dst, src);
33-
} else {
33+
} else if constexpr (block_op == BlockOp::kByWord) {
3434
// We restrict loads/stores to 4 byte to prevent the use of load/store
3535
// multiple (LDM, STM) and load/store double (LDRD, STRD). First, they
3636
// may fault (see notes below) and second, they use more registers which
@@ -40,6 +40,8 @@ LIBC_INLINE void copy_block_and_bump_pointers(Ptr &dst, CPtr &src) {
4040
for (size_t offset = 0; offset < bytes; offset += kWordSize) {
4141
copy_assume_aligned<kWordSize>(dst + offset, src + offset);
4242
}
43+
} else {
44+
static_assert(false, "Invalid BlockOp");
4345
}
4446
// In the 1, 2, 4 byte copy case, the compiler can fold pointer offsetting
4547
// into the load/store instructions.

0 commit comments

Comments
 (0)