byteswap.hh (11800:54436a1784dc) byteswap.hh (12383:57de7e3b7ba0)
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;

--- 125 unchanged lines hidden (view full) ---

134template<>
135inline Twin32_t swap_byte<Twin32_t>(Twin32_t x)
136{
137 x.a = swap_byte(x.a);
138 x.b = swap_byte(x.b);
139 return x;
140}
141
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;

--- 125 unchanged lines hidden (view full) ---

134template<>
135inline Twin32_t swap_byte<Twin32_t>(Twin32_t x)
136{
137 x.a = swap_byte(x.a);
138 x.b = swap_byte(x.b);
139 return x;
140}
141
142template <typename T, size_t N>
143inline std::array<T, N>
144swap_byte(std::array<T, N> a)
145{
146 for (T &v: a)
147 v = swap_byte(v);
148 return a;
149}
150
142//The conversion functions with fixed endianness on both ends don't need to
143//be in a namespace
144template <typename T> inline T betole(T value) {return swap_byte(value);}
145template <typename T> inline T letobe(T value) {return swap_byte(value);}
146
147//For conversions not involving the guest system, we can define the functions
148//conditionally based on the BYTE_ORDER macro and outside of the namespaces
149#if (defined(_BIG_ENDIAN) || !defined(_LITTLE_ENDIAN)) && BYTE_ORDER == BIG_ENDIAN

--- 49 unchanged lines hidden ---
151//The conversion functions with fixed endianness on both ends don't need to
152//be in a namespace
153template <typename T> inline T betole(T value) {return swap_byte(value);}
154template <typename T> inline T letobe(T value) {return swap_byte(value);}
155
156//For conversions not involving the guest system, we can define the functions
157//conditionally based on the BYTE_ORDER macro and outside of the namespaces
158#if (defined(_BIG_ENDIAN) || !defined(_LITTLE_ENDIAN)) && BYTE_ORDER == BIG_ENDIAN

--- 49 unchanged lines hidden ---