mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-29 01:58:55 +00:00
ca971bbfd8
This patch changes the top-level directory layout as a preparatory step for improving the tools for managing 3rd-party source codes. The rationale is described in the issue referenced below. Issue #1082
31 lines
659 B
C++
31 lines
659 B
C++
/*
|
|
* \brief Convert between host endianess and big endian.
|
|
* \author Stebastian Sumpf
|
|
* \author Stefan Kalkowski
|
|
* \date 2010-08-04
|
|
*/
|
|
|
|
/*
|
|
* Copyright (C) 2010-2013 Genode Labs GmbH
|
|
*
|
|
* This file is part of the Genode OS framework, which is distributed
|
|
* under the terms of the GNU General Public License version 2.
|
|
*/
|
|
#ifndef _UTIL__ENDIAN_H_
|
|
#define _UTIL__ENDIAN_H_
|
|
|
|
#include <base/stdint.h>
|
|
|
|
template <typename T>
|
|
inline T bswap(T x)
|
|
{
|
|
Genode::uint8_t v[sizeof(T)];
|
|
for (unsigned i=0; i<sizeof(T); i++) {
|
|
unsigned mask = (sizeof(T) - i - 1) * 8;
|
|
v[i] = (x & (0xff << mask)) >> mask;
|
|
}
|
|
return *(T *)v;
|
|
}
|
|
|
|
#endif /* _UTIL__ENDIAN_H_ */
|