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
This commit is contained in:
Jessica Hamilton 2014-05-30 00:12:45 +12:00
parent 221ea8a17e
commit 44ec21c3ff
4 changed files with 7 additions and 10 deletions

View File

@ -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)

View File

@ -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;

View File

@ -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)

View File

@ -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: