byteswap.hh (12386:2bf5fb25a5f1) byteswap.hh (12521:da4f02f2e5d7)
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;

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

149template <typename T> inline T htole(T value) {return value;}
150template <typename T> inline T letoh(T value) {return value;}
151template <typename T> inline T htobe(T value) {return swap_byte(value);}
152template <typename T> inline T betoh(T value) {return swap_byte(value);}
153#else
154 #error Invalid Endianess
155#endif
156
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;

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

149template <typename T> inline T htole(T value) {return value;}
150template <typename T> inline T letoh(T value) {return value;}
151template <typename T> inline T htobe(T value) {return swap_byte(value);}
152template <typename T> inline T betoh(T value) {return swap_byte(value);}
153#else
154 #error Invalid Endianess
155#endif
156
157template <typename T>
158inline T htog(T value, ByteOrder guest_byte_order)
159{
160 return guest_byte_order == BigEndianByteOrder ?
161 htobe(value) : htole(value);
162}
163
164template <typename T>
165inline T gtoh(T value, ByteOrder guest_byte_order)
166{
167 return guest_byte_order == BigEndianByteOrder ?
168 betoh(value) : letoh(value);
169}
170
157namespace BigEndianGuest
158{
159 const ByteOrder GuestByteOrder = BigEndianByteOrder;
160 template <typename T>
161 inline T gtole(T value) {return betole(value);}
162 template <typename T>
163 inline T letog(T value) {return letobe(value);}
164 template <typename T>

--- 26 unchanged lines hidden ---
171namespace BigEndianGuest
172{
173 const ByteOrder GuestByteOrder = BigEndianByteOrder;
174 template <typename T>
175 inline T gtole(T value) {return betole(value);}
176 template <typename T>
177 inline T letog(T value) {return letobe(value);}
178 template <typename T>

--- 26 unchanged lines hidden ---