Files
fennec/include/fennec/memory/detail/__memory.h
Medusa Slockbower db7d52c86c - Fixed Documentation for Consistency
- Added more documentation, predominantly in the Math Library
2025-06-16 01:48:31 -04:00

53 lines
1.2 KiB
C++

//
// Created by medusa on 5/19/25.
//
#ifndef FENNEC_MEMORY_DETAIL_MEMORY_H
#define FENNEC_MEMORY_DETAIL_MEMORY_H
#include <fennec/lang/types.h>
namespace fennec
{
namespace detail
{
constexpr size_t __memcpy_8(void* dst, const void* src)
{ *static_cast<uint8_t*>(dst) = *static_cast<const uint8_t*>(src); return 1; }
// helper for copying 2 bytes at once
constexpr size_t __memcpy_16(void* dst, const void* src)
{ *static_cast<uint16_t*>(dst) = *static_cast<const uint16_t*>(src); return 2; }
// helper for copying 4 bytes at once
constexpr size_t __memcpy_32(void* dst, const void* src)
{ *static_cast<uint32_t*>(dst) = *static_cast<const uint32_t*>(src); return 4; }
// helper for copying 8 bytes at once
constexpr size_t __memcpy_64(void* dst, const void* src)
{ *static_cast<uint64_t*>(dst) = *static_cast<const uint64_t*>(src); return 8; }
constexpr size_t __memcpy(void* dst, const void* src, size_t n)
{
switch (n)
{
case 0:
return 0;
case 1:
return __memcpy_8(dst, src);
case 2: case 3:
return __memcpy_16(dst, src);
case 4: case 5: case 6: case 7:
return __memcpy_32(dst, src);
default:
return __memcpy_64(dst, src);
}
}
}
}
#endif // FENNEC_MEMORY_DETAIL_MEMORY_H