From 44ec21c3ff3eb22693333ad429b1972206223754 Mon Sep 17 00:00:00 2001 From: Jessica Hamilton Date: Fri, 30 May 2014 00:12:45 +1200 Subject: [PATCH] ByteOrder.h: simplify compiler test * A problem with our gcc requires adding casts for gcc4 when the __builtin_bswap functions are used with a format string * Unlike gcc2, the __builtin_bswap functions do not get disabled despite using -fno-builtins, hence added compiler check in runtime_loader/utility.cpp --- headers/os/support/ByteOrder.h | 6 +----- src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp | 4 ++-- src/system/kernel/arch/x86/arch_debug.cpp | 4 ++-- src/system/runtime_loader/utility.cpp | 3 ++- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/headers/os/support/ByteOrder.h b/headers/os/support/ByteOrder.h index 9952769ff4..de6e959a15 100644 --- a/headers/os/support/ByteOrder.h +++ b/headers/os/support/ByteOrder.h @@ -120,11 +120,7 @@ extern bool is_type_swapped(type_code type); /* Private implementations */ extern double __swap_double(double arg); extern float __swap_float(float arg); -#if (defined(__INTEL__) || defined(__x86_64__)) && GCC_VERSION >= 40300 -#define __swap_int64(arg) __builtin_bswap64(arg) -#define __swap_int32(arg) __builtin_bswap32(arg) -#define __swap_int16(arg) __builtin_bswap16(arg) -#elif defined(__ARM__) && GCC_VERSION >= 40800 +#if __GNUC__ >= 4 #define __swap_int64(arg) __builtin_bswap64(arg) #define __swap_int32(arg) __builtin_bswap32(arg) #define __swap_int16(arg) __builtin_bswap16(arg) diff --git a/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp b/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp index a7429088f0..4b2576ddb5 100644 --- a/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp +++ b/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp @@ -819,8 +819,8 @@ AHCIPort::ScsiUnmap(scsi_ccb* request, scsi_unmap_parameter_list* unmapBlocks) dprintf("TRIM SCSI:\n"); for (uint32 i = 0; i < scsiRangeCount; i++) { dprintf("[%3" B_PRIu32 "] %" B_PRIu64 " : %" B_PRIu32 "\n", i, - B_BENDIAN_TO_HOST_INT64(unmapBlocks->blocks[i].lba), - B_BENDIAN_TO_HOST_INT32(unmapBlocks->blocks[i].block_count)); + (uint64)B_BENDIAN_TO_HOST_INT64(unmapBlocks->blocks[i].lba), + (uint32)B_BENDIAN_TO_HOST_INT32(unmapBlocks->blocks[i].block_count)); } uint32 scsiIndex = 0; diff --git a/src/system/kernel/arch/x86/arch_debug.cpp b/src/system/kernel/arch/x86/arch_debug.cpp index 199f16f402..4df0bd4355 100644 --- a/src/system/kernel/arch/x86/arch_debug.cpp +++ b/src/system/kernel/arch/x86/arch_debug.cpp @@ -1330,11 +1330,11 @@ arch_debug_gdb_get_registers(char* buffer, size_t bufferSize) switch (registers[i].type) { case B_UINT64_TYPE: result = snprintf(buffer, bufferSize, "%016" B_PRIx64, - B_HOST_TO_BENDIAN_INT64(registers[i].value)); + (uint64)B_HOST_TO_BENDIAN_INT64(registers[i].value)); break; case B_UINT32_TYPE: result = snprintf(buffer, bufferSize, "%08" B_PRIx32, - B_HOST_TO_BENDIAN_INT32((uint32)registers[i].value)); + (uint32)B_HOST_TO_BENDIAN_INT32((uint32)registers[i].value)); break; } if (result >= (int)bufferSize) diff --git a/src/system/runtime_loader/utility.cpp b/src/system/runtime_loader/utility.cpp index 922f8078a7..6a9e0734b3 100644 --- a/src/system/runtime_loader/utility.cpp +++ b/src/system/runtime_loader/utility.cpp @@ -72,13 +72,14 @@ dprintf(const char *format, ...) va_end(list); } - +#if __GNUC__ == 2 extern "C" uint32 __swap_int32(uint32 value) { return value >> 24 | ((value >> 8) & 0xff00) | value << 24 | ((value << 8) & 0xff0000); } +#endif // Copied from libroot/os/thread.c: