Skip to content

[libc] Switched calls to inline_memcpy to __builtin_memcpy for wide char utilities #143011

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions libc/src/wchar/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ add_entrypoint_object(
DEPENDS
libc.hdr.types.size_t
libc.hdr.types.wchar_t
libc.src.__support.wctype_utils
)

add_entrypoint_object(
Expand All @@ -54,7 +53,6 @@ add_entrypoint_object(
wcschr.h
DEPENDS
libc.hdr.wchar_macros
libc.src.__support.wctype_utils
)

add_entrypoint_object(
Expand All @@ -75,7 +73,6 @@ add_entrypoint_object(
wcspbrk.h
DEPENDS
libc.hdr.wchar_macros
libc.src.__support.wctype_utils
libc.src.__support.macros.null_check
)

Expand Down Expand Up @@ -109,7 +106,6 @@ add_entrypoint_object(
DEPENDS
libc.hdr.wchar_macros
libc.hdr.types.size_t
libc.src.__support.wctype_utils
)

add_entrypoint_object(
Expand All @@ -121,7 +117,6 @@ add_entrypoint_object(
DEPENDS
libc.hdr.types.size_t
libc.hdr.wchar_macros
libc.src.__support.wctype_utils
libc.src.__support.macros.null_check
)

Expand All @@ -134,7 +129,6 @@ add_entrypoint_object(
DEPENDS
libc.hdr.types.size_t
libc.hdr.wchar_macros
libc.src.__support.wctype_utils
)

add_entrypoint_object(
Expand Down Expand Up @@ -205,8 +199,6 @@ add_entrypoint_object(
DEPENDS
libc.hdr.types.size_t
libc.hdr.wchar_macros
libc.src.__support.wctype_utils
libc.src.string.memory_utils.inline_memcpy
)

add_entrypoint_object(
Expand All @@ -218,6 +210,5 @@ add_entrypoint_object(
DEPENDS
libc.hdr.types.size_t
libc.hdr.wchar_macros
libc.src.string.memory_utils.inline_memcpy
libc.src.string.string_utils
)
3 changes: 1 addition & 2 deletions libc/src/wchar/wcscpy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@
#include "hdr/types/wchar_t.h"
#include "src/__support/common.h"
#include "src/__support/macros/config.h"
#include "src/string/memory_utils/inline_memcpy.h"
#include "src/string/string_utils.h"

namespace LIBC_NAMESPACE_DECL {

LLVM_LIBC_FUNCTION(wchar_t *, wcscpy,
(wchar_t *__restrict s1, const wchar_t *__restrict s2)) {
size_t size = internal::string_length(s2) + 1;
inline_memcpy(s1, s2, size * sizeof(wchar_t));
__builtin_memcpy(s1, s2, size * sizeof(wchar_t));
return s1;
}

Expand Down
2 changes: 0 additions & 2 deletions libc/src/wchar/wcsncpy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
#include "hdr/types/wchar_t.h"
#include "src/__support/common.h"
#include "src/__support/macros/config.h"
#include "src/string/memory_utils/inline_memcpy.h"
#include "src/string/string_utils.h"

namespace LIBC_NAMESPACE_DECL {

Expand Down
3 changes: 1 addition & 2 deletions libc/src/wchar/wmemcpy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@
#include "hdr/types/wchar_t.h"
#include "src/__support/common.h"
#include "src/__support/macros/config.h"
#include "src/string/memory_utils/inline_memcpy.h"

namespace LIBC_NAMESPACE_DECL {

LLVM_LIBC_FUNCTION(wchar_t *, wmemcpy,
(wchar_t *__restrict s1, const wchar_t *__restrict s2,
size_t n)) {
inline_memcpy(s1, s2, n * sizeof(wchar_t));
__builtin_memcpy(s1, s2, n * sizeof(wchar_t));
return s1;
}

Expand Down
3 changes: 1 addition & 2 deletions libc/src/wchar/wmempcpy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@
#include "hdr/types/size_t.h"
#include "hdr/types/wchar_t.h"
#include "src/__support/common.h"
#include "src/string/memory_utils/inline_memcpy.h"

namespace LIBC_NAMESPACE_DECL {

LLVM_LIBC_FUNCTION(wchar_t *, wmempcpy,
(wchar_t *__restrict to, const wchar_t *__restrict from,
size_t size)) {
inline_memcpy(to, from, size * sizeof(wchar_t));
__builtin_memcpy(to, from, size * sizeof(wchar_t));
return reinterpret_cast<wchar_t *>(to) + size;
}

Expand Down
Loading