mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:37:36 +00:00
Kernel: Fix memset() on x86_64
Previously memset() only set half of the bytes to the requested value.
This commit is contained in:
parent
cdcb75709a
commit
e56a0d6af7
2 changed files with 18 additions and 8 deletions
14
AK/Types.h
14
AK/Types.h
|
@ -65,14 +65,24 @@ namespace std {
|
|||
using nullptr_t = decltype(nullptr);
|
||||
}
|
||||
|
||||
static constexpr u32 explode_byte(u8 b)
|
||||
static constexpr FlatPtr explode_byte(u8 b)
|
||||
{
|
||||
return b << 24 | b << 16 | b << 8 | b;
|
||||
#if ARCH(I386)
|
||||
return (u32)b << 24 | (u32)b << 16 | (u32)b << 8 | (u32)b;
|
||||
#else
|
||||
return (u64)b << 56 | (u64)b << 48 | (u64)b << 40 | (u64)b << 32 | (u64)b << 24 | (u64)b << 16 | (u64)b << 8 | (u64)b;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if ARCH(I386)
|
||||
static_assert(explode_byte(0xff) == 0xffffffff);
|
||||
static_assert(explode_byte(0x80) == 0x80808080);
|
||||
static_assert(explode_byte(0x7f) == 0x7f7f7f7f);
|
||||
#else
|
||||
static_assert(explode_byte(0xff) == 0xffffffffffffffff);
|
||||
static_assert(explode_byte(0x80) == 0x8080808080808080);
|
||||
static_assert(explode_byte(0x7f) == 0x7f7f7f7f7f7f7f7f);
|
||||
#endif
|
||||
static_assert(explode_byte(0) == 0);
|
||||
|
||||
constexpr size_t align_up_to(const size_t value, const size_t alignment)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue