diff --git a/Userland/Games/Chess/ChessWidget.cpp b/Userland/Games/Chess/ChessWidget.cpp index 79572d42f9..b723ffbd95 100644 --- a/Userland/Games/Chess/ChessWidget.cpp +++ b/Userland/Games/Chess/ChessWidget.cpp @@ -360,13 +360,13 @@ void ChessWidget::set_piece_set(const StringView& set) Chess::Square ChessWidget::mouse_to_square(GUI::MouseEvent& event) const { - size_t tile_width = width() / 8; - size_t tile_height = height() / 8; + unsigned tile_width = width() / 8; + unsigned tile_height = height() / 8; if (side() == Chess::Color::White) { - return { 7 - (event.y() / tile_height), event.x() / tile_width }; + return { (unsigned)(7 - (event.y() / tile_height)), (unsigned)(event.x() / tile_width) }; } else { - return { event.y() / tile_height, 7 - (event.x() / tile_width) }; + return { (unsigned)(event.y() / tile_height), (unsigned)(7 - (event.x() / tile_width)) }; } } diff --git a/Userland/Libraries/LibC/inttypes.h b/Userland/Libraries/LibC/inttypes.h index 253a349cab..9355cf6ec6 100644 --- a/Userland/Libraries/LibC/inttypes.h +++ b/Userland/Libraries/LibC/inttypes.h @@ -18,23 +18,40 @@ __BEGIN_DECLS #define PRIi8 "d" #define PRIi16 "d" #define PRIi32 "d" -#define PRIi64 "lld" +#ifndef __LP64__ +# define PRIi64 "lld" +#else +# define PRIi64 "ld" +#endif #define PRIu8 "u" #define PRIo8 "o" #define PRIo16 "o" #define PRIo32 "o" -#define PRIo64 "llo" +#ifndef __LP64__ +# define PRIo64 "llo" +#else +# define PRIo64 "lo" +#endif #define PRIu16 "u" #define PRIu32 "u" -#define PRIu64 "llu" +#ifndef __LP64__ +# define PRIu64 "llu" +#else +# define PRIu64 "lu" +#endif #define PRIx8 "b" #define PRIX8 "hhX" #define PRIx16 "w" #define PRIX16 "hX" #define PRIx32 "x" #define PRIX32 "X" -#define PRIx64 "llx" -#define PRIX64 "llX" +#ifndef __LP64__ +# define PRIx64 "llx" +# define PRIX64 "llX" +#else +# define PRIx64 "lx" +# define PRIX64 "lX" +#endif #define __PRI64_PREFIX "ll" #define __PRIPTR_PREFIX diff --git a/Userland/Libraries/LibDebug/DebugSession.h b/Userland/Libraries/LibDebug/DebugSession.h index dac76d5387..2e99f7b843 100644 --- a/Userland/Libraries/LibDebug/DebugSession.h +++ b/Userland/Libraries/LibDebug/DebugSession.h @@ -259,7 +259,7 @@ void DebugSession::run(DesiredInitialDebugeeState initial_debugee_state, Callbac Optional current_breakpoint; if (state == State::FreeRun || state == State::Syscall) { - current_breakpoint = m_breakpoints.get((void*)((u32)regs.eip - 1)); + current_breakpoint = m_breakpoints.get((void*)((uintptr_t)regs.eip - 1)); if (current_breakpoint.has_value()) state = State::FreeRun; } else { diff --git a/Userland/Services/WebServer/Client.cpp b/Userland/Services/WebServer/Client.cpp index a26bd251b8..4a24eaf1f8 100644 --- a/Userland/Services/WebServer/Client.cpp +++ b/Userland/Services/WebServer/Client.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -220,7 +221,7 @@ void Client::handle_directory_listing(const String& requested_path, const String builder.append(escape_html_entities(name)); builder.append(" "); - builder.appendf("%10lld ", st.st_size); + builder.appendf("%10" PRIi64 " ", st.st_size); builder.append(""); builder.append(Core::DateTime::from_timestamp(st.st_mtime).to_string()); builder.append(""); diff --git a/Userland/Tests/Kernel/bxvga-mmap-kernel-into-userspace.cpp b/Userland/Tests/Kernel/bxvga-mmap-kernel-into-userspace.cpp index 9d98c1592f..43df0bb34a 100644 --- a/Userland/Tests/Kernel/bxvga-mmap-kernel-into-userspace.cpp +++ b/Userland/Tests/Kernel/bxvga-mmap-kernel-into-userspace.cpp @@ -53,7 +53,7 @@ int main() uintptr_t g_processes = *(uintptr_t*)&base[0x1b51c4]; printf("base = %p\n", base); - printf("g_processes = %#08x\n", g_processes); + printf("g_processes = %p\n", (void*)g_processes); auto get_ptr = [&](uintptr_t value) -> void* { value -= 0xc0000000; @@ -80,7 +80,7 @@ int main() Process* process = (Process*)get_ptr(process_list->head); - printf("{%p} PID: %d, UID: %d, next: %#08x\n", process, process->pid, process->uid, process->next); + printf("{%p} PID: %d, UID: %d, next: %p\n", process, process->pid, process->uid, (void*)process->next); if (process->pid == getpid()) { printf("That's me! Let's become r00t!\n"); diff --git a/Userland/Tests/Kernel/elf-symbolication-kernel-read-exploit.cpp b/Userland/Tests/Kernel/elf-symbolication-kernel-read-exploit.cpp index c803b1c8f3..88ac29fa74 100644 --- a/Userland/Tests/Kernel/elf-symbolication-kernel-read-exploit.cpp +++ b/Userland/Tests/Kernel/elf-symbolication-kernel-read-exploit.cpp @@ -88,7 +88,7 @@ int main() strcpy(shstrtab, ".strtab"); auto* code = &buffer[8192]; - size_t haxcode_size = (u32)haxcode_end - (u32)haxcode; + size_t haxcode_size = (uintptr_t)haxcode_end - (uintptr_t)haxcode; printf("memcpy(%p, %p, %zu)\n", code, haxcode, haxcode_size); memcpy(code, (void*)haxcode, haxcode_size); @@ -100,7 +100,7 @@ int main() return 1; } - int nwritten = write(fd, buffer, sizeof(buffer)); + auto nwritten = write(fd, buffer, sizeof(buffer)); if (nwritten < 0) { perror("write"); return 1; diff --git a/Userland/Tests/Kernel/stress-writeread.cpp b/Userland/Tests/Kernel/stress-writeread.cpp index 25d627a701..8151c355d1 100644 --- a/Userland/Tests/Kernel/stress-writeread.cpp +++ b/Userland/Tests/Kernel/stress-writeread.cpp @@ -21,18 +21,18 @@ bool verify_block(int fd, int seed, off_t block, AK::ByteBuffer& buffer) auto offset = block * buffer.size(); auto rs = lseek(fd, offset, SEEK_SET); if (rs < 0) { - fprintf(stderr, "Couldn't seek to block %lld (offset %lld) while verifying: %s\n", block, offset, strerror(errno)); + fprintf(stderr, "Couldn't seek to block %" PRIi64 " (offset %" PRIi64 ") while verifying: %s\n", block, offset, strerror(errno)); return false; } auto rw = read(fd, buffer.data(), buffer.size()); if (rw != static_cast(buffer.size())) { - fprintf(stderr, "Failure to read block %lld: %s\n", block, strerror(errno)); + fprintf(stderr, "Failure to read block %" PRIi64 ": %s\n", block, strerror(errno)); return false; } srand((seed + 1) * (block + 1)); for (size_t i = 0; i < buffer.size(); i++) { if (buffer[i] != rand() % 256) { - fprintf(stderr, "Discrepancy detected at block %lld offset %zd\n", block, i); + fprintf(stderr, "Discrepancy detected at block %" PRIi64 " offset %zd\n", block, i); return false; } } @@ -44,7 +44,7 @@ bool write_block(int fd, int seed, off_t block, AK::ByteBuffer& buffer) auto offset = block * buffer.size(); auto rs = lseek(fd, offset, SEEK_SET); if (rs < 0) { - fprintf(stderr, "Couldn't seek to block %lld (offset %lld) while verifying: %s\n", block, offset, strerror(errno)); + fprintf(stderr, "Couldn't seek to block %" PRIi64 " (offset %" PRIi64 ") while verifying: %s\n", block, offset, strerror(errno)); return false; } srand((seed + 1) * (block + 1)); @@ -52,7 +52,7 @@ bool write_block(int fd, int seed, off_t block, AK::ByteBuffer& buffer) buffer[i] = rand(); auto rw = write(fd, buffer.data(), buffer.size()); if (rw != static_cast(buffer.size())) { - fprintf(stderr, "Failure to write block %lld: %s\n", block, strerror(errno)); + fprintf(stderr, "Failure to write block %" PRIi64 ": %s\n", block, strerror(errno)); return false; } return true; diff --git a/Userland/Utilities/crash.cpp b/Userland/Utilities/crash.cpp index 309e891924..743b75c1d3 100644 --- a/Userland/Utilities/crash.cpp +++ b/Userland/Utilities/crash.cpp @@ -267,8 +267,14 @@ int main(int argc, char** argv) return Crash::Failure::UnexpectedError; u8* bad_esp = bad_stack + 2048; +#ifndef __LP64__ asm volatile("mov %%eax, %%esp" ::"a"(bad_esp)); asm volatile("pushl $0"); +#else + asm volatile("movq %%rax, %%rsp" ::"a"(bad_esp)); + asm volatile("pushq $0"); +#endif + return Crash::Failure::DidNotCrash; }).run(run_type); } diff --git a/Userland/Utilities/date.cpp b/Userland/Utilities/date.cpp index ef48ad6946..94227ac5d1 100644 --- a/Userland/Utilities/date.cpp +++ b/Userland/Utilities/date.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include diff --git a/Userland/Utilities/df.cpp b/Userland/Utilities/df.cpp index b0d1f0b106..03d83df991 100644 --- a/Userland/Utilities/df.cpp +++ b/Userland/Utilities/df.cpp @@ -71,9 +71,9 @@ int main(int argc, char** argv) printf("%10s ", human_readable_size((total_block_count - free_block_count) * block_size).characters()); printf("%10s ", human_readable_size(free_block_count * block_size).characters()); } else { - printf("%10" PRIu64 " ", total_block_count); - printf("%10" PRIu64 " ", total_block_count - free_block_count); - printf("%10" PRIu64 " ", free_block_count); + printf("%10" PRIu64 " ", (uint64_t)total_block_count); + printf("%10" PRIu64 " ", (uint64_t)(total_block_count - free_block_count)); + printf("%10" PRIu64 " ", (uint64_t)free_block_count); } printf("%s", mount_point.characters()); diff --git a/Userland/Utilities/du.cpp b/Userland/Utilities/du.cpp index 90731e8e30..b8c292b7e7 100644 --- a/Userland/Utilities/du.cpp +++ b/Userland/Utilities/du.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -151,7 +152,7 @@ int print_space_usage(const String& path, const DuOption& du_option, int max_dep return 0; } - long long size = path_stat.st_size; + off_t size = path_stat.st_size; if (du_option.apparent_size) { const auto block_size = 512; size = path_stat.st_blocks * block_size; @@ -164,7 +165,7 @@ int print_space_usage(const String& path, const DuOption& du_option, int max_dep size = size / block_size + (size % block_size != 0); if (du_option.time_type == DuOption::TimeType::NotUsed) - printf("%lld\t%s\n", size, path.characters()); + printf("%" PRIi64 "\t%s\n", size, path.characters()); else { auto time = path_stat.st_mtime; switch (du_option.time_type) { @@ -178,7 +179,7 @@ int print_space_usage(const String& path, const DuOption& du_option, int max_dep } const auto formatted_time = Core::DateTime::from_timestamp(time).to_string(); - printf("%lld\t%s\t%s\n", size, formatted_time.characters(), path.characters()); + printf("%" PRIi64 "\t%s\t%s\n", size, formatted_time.characters(), path.characters()); } return 0; diff --git a/Userland/Utilities/functrace.cpp b/Userland/Utilities/functrace.cpp index 0024763561..98aa5555f4 100644 --- a/Userland/Utilities/functrace.cpp +++ b/Userland/Utilities/functrace.cpp @@ -68,7 +68,7 @@ static NonnullOwnPtr> instrument_code() if (section.name() != ".text") return IterationDecision::Continue; - X86::SimpleInstructionStream stream((const u8*)((u32)lib.file->data() + section.offset()), section.size()); + X86::SimpleInstructionStream stream((const u8*)((uintptr_t)lib.file->data() + section.offset()), section.size()); X86::Disassembler disassembler(stream); for (;;) { auto offset = stream.offset(); diff --git a/Userland/Utilities/ls.cpp b/Userland/Utilities/ls.cpp index 4938c1e81e..8c56b02751 100644 --- a/Userland/Utilities/ls.cpp +++ b/Userland/Utilities/ls.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -313,7 +314,7 @@ static bool print_filesystem_object(const String& path, const String& name, cons if (flag_human_readable) { printf(" %10s ", human_readable_size(st.st_size).characters()); } else { - printf(" %10lld ", st.st_size); + printf(" %10" PRIu64 " ", (uint64_t)st.st_size); } } diff --git a/Userland/Utilities/stat.cpp b/Userland/Utilities/stat.cpp index 5d1a751d9d..1abca9507a 100644 --- a/Userland/Utilities/stat.cpp +++ b/Userland/Utilities/stat.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -28,7 +29,7 @@ static int stat(const char* file, bool should_follow_links) if (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode)) printf(" Device: %u,%u\n", major(st.st_rdev), minor(st.st_rdev)); else - printf(" Size: %lld\n", st.st_size); + printf(" Size: %" PRIi64 "\n", st.st_size); printf(" Links: %u\n", st.st_nlink); printf(" Blocks: %u\n", st.st_blocks); printf(" UID: %u", st.st_uid); diff --git a/Userland/Utilities/w.cpp b/Userland/Utilities/w.cpp index a9454a3a8c..14158ccf7c 100644 --- a/Userland/Utilities/w.cpp +++ b/Userland/Utilities/w.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -87,7 +88,7 @@ int main() if (stat(tty.characters(), &st) == 0) { auto idle_time = now - st.st_mtime; if (idle_time >= 0) { - builder.appendf("%llds", idle_time); + builder.appendf("%" PRIi64 "s", idle_time); idle_string = builder.to_string(); } }