diff --git a/AK/NumberFormat.h b/AK/NumberFormat.h index d7b1c54cb3..e3dd86a7fd 100644 --- a/AK/NumberFormat.h +++ b/AK/NumberFormat.h @@ -39,13 +39,13 @@ static String number_string_with_one_decimal(float number, const char* suffix) static String human_readable_size(size_t size) { - if (size < 1 * KB) + if (size < 1 * KiB) return String::format("%zu bytes", size); - if (size < 1 * MB) - return number_string_with_one_decimal((float)size / (float)KB, "KB"); - if (size < 1 * GB) - return number_string_with_one_decimal((float)size / (float)MB, "MB"); - return number_string_with_one_decimal((float)size / (float)GB, "GB"); + if (size < 1 * MiB) + return number_string_with_one_decimal((float)size / (float)KiB, "KB"); + if (size < 1 * GiB) + return number_string_with_one_decimal((float)size / (float)MiB, "MB"); + return number_string_with_one_decimal((float)size / (float)GiB, "GB"); } } diff --git a/AK/Types.h b/AK/Types.h index 87acffceec..f0dec283f0 100644 --- a/AK/Types.h +++ b/AK/Types.h @@ -74,9 +74,9 @@ typedef __PTRDIFF_TYPE__ __ptrdiff_t; typedef Conditional::Type FlatPtr; -constexpr unsigned KB = 1024; -constexpr unsigned MB = KB * KB; -constexpr unsigned GB = KB * KB * KB; +constexpr unsigned KiB = 1024; +constexpr unsigned MiB = KiB * KiB; +constexpr unsigned GiB = KiB * KiB * KiB; namespace std { typedef decltype(nullptr) nullptr_t; diff --git a/Applications/SoundPlayer/PlaybackManager.h b/Applications/SoundPlayer/PlaybackManager.h index 681a79a364..e07f8b4667 100644 --- a/Applications/SoundPlayer/PlaybackManager.h +++ b/Applications/SoundPlayer/PlaybackManager.h @@ -31,7 +31,7 @@ #include #include -#define PLAYBACK_MANAGER_BUFFER_SIZE 64 * KB +#define PLAYBACK_MANAGER_BUFFER_SIZE 64 * KiB #define PLAYBACK_MANAGER_RATE 44100 class PlaybackManager final { diff --git a/Applications/SystemMonitor/main.cpp b/Applications/SystemMonitor/main.cpp index de5fd827ea..eb58978a90 100644 --- a/Applications/SystemMonitor/main.cpp +++ b/Applications/SystemMonitor/main.cpp @@ -63,13 +63,13 @@ static String human_readable_size(u32 size) { - if (size < (64 * KB)) + if (size < (64 * KiB)) return String::format("%u", size); - if (size < MB) - return String::format("%u KB", size / KB); - if (size < GB) - return String::format("%u MB", size / MB); - return String::format("%u GB", size / GB); + if (size < MiB) + return String::format("%u KB", size / KiB); + if (size < GiB) + return String::format("%u MB", size / MiB); + return String::format("%u GB", size / GiB); } static NonnullRefPtr build_file_systems_tab(); diff --git a/DevTools/UserspaceEmulator/Emulator.cpp b/DevTools/UserspaceEmulator/Emulator.cpp index 3878f2854c..ef31e2c262 100644 --- a/DevTools/UserspaceEmulator/Emulator.cpp +++ b/DevTools/UserspaceEmulator/Emulator.cpp @@ -54,7 +54,7 @@ namespace UserspaceEmulator { static constexpr u32 stack_location = 0x10000000; -static constexpr size_t stack_size = 64 * KB; +static constexpr size_t stack_size = 64 * KiB; static Emulator* s_the; diff --git a/Kernel/API/Syscall.h b/Kernel/API/Syscall.h index a882df0a35..6a4595fc42 100644 --- a/Kernel/API/Syscall.h +++ b/Kernel/API/Syscall.h @@ -355,7 +355,7 @@ struct SC_create_thread_params { // ... ok, if you say so posix. Guess we get to lie to people about guard page size unsigned int m_guard_page_size = 0; // Rounded up to PAGE_SIZE unsigned int m_reported_guard_page_size = 0; // The lie we tell callers - unsigned int m_stack_size = 4 * MB; // Default PTHREAD_STACK_MIN + unsigned int m_stack_size = 4 * MiB; // Default PTHREAD_STACK_MIN Userspace m_stack_location; // nullptr means any, o.w. process virtual address }; diff --git a/Kernel/Arch/PC/BIOS.cpp b/Kernel/Arch/PC/BIOS.cpp index f8cae3855a..2bae4062d5 100644 --- a/Kernel/Arch/PC/BIOS.cpp +++ b/Kernel/Arch/PC/BIOS.cpp @@ -34,7 +34,7 @@ namespace Kernel { MappedROM map_bios() { MappedROM mapping; - mapping.size = 128 * KB; + mapping.size = 128 * KiB; mapping.paddr = PhysicalAddress(0xe0000); mapping.region = MM.allocate_kernel_region(mapping.paddr, PAGE_ROUND_UP(mapping.size), {}, Region::Access::Read); return mapping; diff --git a/Kernel/FileSystem/Plan9FileSystem.cpp b/Kernel/FileSystem/Plan9FileSystem.cpp index de7c5fd3e3..816ba650a7 100644 --- a/Kernel/FileSystem/Plan9FileSystem.cpp +++ b/Kernel/FileSystem/Plan9FileSystem.cpp @@ -837,7 +837,7 @@ KResult Plan9FSInode::traverse_as_directory(Function m_next_fid { 1 }; ProtocolVersion m_remote_protocol_version { ProtocolVersion::v9P2000 }; - size_t m_max_message_size { 4 * KB }; + size_t m_max_message_size { 4 * KiB }; Lock m_send_lock { "Plan9FS send" }; Atomic m_someone_is_reading { false }; diff --git a/Kernel/Heap/SlabAllocator.cpp b/Kernel/Heap/SlabAllocator.cpp index 2308e290d9..76eafa432a 100644 --- a/Kernel/Heap/SlabAllocator.cpp +++ b/Kernel/Heap/SlabAllocator.cpp @@ -128,10 +128,10 @@ void for_each_allocator(Callback callback) void slab_alloc_init() { - s_slab_allocator_16.init(128 * KB); - s_slab_allocator_32.init(128 * KB); - s_slab_allocator_64.init(512 * KB); - s_slab_allocator_128.init(512 * KB); + s_slab_allocator_16.init(128 * KiB); + s_slab_allocator_32.init(128 * KiB); + s_slab_allocator_64.init(512 * KiB); + s_slab_allocator_128.init(512 * KiB); } void* slab_alloc(size_t slab_size) diff --git a/Kernel/Heap/kmalloc.cpp b/Kernel/Heap/kmalloc.cpp index 6e1c691b60..5936b3641b 100644 --- a/Kernel/Heap/kmalloc.cpp +++ b/Kernel/Heap/kmalloc.cpp @@ -48,12 +48,12 @@ struct AllocationHeader { u8 data[0]; }; -#define BASE_PHYSICAL (0xc0000000 + (4 * MB)) +#define BASE_PHYSICAL (0xc0000000 + (4 * MiB)) #define CHUNK_SIZE 32 -#define POOL_SIZE (3 * MB) +#define POOL_SIZE (3 * MiB) -#define ETERNAL_BASE_PHYSICAL (0xc0000000 + (2 * MB)) -#define ETERNAL_RANGE_SIZE (2 * MB) +#define ETERNAL_BASE_PHYSICAL (0xc0000000 + (2 * MiB)) +#define ETERNAL_RANGE_SIZE (2 * MiB) static u8 alloc_map[POOL_SIZE / CHUNK_SIZE / 8]; diff --git a/Kernel/KBufferBuilder.cpp b/Kernel/KBufferBuilder.cpp index 51734bbb93..1c3129be4e 100644 --- a/Kernel/KBufferBuilder.cpp +++ b/Kernel/KBufferBuilder.cpp @@ -45,7 +45,7 @@ KBuffer KBufferBuilder::build() } KBufferBuilder::KBufferBuilder() - : m_buffer(KBuffer::create_with_size(4 * MB, Region::Access::Read | Region::Access::Write)) + : m_buffer(KBuffer::create_with_size(4 * MiB, Region::Access::Read | Region::Access::Write)) { } diff --git a/Kernel/Net/NetworkTask.cpp b/Kernel/Net/NetworkTask.cpp index 9fd05286e2..f198bc0607 100644 --- a/Kernel/Net/NetworkTask.cpp +++ b/Kernel/Net/NetworkTask.cpp @@ -105,7 +105,7 @@ void NetworkTask_main() return packet_size; }; - size_t buffer_size = 64 * KB; + size_t buffer_size = 64 * KiB; auto buffer_region = MM.allocate_kernel_region(buffer_size, "Kernel Packet Buffer", Region::Access::Read | Region::Access::Write, false, true); auto buffer = (u8*)buffer_region->vaddr().get(); diff --git a/Kernel/PerformanceEventBuffer.cpp b/Kernel/PerformanceEventBuffer.cpp index 5492f00eaf..cb6fe2fb04 100644 --- a/Kernel/PerformanceEventBuffer.cpp +++ b/Kernel/PerformanceEventBuffer.cpp @@ -33,7 +33,7 @@ namespace Kernel { PerformanceEventBuffer::PerformanceEventBuffer() - : m_buffer(KBuffer::create_with_size(4 * MB)) + : m_buffer(KBuffer::create_with_size(4 * MiB)) { } diff --git a/Kernel/Profiling.cpp b/Kernel/Profiling.cpp index 2765b59d34..18fff9aadc 100644 --- a/Kernel/Profiling.cpp +++ b/Kernel/Profiling.cpp @@ -64,7 +64,7 @@ void start(Process& process) s_pid = process.pid(); if (!s_profiling_buffer) { - s_profiling_buffer = RefPtr(KBuffer::create_with_size(8 * MB).impl()).leak_ref(); + s_profiling_buffer = RefPtr(KBuffer::create_with_size(8 * MiB).impl()).leak_ref(); s_profiling_buffer->region().commit(); s_slot_count = s_profiling_buffer->size() / sizeof(Sample); } diff --git a/Kernel/Thread.h b/Kernel/Thread.h index 3ab9fb3ca9..08f9b8a552 100644 --- a/Kernel/Thread.h +++ b/Kernel/Thread.h @@ -512,7 +512,7 @@ public: } static constexpr u32 default_kernel_stack_size = 65536; - static constexpr u32 default_userspace_stack_size = 4 * MB; + static constexpr u32 default_userspace_stack_size = 4 * MiB; ThreadTracer* tracer() { return m_tracer.ptr(); } void start_tracing_from(ProcessID tracer); diff --git a/Kernel/VM/MemoryManager.cpp b/Kernel/VM/MemoryManager.cpp index 294e7222f1..c39735225e 100644 --- a/Kernel/VM/MemoryManager.cpp +++ b/Kernel/VM/MemoryManager.cpp @@ -101,8 +101,8 @@ void MemoryManager::parse_memory_map() if (mmap->type != MULTIBOOT_MEMORY_AVAILABLE) continue; - // FIXME: Maybe make use of stuff below the 1MB mark? - if (mmap->addr < (1 * MB)) + // FIXME: Maybe make use of stuff below the 1MiB mark? + if (mmap->addr < (1 * MiB)) continue; if ((mmap->addr + mmap->len) > 0xffffffff) @@ -131,9 +131,9 @@ void MemoryManager::parse_memory_map() for (size_t page_base = mmap->addr; page_base < (mmap->addr + mmap->len); page_base += PAGE_SIZE) { auto addr = PhysicalAddress(page_base); - if (page_base < 7 * MB) { + if (page_base < 7 * MiB) { // nothing - } else if (page_base >= 7 * MB && page_base < 8 * MB) { + } else if (page_base >= 7 * MiB && page_base < 8 * MiB) { if (region.is_null() || !region_is_super || region->upper().offset(PAGE_SIZE) != addr) { m_super_physical_regions.append(PhysicalRegion::create(addr, addr)); region = m_super_physical_regions.last(); diff --git a/Kernel/VM/PageDirectory.cpp b/Kernel/VM/PageDirectory.cpp index 20f90100e7..a38fcf1f60 100644 --- a/Kernel/VM/PageDirectory.cpp +++ b/Kernel/VM/PageDirectory.cpp @@ -80,7 +80,7 @@ PageDirectory::PageDirectory(Process& process, const RangeAllocator* parent_rang if (parent_range_allocator) { m_range_allocator.initialize_from_parent(*parent_range_allocator); } else { - size_t random_offset = (get_fast_random() % 32 * MB) & PAGE_MASK; + size_t random_offset = (get_fast_random() % 32 * MiB) & PAGE_MASK; u32 base = userspace_range_base + random_offset; m_range_allocator.initialize_with_range(VirtualAddress(base), userspace_range_ceiling - base); } @@ -102,7 +102,7 @@ PageDirectory::PageDirectory(Process& process, const RangeAllocator* parent_rang MM.unquickmap_page(); } - // Clone bottom 2 MB of mappings from kernel_page_directory + // Clone bottom 2 MiB of mappings from kernel_page_directory PageDirectoryEntry buffer; auto* kernel_pd = MM.quickmap_pd(MM.kernel_page_directory(), 0); memcpy(&buffer, kernel_pd, sizeof(PageDirectoryEntry)); diff --git a/Libraries/LibAudio/WavLoader.h b/Libraries/LibAudio/WavLoader.h index 5a4c58c06e..c0a8bae4bc 100644 --- a/Libraries/LibAudio/WavLoader.h +++ b/Libraries/LibAudio/WavLoader.h @@ -44,7 +44,7 @@ public: bool has_error() const { return !m_error_string.is_null(); } const char* error_string() { return m_error_string.characters(); } - RefPtr get_more_samples(size_t max_bytes_to_read_from_input = 128 * KB); + RefPtr get_more_samples(size_t max_bytes_to_read_from_input = 128 * KiB); void reset(); void seek(const int position); diff --git a/Libraries/LibC/malloc.cpp b/Libraries/LibC/malloc.cpp index 72d5b5bc27..a89f20de82 100644 --- a/Libraries/LibC/malloc.cpp +++ b/Libraries/LibC/malloc.cpp @@ -73,7 +73,7 @@ static bool s_profiling = false; static unsigned short size_classes[] = { 8, 16, 32, 64, 128, 252, 508, 1016, 2036, 4090, 8188, 16376, 32756, 0 }; static constexpr size_t num_size_classes = sizeof(size_classes) / sizeof(unsigned short); -constexpr size_t block_size = 64 * KB; +constexpr size_t block_size = 64 * KiB; constexpr size_t block_mask = ~(block_size - 1); struct CommonHeader { diff --git a/Libraries/LibGemini/Job.cpp b/Libraries/LibGemini/Job.cpp index b4d0d4c10a..37753eb920 100644 --- a/Libraries/LibGemini/Job.cpp +++ b/Libraries/LibGemini/Job.cpp @@ -109,7 +109,7 @@ void Job::on_socket_connected() ASSERT(m_state == State::InBody || m_state == State::Finished); read_while_data_available([&] { - auto read_size = 64 * KB; + auto read_size = 64 * KiB; auto payload = receive(read_size); if (!payload) { diff --git a/Libraries/LibGfx/JPGLoader.cpp b/Libraries/LibGfx/JPGLoader.cpp index ca0715127f..bec4d6f5b8 100644 --- a/Libraries/LibGfx/JPGLoader.cpp +++ b/Libraries/LibGfx/JPGLoader.cpp @@ -1206,7 +1206,7 @@ JPGImageDecoderPlugin::JPGImageDecoderPlugin(const u8* data, size_t size) m_context = make(); m_context->data = data; m_context->data_size = size; - m_context->huffman_stream.stream.ensure_capacity(50 * KB); + m_context->huffman_stream.stream.ensure_capacity(50 * KiB); } JPGImageDecoderPlugin::~JPGImageDecoderPlugin() diff --git a/Libraries/LibHTTP/Job.cpp b/Libraries/LibHTTP/Job.cpp index 36d47f9455..285338db63 100644 --- a/Libraries/LibHTTP/Job.cpp +++ b/Libraries/LibHTTP/Job.cpp @@ -173,7 +173,7 @@ void Job::on_socket_connected() ASSERT(can_read()); read_while_data_available([&] { - auto read_size = 64 * KB; + auto read_size = 64 * KiB; if (m_current_chunk_remaining_size.has_value()) { read_chunk_size:; auto remaining = m_current_chunk_remaining_size.value(); diff --git a/Libraries/LibJS/Heap/HeapBlock.h b/Libraries/LibJS/Heap/HeapBlock.h index 8a12d84090..6269ebd45d 100644 --- a/Libraries/LibJS/Heap/HeapBlock.h +++ b/Libraries/LibJS/Heap/HeapBlock.h @@ -34,7 +34,7 @@ namespace JS { class HeapBlock { public: - static constexpr size_t block_size = 16 * KB; + static constexpr size_t block_size = 16 * KiB; static NonnullOwnPtr create_with_cell_size(Heap&, size_t); void operator delete(void*); diff --git a/Libraries/LibPthread/pthread.cpp b/Libraries/LibPthread/pthread.cpp index ebf50f78c8..68af2fff21 100644 --- a/Libraries/LibPthread/pthread.cpp +++ b/Libraries/LibPthread/pthread.cpp @@ -44,9 +44,9 @@ namespace { using PthreadAttrImpl = Syscall::SC_create_thread_params; } // end anonymous namespace -constexpr size_t required_stack_alignment = 4 * MB; +constexpr size_t required_stack_alignment = 4 * MiB; constexpr size_t highest_reasonable_guard_size = 32 * PAGE_SIZE; -constexpr size_t highest_reasonable_stack_size = 8 * MB; // That's the default in Ubuntu? +constexpr size_t highest_reasonable_stack_size = 8 * MiB; // That's the default in Ubuntu? extern "C" { diff --git a/MenuApplets/ResourceGraph/main.cpp b/MenuApplets/ResourceGraph/main.cpp index f27341c6dc..ad2e97d892 100644 --- a/MenuApplets/ResourceGraph/main.cpp +++ b/MenuApplets/ResourceGraph/main.cpp @@ -80,7 +80,7 @@ private: float total_memory = allocated + available; float memory = (float)allocated / total_memory; m_history.enqueue(memory); - m_tooltip = String::format("Memory: %.1f MiB of %.1f MiB in use",(float)allocated / MB, total_memory / MB); + m_tooltip = String::format("Memory: %.1f MiB of %.1f MiB in use", (float)allocated / MiB, total_memory / MiB); break; } default: diff --git a/Userland/Tests/Kernel/bxvga-mmap-kernel-into-userspace.cpp b/Userland/Tests/Kernel/bxvga-mmap-kernel-into-userspace.cpp index 0ffaafa19d..82ac8b469a 100644 --- a/Userland/Tests/Kernel/bxvga-mmap-kernel-into-userspace.cpp +++ b/Userland/Tests/Kernel/bxvga-mmap-kernel-into-userspace.cpp @@ -69,7 +69,7 @@ int main() printf("Success! Evil pointer: %p\n", ptr); - u8* base = &ptr[128 * MB]; + u8* base = &ptr[128 * MiB]; uintptr_t g_processes = *(uintptr_t*)&base[0x1b51c4]; printf("base = %p\n", base); diff --git a/Userland/df.cpp b/Userland/df.cpp index a8a6595867..84681ee443 100644 --- a/Userland/df.cpp +++ b/Userland/df.cpp @@ -58,13 +58,13 @@ static String number_string_with_one_decimal(float number, const char* suffix) static String human_readable_size(size_t size) { - if (size < 1 * KB) + if (size < 1 * KiB) return String::number(size); - if (size < 1 * MB) - return number_string_with_one_decimal((float)size / (float)KB, "K"); - if (size < 1 * GB) - return number_string_with_one_decimal((float)size / (float)MB, "M"); - return number_string_with_one_decimal((float)size / (float)GB, "G"); + if (size < 1 * MiB) + return number_string_with_one_decimal((float)size / (float)KiB, "K"); + if (size < 1 * GiB) + return number_string_with_one_decimal((float)size / (float)MiB, "M"); + return number_string_with_one_decimal((float)size / (float)GiB, "G"); } int main(int argc, char** argv) diff --git a/Userland/ifconfig.cpp b/Userland/ifconfig.cpp index 85eee10488..bd32b8ee68 100644 --- a/Userland/ifconfig.cpp +++ b/Userland/ifconfig.cpp @@ -40,12 +40,12 @@ static String si_bytes(unsigned bytes) { - if (bytes >= GB) - return String::format("%fGiB", (double)bytes / (double)GB); - if (bytes >= MB) - return String::format("%fMiB", (double)bytes / (double)MB); - if (bytes >= KB) - return String::format("%fkiB", (double)bytes / (double)KB); + if (bytes >= GiB) + return String::format("%fGiB", (double)bytes / (double)GiB); + if (bytes >= MiB) + return String::format("%fMiB", (double)bytes / (double)MiB); + if (bytes >= KiB) + return String::format("%fkiB", (double)bytes / (double)KiB); return String::format("%dB", bytes); } diff --git a/Userland/ls.cpp b/Userland/ls.cpp index 4d0e4ea993..7fed159f1e 100644 --- a/Userland/ls.cpp +++ b/Userland/ls.cpp @@ -241,13 +241,13 @@ static String number_string_with_one_decimal(float number, const char* suffix) static String human_readable_size(size_t size) { - if (size < 1 * KB) + if (size < 1 * KiB) return String::number(size); - if (size < 1 * MB) - return number_string_with_one_decimal((float)size / (float)KB, "K"); - if (size < 1 * GB) - return number_string_with_one_decimal((float)size / (float)MB, "M"); - return number_string_with_one_decimal((float)size / (float)GB, "G"); + if (size < 1 * MiB) + return number_string_with_one_decimal((float)size / (float)KiB, "K"); + if (size < 1 * GiB) + return number_string_with_one_decimal((float)size / (float)MiB, "M"); + return number_string_with_one_decimal((float)size / (float)GiB, "G"); } static bool print_filesystem_object(const String& path, const String& name, const struct stat& st) diff --git a/Userland/unzip.cpp b/Userland/unzip.cpp index cf7bfaf9e9..f88e414892 100644 --- a/Userland/unzip.cpp +++ b/Userland/unzip.cpp @@ -156,7 +156,7 @@ static bool unpack_file_for_central_directory_index(off_t central_directory_inde int main(int argc, char** argv) { const char* path; - int map_size_limit = 32 * MB; + int map_size_limit = 32 * MiB; Core::ArgsParser args_parser; args_parser.add_option(map_size_limit, "Maximum chunk size to map", "map-size-limit", 0, "size");