mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 10:27:35 +00:00
AK: Rename the common integer typedefs to make it obvious what they are.
These types can be picked up by including <AK/Types.h>: * u8, u16, u32, u64 (unsigned) * i8, i16, i32, i64 (signed)
This commit is contained in:
parent
c4c4bbc5ba
commit
27f699ef0c
208 changed files with 1603 additions and 1621 deletions
18
AK/Bitmap.h
18
AK/Bitmap.h
|
@ -10,7 +10,7 @@ namespace AK {
|
|||
class Bitmap {
|
||||
public:
|
||||
// NOTE: A wrapping Bitmap won't try to free the wrapped data.
|
||||
static Bitmap wrap(byte* data, int size)
|
||||
static Bitmap wrap(u8* data, int size)
|
||||
{
|
||||
return Bitmap(data, size);
|
||||
}
|
||||
|
@ -42,13 +42,13 @@ public:
|
|||
{
|
||||
ASSERT(index < m_size);
|
||||
if (value)
|
||||
m_data[index / 8] |= static_cast<byte>((1u << (index % 8)));
|
||||
m_data[index / 8] |= static_cast<u8>((1u << (index % 8)));
|
||||
else
|
||||
m_data[index / 8] &= static_cast<byte>(~(1u << (index % 8)));
|
||||
m_data[index / 8] &= static_cast<u8>(~(1u << (index % 8)));
|
||||
}
|
||||
|
||||
byte* data() { return m_data; }
|
||||
const byte* data() const { return m_data; }
|
||||
u8* data() { return m_data; }
|
||||
const u8* data() const { return m_data; }
|
||||
|
||||
void grow(int size, bool default_value)
|
||||
{
|
||||
|
@ -59,7 +59,7 @@ public:
|
|||
auto previous_data = m_data;
|
||||
|
||||
m_size = size;
|
||||
m_data = reinterpret_cast<byte*>(kmalloc(size_in_bytes()));
|
||||
m_data = reinterpret_cast<u8*>(kmalloc(size_in_bytes()));
|
||||
|
||||
fill(default_value);
|
||||
|
||||
|
@ -123,11 +123,11 @@ private:
|
|||
, m_owned(true)
|
||||
{
|
||||
ASSERT(m_size != 0);
|
||||
m_data = reinterpret_cast<byte*>(kmalloc(size_in_bytes()));
|
||||
m_data = reinterpret_cast<u8*>(kmalloc(size_in_bytes()));
|
||||
fill(default_value);
|
||||
}
|
||||
|
||||
Bitmap(byte* data, int size)
|
||||
Bitmap(u8* data, int size)
|
||||
: m_data(data)
|
||||
, m_size(size)
|
||||
, m_owned(false)
|
||||
|
@ -136,7 +136,7 @@ private:
|
|||
|
||||
int size_in_bytes() const { return ceil_div(m_size, 8); }
|
||||
|
||||
byte* m_data { nullptr };
|
||||
u8* m_data { nullptr };
|
||||
int m_size { 0 };
|
||||
bool m_owned { false };
|
||||
};
|
||||
|
|
|
@ -12,28 +12,28 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
void operator<<(byte value)
|
||||
void operator<<(u8 value)
|
||||
{
|
||||
m_buffer[m_offset++] = value & 0xffu;
|
||||
}
|
||||
|
||||
void operator<<(char value)
|
||||
{
|
||||
m_buffer[m_offset++] = (byte)value;
|
||||
m_buffer[m_offset++] = (u8)value;
|
||||
}
|
||||
|
||||
void operator<<(word value)
|
||||
void operator<<(u16 value)
|
||||
{
|
||||
m_buffer[m_offset++] = value & 0xffu;
|
||||
m_buffer[m_offset++] = (byte)(value >> 8) & 0xffu;
|
||||
m_buffer[m_offset++] = (u8)(value >> 8) & 0xffu;
|
||||
}
|
||||
|
||||
void operator<<(dword value)
|
||||
void operator<<(u32 value)
|
||||
{
|
||||
m_buffer[m_offset++] = value & 0xffu;
|
||||
m_buffer[m_offset++] = (byte)(value >> 8) & 0xffu;
|
||||
m_buffer[m_offset++] = (byte)(value >> 16) & 0xffu;
|
||||
m_buffer[m_offset++] = (byte)(value >> 24) & 0xffu;
|
||||
m_buffer[m_offset++] = (u8)(value >> 8) & 0xffu;
|
||||
m_buffer[m_offset++] = (u8)(value >> 16) & 0xffu;
|
||||
m_buffer[m_offset++] = (u8)(value >> 24) & 0xffu;
|
||||
}
|
||||
|
||||
void operator<<(const StringView& value)
|
||||
|
@ -53,7 +53,7 @@ public:
|
|||
return m_offset == m_buffer.size();
|
||||
}
|
||||
|
||||
void fill_to_end(byte ch)
|
||||
void fill_to_end(u8 ch)
|
||||
{
|
||||
while (!at_end())
|
||||
m_buffer[m_offset++] = ch;
|
||||
|
|
|
@ -28,12 +28,12 @@ public:
|
|||
m_data = nullptr;
|
||||
}
|
||||
|
||||
byte& operator[](int i)
|
||||
u8& operator[](int i)
|
||||
{
|
||||
ASSERT(i < m_size);
|
||||
return m_data[i];
|
||||
}
|
||||
const byte& operator[](int i) const
|
||||
const u8& operator[](int i) const
|
||||
{
|
||||
ASSERT(i < m_size);
|
||||
return m_data[i];
|
||||
|
@ -41,11 +41,11 @@ public:
|
|||
bool is_empty() const { return !m_size; }
|
||||
int size() const { return m_size; }
|
||||
|
||||
byte* pointer() { return m_data; }
|
||||
const byte* pointer() const { return m_data; }
|
||||
u8* pointer() { return m_data; }
|
||||
const u8* pointer() const { return m_data; }
|
||||
|
||||
byte* offset_pointer(int offset) { return m_data + offset; }
|
||||
const byte* offset_pointer(int offset) const { return m_data + offset; }
|
||||
u8* offset_pointer(int offset) { return m_data + offset; }
|
||||
const u8* offset_pointer(int offset) const { return m_data + offset; }
|
||||
|
||||
void* end_pointer() { return m_data + m_size; }
|
||||
const void* end_pointer() const { return m_data + m_size; }
|
||||
|
@ -71,7 +71,7 @@ private:
|
|||
ByteBufferImpl(void*, int, ConstructionMode); // For ConstructionMode=Wrap/Adopt
|
||||
ByteBufferImpl() {}
|
||||
|
||||
byte* m_data { nullptr };
|
||||
u8* m_data { nullptr };
|
||||
int m_size { 0 };
|
||||
bool m_owned { false };
|
||||
};
|
||||
|
@ -114,12 +114,12 @@ public:
|
|||
bool operator!() const { return is_null(); }
|
||||
bool is_null() const { return m_impl == nullptr; }
|
||||
|
||||
byte& operator[](int i)
|
||||
u8& operator[](int i)
|
||||
{
|
||||
ASSERT(m_impl);
|
||||
return (*m_impl)[i];
|
||||
}
|
||||
byte operator[](int i) const
|
||||
u8 operator[](int i) const
|
||||
{
|
||||
ASSERT(m_impl);
|
||||
return (*m_impl)[i];
|
||||
|
@ -127,14 +127,14 @@ public:
|
|||
bool is_empty() const { return !m_impl || m_impl->is_empty(); }
|
||||
int size() const { return m_impl ? m_impl->size() : 0; }
|
||||
|
||||
byte* data() { return pointer(); }
|
||||
const byte* data() const { return pointer(); }
|
||||
u8* data() { return pointer(); }
|
||||
const u8* data() const { return pointer(); }
|
||||
|
||||
byte* pointer() { return m_impl ? m_impl->pointer() : nullptr; }
|
||||
const byte* pointer() const { return m_impl ? m_impl->pointer() : nullptr; }
|
||||
u8* pointer() { return m_impl ? m_impl->pointer() : nullptr; }
|
||||
const u8* pointer() const { return m_impl ? m_impl->pointer() : nullptr; }
|
||||
|
||||
byte* offset_pointer(int offset) { return m_impl ? m_impl->offset_pointer(offset) : nullptr; }
|
||||
const byte* offset_pointer(int offset) const { return m_impl ? m_impl->offset_pointer(offset) : nullptr; }
|
||||
u8* offset_pointer(int offset) { return m_impl ? m_impl->offset_pointer(offset) : nullptr; }
|
||||
const u8* offset_pointer(int offset) const { return m_impl ? m_impl->offset_pointer(offset) : nullptr; }
|
||||
|
||||
void* end_pointer() { return m_impl ? m_impl->end_pointer() : nullptr; }
|
||||
const void* end_pointer() const { return m_impl ? m_impl->end_pointer() : nullptr; }
|
||||
|
@ -191,7 +191,7 @@ private:
|
|||
inline ByteBufferImpl::ByteBufferImpl(int size)
|
||||
: m_size(size)
|
||||
{
|
||||
m_data = static_cast<byte*>(kmalloc(size));
|
||||
m_data = static_cast<u8*>(kmalloc(size));
|
||||
m_owned = true;
|
||||
}
|
||||
|
||||
|
@ -199,13 +199,13 @@ inline ByteBufferImpl::ByteBufferImpl(const void* data, int size, ConstructionMo
|
|||
: m_size(size)
|
||||
{
|
||||
ASSERT(mode == Copy);
|
||||
m_data = static_cast<byte*>(kmalloc(size));
|
||||
m_data = static_cast<u8*>(kmalloc(size));
|
||||
memcpy(m_data, data, size);
|
||||
m_owned = true;
|
||||
}
|
||||
|
||||
inline ByteBufferImpl::ByteBufferImpl(void* data, int size, ConstructionMode mode)
|
||||
: m_data(static_cast<byte*>(data))
|
||||
: m_data(static_cast<u8*>(data))
|
||||
, m_size(size)
|
||||
{
|
||||
if (mode == Adopt) {
|
||||
|
@ -219,9 +219,9 @@ inline void ByteBufferImpl::grow(int size)
|
|||
{
|
||||
ASSERT(size > m_size);
|
||||
ASSERT(m_owned);
|
||||
byte* new_data = static_cast<byte*>(kmalloc(size));
|
||||
u8* new_data = static_cast<u8*>(kmalloc(size));
|
||||
memcpy(new_data, m_data, m_size);
|
||||
byte* old_data = m_data;
|
||||
u8* old_data = m_data;
|
||||
m_data = new_data;
|
||||
m_size = size;
|
||||
kfree(old_data);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "ELFImage.h"
|
||||
#include <AK/kstdio.h>
|
||||
|
||||
ELFImage::ELFImage(const byte* buffer)
|
||||
ELFImage::ELFImage(const u8* buffer)
|
||||
: m_buffer(buffer)
|
||||
{
|
||||
m_valid = parse();
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
class ELFImage {
|
||||
public:
|
||||
explicit ELFImage(const byte*);
|
||||
explicit ELFImage(const u8*);
|
||||
~ELFImage();
|
||||
void dump();
|
||||
bool is_valid() const { return m_valid; }
|
||||
|
@ -54,13 +54,13 @@ public:
|
|||
~ProgramHeader() {}
|
||||
|
||||
unsigned index() const { return m_program_header_index; }
|
||||
dword type() const { return m_program_header.p_type; }
|
||||
dword flags() const { return m_program_header.p_flags; }
|
||||
dword offset() const { return m_program_header.p_offset; }
|
||||
u32 type() const { return m_program_header.p_type; }
|
||||
u32 flags() const { return m_program_header.p_flags; }
|
||||
u32 offset() const { return m_program_header.p_offset; }
|
||||
VirtualAddress vaddr() const { return VirtualAddress(m_program_header.p_vaddr); }
|
||||
dword size_in_memory() const { return m_program_header.p_memsz; }
|
||||
dword size_in_image() const { return m_program_header.p_filesz; }
|
||||
dword alignment() const { return m_program_header.p_align; }
|
||||
u32 size_in_memory() const { return m_program_header.p_memsz; }
|
||||
u32 size_in_image() const { return m_program_header.p_filesz; }
|
||||
u32 alignment() const { return m_program_header.p_align; }
|
||||
bool is_readable() const { return flags() & PF_R; }
|
||||
bool is_writable() const { return flags() & PF_W; }
|
||||
bool is_executable() const { return flags() & PF_X; }
|
||||
|
@ -88,10 +88,10 @@ public:
|
|||
unsigned size() const { return m_section_header.sh_size; }
|
||||
unsigned entry_size() const { return m_section_header.sh_entsize; }
|
||||
unsigned entry_count() const { return !entry_size() ? 0 : size() / entry_size(); }
|
||||
dword address() const { return m_section_header.sh_addr; }
|
||||
u32 address() const { return m_section_header.sh_addr; }
|
||||
const char* raw_data() const { return m_image.raw_data(m_section_header.sh_offset); }
|
||||
bool is_undefined() const { return m_section_index == SHN_UNDEF; }
|
||||
dword flags() const { return m_section_header.sh_flags; }
|
||||
u32 flags() const { return m_section_header.sh_flags; }
|
||||
bool is_writable() const { return flags() & SHF_WRITE; }
|
||||
bool is_executable() const { return flags() & PF_X; }
|
||||
|
||||
|
@ -134,7 +134,7 @@ private:
|
|||
const char* section_header_table_string(unsigned offset) const;
|
||||
const char* section_index_to_string(unsigned index);
|
||||
|
||||
const byte* m_buffer { nullptr };
|
||||
const u8* m_buffer { nullptr };
|
||||
bool m_valid { false };
|
||||
unsigned m_symbol_table_section_index { 0 };
|
||||
unsigned m_string_table_section_index { 0 };
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
//#define ELFLOADER_DEBUG
|
||||
|
||||
ELFLoader::ELFLoader(const byte* buffer)
|
||||
ELFLoader::ELFLoader(const u8* buffer)
|
||||
: m_image(buffer)
|
||||
{
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ char* ELFLoader::symbol_ptr(const char* name)
|
|||
return found_ptr;
|
||||
}
|
||||
|
||||
String ELFLoader::symbolicate(dword address) const
|
||||
String ELFLoader::symbolicate(u32 address) const
|
||||
{
|
||||
SortedSymbol* sorted_symbols = nullptr;
|
||||
#ifdef KERNEL
|
||||
|
|
|
@ -13,7 +13,7 @@ class Region;
|
|||
|
||||
class ELFLoader {
|
||||
public:
|
||||
explicit ELFLoader(const byte*);
|
||||
explicit ELFLoader(const u8*);
|
||||
~ELFLoader();
|
||||
|
||||
bool load();
|
||||
|
@ -26,7 +26,7 @@ public:
|
|||
|
||||
bool has_symbols() const { return m_image.symbol_count(); }
|
||||
|
||||
String symbolicate(dword address) const;
|
||||
String symbolicate(u32 address) const;
|
||||
|
||||
private:
|
||||
bool layout();
|
||||
|
@ -49,7 +49,7 @@ private:
|
|||
ELFImage m_image;
|
||||
|
||||
struct SortedSymbol {
|
||||
dword address;
|
||||
u32 address;
|
||||
const char* name;
|
||||
};
|
||||
#ifdef KERNEL
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include "Types.h"
|
||||
|
||||
inline unsigned int_hash(dword key)
|
||||
inline unsigned int_hash(u32 key)
|
||||
{
|
||||
key += ~(key << 15);
|
||||
key ^= (key >> 10);
|
||||
|
@ -13,7 +13,7 @@ inline unsigned int_hash(dword key)
|
|||
return key;
|
||||
}
|
||||
|
||||
inline unsigned pair_int_hash(dword key1, dword key2)
|
||||
inline unsigned pair_int_hash(u32 key1, u32 key2)
|
||||
{
|
||||
return int_hash((int_hash(key1) * 209) ^ (int_hash(key2 * 413)));
|
||||
}
|
||||
|
|
|
@ -9,26 +9,26 @@ class [[gnu::packed]] IPv4Address
|
|||
{
|
||||
public:
|
||||
IPv4Address() {}
|
||||
IPv4Address(const byte data[4])
|
||||
IPv4Address(const u8 data[4])
|
||||
{
|
||||
m_data[0] = data[0];
|
||||
m_data[1] = data[1];
|
||||
m_data[2] = data[2];
|
||||
m_data[3] = data[3];
|
||||
}
|
||||
IPv4Address(byte a, byte b, byte c, byte d)
|
||||
IPv4Address(u8 a, u8 b, u8 c, u8 d)
|
||||
{
|
||||
m_data[0] = a;
|
||||
m_data[1] = b;
|
||||
m_data[2] = c;
|
||||
m_data[3] = d;
|
||||
}
|
||||
IPv4Address(NetworkOrdered<dword> address)
|
||||
: m_data_as_dword(address)
|
||||
IPv4Address(NetworkOrdered<u32> address)
|
||||
: m_data_as_u32(address)
|
||||
{
|
||||
}
|
||||
|
||||
byte operator[](int i) const
|
||||
u8 operator[](int i) const
|
||||
{
|
||||
ASSERT(i >= 0 && i < 4);
|
||||
return m_data[i];
|
||||
|
@ -39,13 +39,13 @@ public:
|
|||
return String::format("%u.%u.%u.%u", m_data[0], m_data[1], m_data[2], m_data[3]);
|
||||
}
|
||||
|
||||
bool operator==(const IPv4Address& other) const { return m_data_as_dword == other.m_data_as_dword; }
|
||||
bool operator!=(const IPv4Address& other) const { return m_data_as_dword != other.m_data_as_dword; }
|
||||
bool operator==(const IPv4Address& other) const { return m_data_as_u32 == other.m_data_as_u32; }
|
||||
bool operator!=(const IPv4Address& other) const { return m_data_as_u32 != other.m_data_as_u32; }
|
||||
|
||||
private:
|
||||
union {
|
||||
byte m_data[4];
|
||||
dword m_data_as_dword { 0 };
|
||||
u8 m_data[4];
|
||||
u32 m_data_as_u32 { 0 };
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -117,18 +117,18 @@ public:
|
|||
#endif
|
||||
}
|
||||
|
||||
dword to_dword(dword default_value = 0) const
|
||||
u32 to_u32(u32 default_value = 0) const
|
||||
{
|
||||
if (!is_number())
|
||||
return default_value;
|
||||
#ifdef KERNEL
|
||||
return (dword)m_value.as_int;
|
||||
return (u32)m_value.as_int;
|
||||
#else
|
||||
if (type() == Type::Int)
|
||||
return (dword)m_value.as_int;
|
||||
return (u32)m_value.as_int;
|
||||
if (type() == Type::UnsignedInt)
|
||||
return m_value.as_uint;
|
||||
return (dword)m_value.as_double;
|
||||
return (u32)m_value.as_double;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -12,10 +12,10 @@ extern "C" size_t strlen(const char*);
|
|||
#endif
|
||||
|
||||
template<typename PutChFunc, typename T>
|
||||
[[gnu::always_inline]] inline int print_hex(PutChFunc putch, char*& bufptr, T number, byte fields)
|
||||
[[gnu::always_inline]] inline int print_hex(PutChFunc putch, char*& bufptr, T number, u8 fields)
|
||||
{
|
||||
int ret = 0;
|
||||
byte shr_count = fields * 4;
|
||||
u8 shr_count = fields * 4;
|
||||
while (shr_count) {
|
||||
shr_count -= 4;
|
||||
putch(bufptr, printf_hex_digits[(number >> shr_count) & 0x0F]);
|
||||
|
@ -25,9 +25,9 @@ template<typename PutChFunc, typename T>
|
|||
}
|
||||
|
||||
template<typename PutChFunc>
|
||||
[[gnu::always_inline]] inline int print_number(PutChFunc putch, char*& bufptr, dword number, bool leftPad, bool zeroPad, dword fieldWidth)
|
||||
[[gnu::always_inline]] inline int print_number(PutChFunc putch, char*& bufptr, u32 number, bool leftPad, bool zeroPad, u32 fieldWidth)
|
||||
{
|
||||
dword divisor = 1000000000;
|
||||
u32 divisor = 1000000000;
|
||||
char ch;
|
||||
char padding = 1;
|
||||
char buf[16];
|
||||
|
@ -66,9 +66,9 @@ template<typename PutChFunc>
|
|||
}
|
||||
|
||||
template<typename PutChFunc>
|
||||
[[gnu::always_inline]] inline int print_qword(PutChFunc putch, char*& bufptr, qword number, bool leftPad, bool zeroPad, dword fieldWidth)
|
||||
[[gnu::always_inline]] inline int print_u64(PutChFunc putch, char*& bufptr, u64 number, bool leftPad, bool zeroPad, u32 fieldWidth)
|
||||
{
|
||||
qword divisor = 10000000000000000000LLU;
|
||||
u64 divisor = 10000000000000000000LLU;
|
||||
char ch;
|
||||
char padding = 1;
|
||||
char buf[16];
|
||||
|
@ -107,19 +107,19 @@ template<typename PutChFunc>
|
|||
}
|
||||
|
||||
template<typename PutChFunc>
|
||||
[[gnu::always_inline]] inline int print_signed_qword(PutChFunc putch, char*& bufptr, signed_qword number, bool leftPad, bool zeroPad, dword fieldWidth)
|
||||
[[gnu::always_inline]] inline int print_i64(PutChFunc putch, char*& bufptr, i64 number, bool leftPad, bool zeroPad, u32 fieldWidth)
|
||||
{
|
||||
if (number < 0) {
|
||||
putch(bufptr, '-');
|
||||
return print_qword(putch, bufptr, 0 - number, leftPad, zeroPad, fieldWidth) + 1;
|
||||
return print_u64(putch, bufptr, 0 - number, leftPad, zeroPad, fieldWidth) + 1;
|
||||
}
|
||||
return print_qword(putch, bufptr, number, leftPad, zeroPad, fieldWidth);
|
||||
return print_u64(putch, bufptr, number, leftPad, zeroPad, fieldWidth);
|
||||
}
|
||||
|
||||
template<typename PutChFunc>
|
||||
[[gnu::always_inline]] inline int print_octal_number(PutChFunc putch, char*& bufptr, dword number, bool leftPad, bool zeroPad, dword fieldWidth)
|
||||
[[gnu::always_inline]] inline int print_octal_number(PutChFunc putch, char*& bufptr, u32 number, bool leftPad, bool zeroPad, u32 fieldWidth)
|
||||
{
|
||||
dword divisor = 134217728;
|
||||
u32 divisor = 134217728;
|
||||
char ch;
|
||||
char padding = 1;
|
||||
char buf[32];
|
||||
|
@ -158,7 +158,7 @@ template<typename PutChFunc>
|
|||
}
|
||||
|
||||
template<typename PutChFunc>
|
||||
[[gnu::always_inline]] inline int print_string(PutChFunc putch, char*& bufptr, const char* str, bool leftPad, dword fieldWidth)
|
||||
[[gnu::always_inline]] inline int print_string(PutChFunc putch, char*& bufptr, const char* str, bool leftPad, u32 fieldWidth)
|
||||
{
|
||||
size_t len = strlen(str);
|
||||
if (!fieldWidth || fieldWidth < len)
|
||||
|
@ -178,7 +178,7 @@ template<typename PutChFunc>
|
|||
}
|
||||
|
||||
template<typename PutChFunc>
|
||||
[[gnu::always_inline]] inline int print_signed_number(PutChFunc putch, char*& bufptr, int number, bool leftPad, bool zeroPad, dword fieldWidth)
|
||||
[[gnu::always_inline]] inline int print_signed_number(PutChFunc putch, char*& bufptr, int number, bool leftPad, bool zeroPad, u32 fieldWidth)
|
||||
{
|
||||
if (number < 0) {
|
||||
putch(bufptr, '-');
|
||||
|
@ -248,22 +248,22 @@ template<typename PutChFunc>
|
|||
break;
|
||||
|
||||
case 'u':
|
||||
ret += print_number(putch, bufptr, va_arg(ap, dword), left_pad, zeroPad, fieldWidth);
|
||||
ret += print_number(putch, bufptr, va_arg(ap, u32), left_pad, zeroPad, fieldWidth);
|
||||
break;
|
||||
|
||||
case 'Q':
|
||||
ret += print_qword(putch, bufptr, va_arg(ap, qword), left_pad, zeroPad, fieldWidth);
|
||||
ret += print_u64(putch, bufptr, va_arg(ap, u64), left_pad, zeroPad, fieldWidth);
|
||||
break;
|
||||
|
||||
case 'q':
|
||||
ret += print_hex(putch, bufptr, va_arg(ap, qword), 16);
|
||||
ret += print_hex(putch, bufptr, va_arg(ap, u64), 16);
|
||||
break;
|
||||
|
||||
#ifndef KERNEL
|
||||
case 'g':
|
||||
case 'f':
|
||||
// FIXME: Print as float!
|
||||
ret += print_signed_qword(putch, bufptr, (qword)va_arg(ap, double), left_pad, zeroPad, fieldWidth);
|
||||
ret += print_i64(putch, bufptr, (u64)va_arg(ap, double), left_pad, zeroPad, fieldWidth);
|
||||
break;
|
||||
#endif
|
||||
|
||||
|
@ -272,7 +272,7 @@ template<typename PutChFunc>
|
|||
putch(bufptr, '0');
|
||||
++ret;
|
||||
}
|
||||
ret += print_octal_number(putch, bufptr, va_arg(ap, dword), left_pad, zeroPad, fieldWidth);
|
||||
ret += print_octal_number(putch, bufptr, va_arg(ap, u32), left_pad, zeroPad, fieldWidth);
|
||||
break;
|
||||
|
||||
case 'x':
|
||||
|
@ -281,7 +281,7 @@ template<typename PutChFunc>
|
|||
putch(bufptr, 'x');
|
||||
ret += 2;
|
||||
}
|
||||
ret += print_hex(putch, bufptr, va_arg(ap, dword), 8);
|
||||
ret += print_hex(putch, bufptr, va_arg(ap, u32), 8);
|
||||
break;
|
||||
|
||||
case 'w':
|
||||
|
@ -306,7 +306,7 @@ template<typename PutChFunc>
|
|||
putch(bufptr, '0');
|
||||
putch(bufptr, 'x');
|
||||
ret += 2;
|
||||
ret += print_hex(putch, bufptr, va_arg(ap, dword), 8);
|
||||
ret += print_hex(putch, bufptr, va_arg(ap, u32), 8);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -10,11 +10,11 @@ void* mmx_memcpy(void* dest, const void* src, size_t len)
|
|||
{
|
||||
ASSERT(len >= 1024);
|
||||
|
||||
auto* dest_ptr = (byte*)dest;
|
||||
auto* src_ptr = (const byte*)src;
|
||||
auto* dest_ptr = (u8*)dest;
|
||||
auto* src_ptr = (const u8*)src;
|
||||
|
||||
if ((dword)dest_ptr & 7) {
|
||||
dword prologue = 8 - ((dword)dest_ptr & 7);
|
||||
if ((u32)dest_ptr & 7) {
|
||||
u32 prologue = 8 - ((u32)dest_ptr & 7);
|
||||
len -= prologue;
|
||||
asm volatile(
|
||||
"rep movsb\n"
|
||||
|
@ -22,7 +22,7 @@ void* mmx_memcpy(void* dest, const void* src, size_t len)
|
|||
: "0"(src_ptr), "1"(dest_ptr), "2"(prologue)
|
||||
: "memory");
|
||||
}
|
||||
for (dword i = len / 64; i; --i) {
|
||||
for (u32 i = len / 64; i; --i) {
|
||||
asm volatile(
|
||||
"movq (%0), %%mm0\n"
|
||||
"movq 8(%0), %%mm1\n"
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
extern "C" void* mmx_memcpy(void* to, const void* from, size_t);
|
||||
#endif
|
||||
|
||||
[[gnu::always_inline]] inline void fast_dword_copy(dword* dest, const dword* src, size_t count)
|
||||
[[gnu::always_inline]] inline void fast_u32_copy(u32* dest, const u32* src, size_t count)
|
||||
{
|
||||
#ifndef KERNEL
|
||||
if (count >= 256) {
|
||||
|
@ -30,7 +30,7 @@ extern "C" void* mmx_memcpy(void* to, const void* from, size_t);
|
|||
: "memory");
|
||||
}
|
||||
|
||||
[[gnu::always_inline]] inline void fast_dword_fill(dword* dest, dword value, size_t count)
|
||||
[[gnu::always_inline]] inline void fast_u32_fill(u32* dest, u32 value, size_t count)
|
||||
{
|
||||
asm volatile(
|
||||
"rep stosl\n"
|
||||
|
@ -39,7 +39,7 @@ extern "C" void* mmx_memcpy(void* to, const void* from, size_t);
|
|||
: "memory");
|
||||
}
|
||||
|
||||
inline constexpr dword round_up_to_power_of_two(dword value, dword power_of_two)
|
||||
inline constexpr u32 round_up_to_power_of_two(u32 value, u32 power_of_two)
|
||||
{
|
||||
return ((value - 1) & ~(power_of_two - 1)) + power_of_two;
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ ByteBuffer String::to_byte_buffer() const
|
|||
{
|
||||
if (!m_impl)
|
||||
return nullptr;
|
||||
return ByteBuffer::copy(reinterpret_cast<const byte*>(characters()), length());
|
||||
return ByteBuffer::copy(reinterpret_cast<const u8*>(characters()), length());
|
||||
}
|
||||
|
||||
int String::to_int(bool& ok) const
|
||||
|
|
|
@ -66,11 +66,11 @@ private:
|
|||
char m_inline_buffer[0];
|
||||
};
|
||||
|
||||
inline constexpr dword string_hash(const char* characters, int length)
|
||||
inline constexpr u32 string_hash(const char* characters, int length)
|
||||
{
|
||||
dword hash = 0;
|
||||
u32 hash = 0;
|
||||
for (int i = 0; i < length; ++i) {
|
||||
hash += (dword)characters[i];
|
||||
hash += (u32)characters[i];
|
||||
hash += (hash << 10);
|
||||
hash ^= (hash >> 6);
|
||||
}
|
||||
|
|
|
@ -27,9 +27,9 @@ struct Traits<unsigned> : public GenericTraits<unsigned> {
|
|||
};
|
||||
|
||||
template<>
|
||||
struct Traits<word> : public GenericTraits<word> {
|
||||
static unsigned hash(word u) { return int_hash(u); }
|
||||
static void dump(word u) { kprintf("%u", u); }
|
||||
struct Traits<u16> : public GenericTraits<u16> {
|
||||
static unsigned hash(u16 u) { return int_hash(u); }
|
||||
static void dump(u16 u) { kprintf("%u", u); }
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
|
|
44
AK/Types.h
44
AK/Types.h
|
@ -21,33 +21,23 @@ static_assert(sizeof(i16) == 2);
|
|||
static_assert(sizeof(i32) == 4);
|
||||
static_assert(sizeof(i64) == 8);
|
||||
|
||||
typedef unsigned char byte;
|
||||
typedef unsigned short word;
|
||||
typedef unsigned int dword;
|
||||
typedef unsigned long long int qword;
|
||||
|
||||
typedef signed char signed_byte;
|
||||
typedef signed short signed_word;
|
||||
typedef signed int signed_dword;
|
||||
typedef signed long long int signed_qword;
|
||||
|
||||
typedef __SIZE_TYPE__ size_t;
|
||||
typedef signed_dword ssize_t;
|
||||
typedef i32 ssize_t;
|
||||
|
||||
static_assert(sizeof(size_t) == sizeof(dword));
|
||||
static_assert(sizeof(ssize_t) == sizeof(signed_dword));
|
||||
static_assert(sizeof(size_t) == sizeof(u32));
|
||||
static_assert(sizeof(ssize_t) == sizeof(i32));
|
||||
|
||||
typedef __PTRDIFF_TYPE__ ptrdiff_t;
|
||||
|
||||
typedef byte uint8_t;
|
||||
typedef word uint16_t;
|
||||
typedef dword uint32_t;
|
||||
typedef qword uint64_t;
|
||||
typedef u8 uint8_t;
|
||||
typedef u16 uint16_t;
|
||||
typedef u32 uint32_t;
|
||||
typedef u64 uint64_t;
|
||||
|
||||
typedef signed_byte int8_t;
|
||||
typedef signed_word int16_t;
|
||||
typedef signed_dword int32_t;
|
||||
typedef signed_qword int64_t;
|
||||
typedef i8 int8_t;
|
||||
typedef i16 int16_t;
|
||||
typedef i32 int32_t;
|
||||
typedef i64 int64_t;
|
||||
|
||||
#else
|
||||
# include <stdint.h>
|
||||
|
@ -62,16 +52,6 @@ typedef int8_t i8;
|
|||
typedef int16_t i16;
|
||||
typedef int32_t i32;
|
||||
typedef int64_t i64;
|
||||
|
||||
typedef uint8_t byte;
|
||||
typedef uint16_t word;
|
||||
typedef uint32_t dword;
|
||||
typedef uint64_t qword;
|
||||
|
||||
typedef int8_t signed_byte;
|
||||
typedef int16_t signed_word;
|
||||
typedef int32_t signed_dword;
|
||||
typedef int64_t signed_qword;
|
||||
#endif
|
||||
|
||||
constexpr unsigned KB = 1024;
|
||||
|
@ -82,7 +62,7 @@ namespace std {
|
|||
typedef decltype(nullptr) nullptr_t;
|
||||
}
|
||||
|
||||
static constexpr dword explode_byte(byte b)
|
||||
static constexpr u32 explode_byte(u8 b)
|
||||
{
|
||||
return b << 24 | b << 16 | b << 8 | b;
|
||||
}
|
||||
|
|
|
@ -427,7 +427,7 @@ private:
|
|||
int m_size { 0 };
|
||||
int m_capacity { 0 };
|
||||
|
||||
alignas(T) byte m_inline_buffer_storage[sizeof(T) * inline_capacity];
|
||||
alignas(T) u8 m_inline_buffer_storage[sizeof(T) * inline_capacity];
|
||||
T* m_outline_buffer { nullptr };
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue