Ticket #10800: 0001-Use-GCC-builtins-for-byte-swapping.-Fixes-10800.patch

File 0001-Use-GCC-builtins-for-byte-swapping.-Fixes-10800.patch, 1.2 KB (added by jessicah, 10 years ago)
  • headers/os/support/ByteOrder.h

    From 113c52497c917837169b408defe219b84d31ff48 Mon Sep 17 00:00:00 2001
    From: Jessica Hamilton <jessica.l.hamilton@gmail.com>
    Date: Sun, 4 May 2014 12:03:11 +1200
    Subject: [PATCH] Use GCC builtins for byte-swapping. Fixes #10800.
    
    ---
     headers/os/support/ByteOrder.h | 9 +++++++--
     1 file changed, 7 insertions(+), 2 deletions(-)
    
    diff --git a/headers/os/support/ByteOrder.h b/headers/os/support/ByteOrder.h
    index 96e9961..0411faa 100644
    a b typedef enum {  
    111111
    112112#ifdef __cplusplus
    113113extern "C" {
    114 #endif 
     114#endif
    115115
    116116extern status_t swap_data(type_code type, void *data, size_t length,
    117117    swap_action action);
    118118extern bool is_type_swapped(type_code type);
    119119
    120 
    121120/* Private implementations */
    122121extern double __swap_double(double arg);
    123122extern float  __swap_float(float arg);
     123#if GCC_VERSION >= 40600
     124#define __swap_int64(arg)   __builtin_bswap64(arg)
     125#define __swap_int32(arg)   __builtin_bswap32(arg)
     126#define __swap_int16(arg)   __builtin_bswap16(arg)
     127#else
    124128extern uint64 __swap_int64(uint64 arg);
    125129extern uint32 __swap_int32(uint32 arg);
    126130extern uint16 __swap_int16(uint16 arg);
     131#endif
    127132
    128133#ifdef __cplusplus
    129134}