Procházet zdrojové kódy

Userland: Prefer using ARCH() over __LP64__

Gunnar Beutner před 4 roky
rodič
revize
4cf24c6ba2

+ 1 - 1
Userland/Libraries/LibC/elf.h

@@ -38,7 +38,7 @@
 #    include <AK/Types.h>
 #endif
 
-#ifdef __LP64__
+#ifdef __x86_64__
 #    define ElfW(type) Elf64_##type
 #else
 #    define ElfW(type) Elf32_##type

+ 5 - 4
Userland/Libraries/LibC/inttypes.h

@@ -6,6 +6,7 @@
 
 #pragma once
 
+#include <AK/Platform.h>
 #include <bits/stdint.h>
 #include <sys/cdefs.h>
 
@@ -18,7 +19,7 @@ __BEGIN_DECLS
 #define PRIi8 "d"
 #define PRIi16 "d"
 #define PRIi32 "d"
-#ifndef __LP64__
+#if ARCH(I386)
 #    define PRIi64 "lld"
 #else
 #    define PRIi64 "ld"
@@ -27,14 +28,14 @@ __BEGIN_DECLS
 #define PRIo8 "o"
 #define PRIo16 "o"
 #define PRIo32 "o"
-#ifndef __LP64__
+#if ARCH(I386)
 #    define PRIo64 "llo"
 #else
 #    define PRIo64 "lo"
 #endif
 #define PRIu16 "u"
 #define PRIu32 "u"
-#ifndef __LP64__
+#if ARCH(I386)
 #    define PRIu64 "llu"
 #    define PRIuPTR "x"
 #else
@@ -47,7 +48,7 @@ __BEGIN_DECLS
 #define PRIX16 "hX"
 #define PRIx32 "x"
 #define PRIX32 "X"
-#ifndef __LP64__
+#if ARCH(I386)
 #    define PRIx64 "llx"
 #    define PRIX64 "llX"
 #    define PRIxPTR "x"

+ 0 - 6
Userland/Libraries/LibC/link.h

@@ -16,12 +16,6 @@
 
 __BEGIN_DECLS
 
-#ifdef __LP64__
-#    define ElfW(type) Elf64_##type
-#else
-#    define ElfW(type) Elf32_##type
-#endif
-
 struct dl_phdr_info {
     ElfW(Addr) dlpi_addr;
     const char* dlpi_name;

+ 6 - 6
Userland/Libraries/LibELF/DynamicLoader.cpp

@@ -398,7 +398,7 @@ DynamicLoader::RelocationResult DynamicLoader::do_relocation(const ELF::DynamicO
         patch_ptr = (FlatPtr*)(FlatPtr)relocation.offset();
 
     switch (relocation.type()) {
-#ifndef __LP64__
+#if ARCH(I386)
     case R_386_NONE:
 #else
     case R_X86_64_NONE:
@@ -406,7 +406,7 @@ DynamicLoader::RelocationResult DynamicLoader::do_relocation(const ELF::DynamicO
         // Apparently most loaders will just skip these?
         // Seems if the 'link editor' generates one something is funky with your code
         break;
-#ifndef __LP64__
+#if ARCH(I386)
     case R_386_32: {
 #else
     case R_X86_64_64: {
@@ -426,7 +426,7 @@ DynamicLoader::RelocationResult DynamicLoader::do_relocation(const ELF::DynamicO
             *patch_ptr += symbol_address.get();
         break;
     }
-#ifndef __LP64__
+#if ARCH(I386)
     case R_386_PC32: {
         auto symbol = relocation.symbol();
         auto result = lookup_symbol(symbol);
@@ -459,7 +459,7 @@ DynamicLoader::RelocationResult DynamicLoader::do_relocation(const ELF::DynamicO
         *patch_ptr = symbol_location.get();
         break;
     }
-#ifndef __LP64__
+#if ARCH(I386)
     case R_386_RELATIVE: {
 #else
     case R_X86_64_RELATIVE: {
@@ -473,7 +473,7 @@ DynamicLoader::RelocationResult DynamicLoader::do_relocation(const ELF::DynamicO
             *patch_ptr += (FlatPtr)m_dynamic_object->base_address().as_ptr();
         break;
     }
-#ifndef __LP64__
+#if ARCH(I386)
     case R_386_TLS_TPOFF32:
     case R_386_TLS_TPOFF: {
 #else
@@ -497,7 +497,7 @@ DynamicLoader::RelocationResult DynamicLoader::do_relocation(const ELF::DynamicO
         *patch_ptr = negative_offset_from_tls_block_end(dynamic_object_of_symbol->tls_offset().value(), symbol_value + addend);
         break;
     }
-#ifndef __LP64__
+#if ARCH(I386)
     case R_386_JMP_SLOT: {
 #else
     case R_X86_64_JUMP_SLOT: {

+ 1 - 1
Userland/Utilities/crash.cpp

@@ -207,7 +207,7 @@ int main(int argc, char** argv)
                 return Crash::Failure::UnexpectedError;
 
             u8* bad_esp = bad_stack + 2048;
-#ifndef __LP64__
+#if ARCH(I386)
             asm volatile("mov %%eax, %%esp" ::"a"(bad_esp));
             asm volatile("pushl $0");
 #else