Skip to content

Commit e811702

Browse files
authored
[libc] Default to byte_per_byte instead of erroring (#131340)
Summary: Right now a lot of the memory functions error if we don't have specific handling for them. This is weird because we have a generic implementation that should just be used whenever someone hasn't written a more optimized version. This allows us to use the `libc` headers with more architectures from the `shared/` directory without worrying about it breaking.
1 parent 244cf89 commit e811702

File tree

5 files changed

+10
-20
lines changed

5 files changed

+10
-20
lines changed

libc/src/string/memory_utils/inline_bcmp.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,9 @@
2525
#elif defined(LIBC_TARGET_ARCH_IS_ANY_RISCV)
2626
#include "src/string/memory_utils/riscv/inline_bcmp.h"
2727
#define LIBC_SRC_STRING_MEMORY_UTILS_BCMP inline_bcmp_riscv
28-
#elif defined(LIBC_TARGET_ARCH_IS_ARM) || defined(LIBC_TARGET_ARCH_IS_GPU)
28+
#else
2929
#include "src/string/memory_utils/generic/byte_per_byte.h"
3030
#define LIBC_SRC_STRING_MEMORY_UTILS_BCMP inline_bcmp_byte_per_byte
31-
#else
32-
#error "Unsupported architecture"
3331
#endif
3432

3533
namespace LIBC_NAMESPACE_DECL {

libc/src/string/memory_utils/inline_memcmp.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,9 @@
2424
#elif defined(LIBC_TARGET_ARCH_IS_ANY_RISCV)
2525
#include "src/string/memory_utils/riscv/inline_memcmp.h"
2626
#define LIBC_SRC_STRING_MEMORY_UTILS_MEMCMP inline_memcmp_riscv
27-
#elif defined(LIBC_TARGET_ARCH_IS_ARM) || defined(LIBC_TARGET_ARCH_IS_GPU)
27+
#else
2828
#include "src/string/memory_utils/generic/byte_per_byte.h"
2929
#define LIBC_SRC_STRING_MEMORY_UTILS_MEMCMP inline_memcmp_byte_per_byte
30-
#else
31-
#error "Unsupported architecture"
3230
#endif
3331

3432
namespace LIBC_NAMESPACE_DECL {

libc/src/string/memory_utils/inline_memcpy.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,12 @@
2828
#elif defined(LIBC_TARGET_ARCH_IS_ANY_RISCV)
2929
#include "src/string/memory_utils/riscv/inline_memcpy.h"
3030
#define LIBC_SRC_STRING_MEMORY_UTILS_MEMCPY inline_memcpy_riscv
31-
#elif defined(LIBC_TARGET_ARCH_IS_ARM)
32-
#include "src/string/memory_utils/generic/byte_per_byte.h"
33-
#define LIBC_SRC_STRING_MEMORY_UTILS_MEMCPY inline_memcpy_byte_per_byte
3431
#elif defined(LIBC_TARGET_ARCH_IS_GPU)
3532
#include "src/string/memory_utils/generic/builtin.h"
3633
#define LIBC_SRC_STRING_MEMORY_UTILS_MEMCPY inline_memcpy_builtin
3734
#else
38-
#error "Unsupported architecture"
35+
#include "src/string/memory_utils/generic/byte_per_byte.h"
36+
#define LIBC_SRC_STRING_MEMORY_UTILS_MEMCPY inline_memcpy_byte_per_byte
3937
#endif
4038

4139
namespace LIBC_NAMESPACE_DECL {

libc/src/string/memory_utils/inline_memmove.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
#include "src/__support/macros/attributes.h" // LIBC_INLINE
1313
#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL
14-
#include <stddef.h> // size_t, ptrdiff_t
14+
#include <stddef.h> // size_t, ptrdiff_t
1515

1616
#if defined(LIBC_TARGET_ARCH_IS_X86)
1717
#include "src/string/memory_utils/x86_64/inline_memmove.h"
@@ -29,10 +29,6 @@
2929
#define LIBC_SRC_STRING_MEMORY_UTILS_MEMMOVE_SMALL_SIZE \
3030
inline_memmove_no_small_size
3131
#define LIBC_SRC_STRING_MEMORY_UTILS_MEMMOVE_FOLLOW_UP inline_memmove_riscv
32-
#elif defined(LIBC_TARGET_ARCH_IS_ARM)
33-
#include "src/string/memory_utils/generic/byte_per_byte.h"
34-
#define LIBC_SRC_STRING_MEMORY_UTILS_MEMMOVE_SMALL_SIZE \
35-
inline_memmove_no_small_size
3632
#define LIBC_SRC_STRING_MEMORY_UTILS_MEMMOVE_FOLLOW_UP \
3733
inline_memmove_byte_per_byte
3834
#elif defined(LIBC_TARGET_ARCH_IS_GPU)
@@ -41,7 +37,9 @@
4137
inline_memmove_no_small_size
4238
#define LIBC_SRC_STRING_MEMORY_UTILS_MEMMOVE_FOLLOW_UP inline_memmove_builtin
4339
#else
44-
#error "Unsupported architecture"
40+
#include "src/string/memory_utils/generic/byte_per_byte.h"
41+
#define LIBC_SRC_STRING_MEMORY_UTILS_MEMMOVE_SMALL_SIZE \
42+
inline_memmove_no_small_size
4543
#endif
4644

4745
namespace LIBC_NAMESPACE_DECL {

libc/src/string/memory_utils/inline_memset.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,12 @@
2424
#elif defined(LIBC_TARGET_ARCH_IS_ANY_RISCV)
2525
#include "src/string/memory_utils/riscv/inline_memset.h"
2626
#define LIBC_SRC_STRING_MEMORY_UTILS_MEMSET inline_memset_riscv
27-
#elif defined(LIBC_TARGET_ARCH_IS_ARM)
28-
#include "src/string/memory_utils/generic/byte_per_byte.h"
29-
#define LIBC_SRC_STRING_MEMORY_UTILS_MEMSET inline_memset_byte_per_byte
3027
#elif defined(LIBC_TARGET_ARCH_IS_GPU)
3128
#include "src/string/memory_utils/generic/builtin.h"
3229
#define LIBC_SRC_STRING_MEMORY_UTILS_MEMSET inline_memset_builtin
3330
#else
34-
#error "Unsupported architecture"
31+
#include "src/string/memory_utils/generic/byte_per_byte.h"
32+
#define LIBC_SRC_STRING_MEMORY_UTILS_MEMSET inline_memset_byte_per_byte
3533
#endif
3634

3735
namespace LIBC_NAMESPACE_DECL {

0 commit comments

Comments
 (0)