Skip to content

Commit

Permalink
chore: Fix memcpy
Browse files Browse the repository at this point in the history
  • Loading branch information
cwahn committed Feb 19, 2024
1 parent 304e508 commit 9c32bbb
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions include/efp/cpp_core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,28 @@

#if defined(__STDC_HOSTED__) && __STDC_HOSTED__ == 1

#include <cstring>
#include <cstring>

namespace efp {
// Use a function alias for clarity and avoid direct assignment to avoid potential confusion.
inline void* _memcpy(void* dest, const void* src, size_t size) {
return std::memcpy(dest, src, size);
// Use a function alias for clarity and avoid direct assignment to avoid potential confusion.
inline void* _memcpy(void* dest, const void* src, size_t size) {
return std::memcpy(dest, src, size);
}
}
} // namespace efp

#else

namespace efp {
// Custom memcpy implementation for freestanding environments.
// Added extern "C" to ensure C linkage for compatibility with C libraries or code.
extern "C" void* _memcpy(void* dest, const void* src, size_t size) {
auto* d = static_cast<char*>(dest);
const auto* s = static_cast<const char*>(src);
for (size_t i = 0; i < size; ++i) {
d[i] = s[i];
// Custom memcpy implementation for freestanding environments.
// Added extern "C" to ensure C linkage for compatibility with C libraries or code.
extern "C" void* _memcpy(void* dest, const void* src, size_t size) {
auto* d = static_cast<char*>(dest);
const auto* s = static_cast<const char*>(src);
for (size_t i = 0; i < size; ++i) {
d[i] = s[i];
}
return dest;
}
return dest;
}
} // namespace efp

#endif
Expand Down

0 comments on commit 9c32bbb

Please sign in to comment.