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

📄 ulint.h

📁 linux内核
💻 H
字号:
#ident "$Id$"/* ----------------------------------------------------------------------- * *    *   Copyright 2001-2004 H. Peter Anvin - All Rights Reserved * *   This program is free software; you can redistribute it and/or modify *   it under the terms of the GNU General Public License as published by *   the Free Software Foundation, Inc., 675 Mass Ave, Cambridge MA 02139, *   USA; either version 2 of the License, or (at your option) any later *   version; incorporated herein by reference. * * ----------------------------------------------------------------------- *//* * ulint.h * * Basic operations on unaligned, littleendian integers  */#ifndef ULINT_H#define ULINT_H#include <inttypes.h>/* These are unaligned, littleendian integer types */typedef uint8_t le8_t;		/*  8-bit byte */typedef uint8_t le16_t[2];	/* 16-bit word */typedef uint8_t le32_t[4];	/* 32-bit dword *//* Read/write these quantities */static inline unsigned charread8(le8_t *_p){  return *_p;}static inline voidwrite8(le8_t *_p, uint8_t _v){  *_p = _v;}#if defined(__i386__) || defined(__x86_64__)/* Littleendian architectures which support unaligned memory accesses */static inline unsigned shortread16(le16_t *_p){  return *((const uint16_t *)_p);}static inline voidwrite16(le16_t *_p, unsigned short _v){  *((uint16_t *)_p) = _v;}static inline unsigned intread32(le32_t *_p){  return *((const uint32_t *)_p);}static inline voidwrite32(le32_t *_p, uint32_t _v){  *((uint32_t *)_p) = _v;}#else /* Generic, mostly portable versions */static inline unsigned shortread16(le16_t *_p){  uint16_t _v;  _v  = p[0];  _v |= p[1] << 8;  return _v;}static inline voidwrite16(le16_t *_p, uint16_t _v){  _p[0] = _v & 0xFF;  _p[1] = (_v >> 8) & 0xFF;}static inline unsigned intread32(le32_t *_p){  _v  = _p[0];  _v |= _p[1] << 8;  _v |= _p[2] << 16;  _v |= _p[3] << 24;  return _v;}static inline voidwrite32(le32_t *_p, uint32_t _v){  _p[0] = _v & 0xFF;  _p[1] = (_v >> 8) & 0xFF;  _p[2] = (_v >> 16) & 0xFF;  _p[3] = (_v >> 24) & 0xFF;}#endif#endif /* ULINT_H */

⌨️ 快捷键说明

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