byteswap.hh (8902:75b524b64c28) | byteswap.hh (10776:20686329e673) |
---|---|
1/* 2 * Copyright (c) 2004 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 135 unchanged lines hidden (view full) --- 144 145//The conversion functions with fixed endianness on both ends don't need to 146//be in a namespace 147template <typename T> inline T betole(T value) {return swap_byte(value);} 148template <typename T> inline T letobe(T value) {return swap_byte(value);} 149 150//For conversions not involving the guest system, we can define the functions 151//conditionally based on the BYTE_ORDER macro and outside of the namespaces | 1/* 2 * Copyright (c) 2004 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 135 unchanged lines hidden (view full) --- 144 145//The conversion functions with fixed endianness on both ends don't need to 146//be in a namespace 147template <typename T> inline T betole(T value) {return swap_byte(value);} 148template <typename T> inline T letobe(T value) {return swap_byte(value);} 149 150//For conversions not involving the guest system, we can define the functions 151//conditionally based on the BYTE_ORDER macro and outside of the namespaces |
152#if defined(_BIG_ENDIAN) || !defined(_LITTLE_ENDIAN) && BYTE_ORDER == BIG_ENDIAN | 152#if (defined(_BIG_ENDIAN) || !defined(_LITTLE_ENDIAN)) && BYTE_ORDER == BIG_ENDIAN |
153const ByteOrder HostByteOrder = BigEndianByteOrder; 154template <typename T> inline T htole(T value) {return swap_byte(value);} 155template <typename T> inline T letoh(T value) {return swap_byte(value);} 156template <typename T> inline T htobe(T value) {return value;} 157template <typename T> inline T betoh(T value) {return value;} 158#elif defined(_LITTLE_ENDIAN) || BYTE_ORDER == LITTLE_ENDIAN 159const ByteOrder HostByteOrder = LittleEndianByteOrder; 160template <typename T> inline T htole(T value) {return value;} --- 41 unchanged lines hidden --- | 153const ByteOrder HostByteOrder = BigEndianByteOrder; 154template <typename T> inline T htole(T value) {return swap_byte(value);} 155template <typename T> inline T letoh(T value) {return swap_byte(value);} 156template <typename T> inline T htobe(T value) {return value;} 157template <typename T> inline T betoh(T value) {return value;} 158#elif defined(_LITTLE_ENDIAN) || BYTE_ORDER == LITTLE_ENDIAN 159const ByteOrder HostByteOrder = LittleEndianByteOrder; 160template <typename T> inline T htole(T value) {return value;} --- 41 unchanged lines hidden --- |