⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 byte_swap.hh

📁 linux下基于c++的处理器仿真平台。具有处理器流水线
💻 HH
字号:
/* * Copyright (c) 2004, 2005 * The Regents of The University of Michigan * All Rights Reserved * * This code is part of the M5 simulator, developed by Nathan Binkert, * Erik Hallnor, Steve Raasch, and Steve Reinhardt, with contributions * from Ron Dreslinski, Dave Greene, Lisa Hsu, Kevin Lim, Ali Saidi, * and Andrew Schultz. * * Permission is granted to use, copy, create derivative works and * redistribute this software and such derivative works for any * purpose, so long as the copyright notice above, this grant of * permission, and the disclaimer below appear in all copies made; and * so long as the name of The University of Michigan is not used in * any advertising or publicity pertaining to the use or distribution * of this software without specific, written prior authorization. * * THIS SOFTWARE IS PROVIDED AS IS, WITHOUT REPRESENTATION FROM THE * UNIVERSITY OF MICHIGAN AS TO ITS FITNESS FOR ANY PURPOSE, AND * WITHOUT WARRANTY BY THE UNIVERSITY OF MICHIGAN OF ANY KIND, EITHER * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE. THE REGENTS OF THE UNIVERSITY OF MICHIGAN SHALL NOT BE * LIABLE FOR ANY DAMAGES, INCLUDING DIRECT, SPECIAL, INDIRECT, * INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WITH RESPECT TO ANY CLAIM * ARISING OUT OF OR IN CONNECTION WITH THE USE OF THE SOFTWARE, EVEN * IF IT HAS BEEN OR IS HEREAFTER ADVISED OF THE POSSIBILITY OF SUCH * DAMAGES. */#ifndef __ARCH_ALPHA_BYTE_SWAP_HH__#define __ARCH_ALPHA_BYTE_SWAP_HH__#if defined(linux)#include <endian.h>#else#include <machine/endian.h>#endif#include "sim/byte_swap.hh"/* Note: the host byte-order is defined by BYTE_ORDER, but there is no macro to specify the guest byte-order, instead it is assumed to be little endian */#if BYTE_ORDER == BIG_ENDIANstatic inline uint64_tletoh(uint64_t x) { return swp_byte64(x); }static inline int64_tletoh(int64_t x) { return swp_byte64((uint64_t)x); }static inline uint32_tletoh(uint32_t x) { return swp_byte32(x); }static inline int32_tletoh(int32_t x) { return swp_byte32((uint32_t)x); }static inline uint16_tletoh(uint16_t x) { return swp_byte16(x); }static inline int16_tletoh(int16_t x) { return swp_byte16((uint16_t)x); }static inline uint8_tletoh(uint8_t x) { return x; }static inline int8_tletoh(int8_t x) { return x; }static inline double letoh(double x) { return swp_byte32((uint64_t)x); } static inline float letoh(float x) { return swp_byte64((uint32_t)x); }static inline uint64_tletoh(uint64_t x) { return swp_byte64(x); }static inline int64_tgtoh(int64_t x) { return swp_byte64((uint64_t)x); }static inline uint32_tgtoh(uint32_t x) { return swp_byte32(x); }static inline int32_tgtoh(int32_t x) { return swp_byte32((uint32_t)x); }static inline uint16_tgtoh(uint16_t x) { return swp_byte16(x); }static inline int16_tgtoh(int16_t x) { return swp_byte16((uint16_t)x); }static inline uint8_tgtoh(uint8_t x) { return x; }static inline int8_tgtoh(int8_t x) { return x; }static inline double gtoh(double x) { return swp_byte32((uint64_t)x); } static inline float gtoh(float x) { return swp_byte64((uint32_t)x); }#elif BYTE_ORDER == LITTLE_ENDIANstatic inline uint64_tletoh(uint64_t x) { return x; }static inline int64_tletoh(int64_t x) { return x; }static inline uint32_tletoh(uint32_t x) { return x; }static inline int32_tletoh(int32_t x) { return x; }static inline uint16_tletoh(uint16_t x) { return x; }static inline int16_tletoh(int16_t x) { return x; }static inline uint8_tletoh(uint8_t x) { return x; }static inline int8_tletoh(int8_t x) { return x; }static inline double letoh(double x) { return x; } static inline float letoh(float x) { return x; }static inline uint64_tgtoh(uint64_t x) { return x; }static inline int64_tgtoh(int64_t x) { return x; }static inline uint32_tgtoh(uint32_t x) { return x; }static inline int32_tgtoh(int32_t x) { return x; }static inline uint16_tgtoh(uint16_t x) { return x; }static inline int16_tgtoh(int16_t x) { return x; }static inline uint8_tgtoh(uint8_t x) { return x; }static inline int8_tgtoh(int8_t x) { return x; }static inline double gtoh(double x) { return x; } static inline float gtoh(float x) { return x; }#else #error Invalid Endianness #endif /* BYTE_ORDER */static inline uint64_thtole(uint64_t x) { return letoh(x); }static inline int64_thtole(int64_t x) { return letoh(x); }static inline uint32_thtole(uint32_t x) { return letoh(x); }static inline int32_thtole(int32_t x) { return letoh(x); }static inline uint16_thtole(uint16_t x) { return letoh(x); }static inline int16_thtole(int16_t x) { return letoh(x); }static inline uint8_thtole(uint8_t x) { return x; }static inline int8_thtole(int8_t x) { return x; }static inline double htole(double x) { return letoh(x); } static inline float htole(float x) { return letoh(x); }static inline uint64_thtog(uint64_t x) { return gtoh(x); }static inline int64_thtog(int64_t x) { return gtoh(x); }static inline uint32_thtog(uint32_t x) { return gtoh(x); }static inline int32_thtog(int32_t x) { return gtoh(x); }static inline uint16_thtog(uint16_t x) { return gtoh(x); }static inline int16_thtog(int16_t x) { return gtoh(x); }static inline uint8_thtog(uint8_t x) { return x; }static inline int8_thtog(int8_t x) { return x; }static inline double htog(double x) { return gtoh(x); } static inline float htog(float x) { return gtoh(x); }#endif /* __ARCH_ALPHA_BYTE_SWAP_HH__ */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -