byteorder.h
来自「学习嵌入式LINUX的好东西」· C头文件 代码 · 共 27 行
H
27 行
#ifndef _MAIN_H#define _MAIN_H// Byte swapping.#define swap8(A) (A)#define swap16(A) ((((A)&0x00ff)<<8) | ((A)>>8))#define swap32(A) ((((A)&0x000000ff)<<24) | (((A)&0x0000ff00)<<8) | (((A)&0x00ff0000)>>8) | (((A)&0xff000000)>>24))#define htonl(x) swap32(x) // host to network, long#define ntohl(x) swap32(x) // network to host, long#define htons(x) swap16(x) // host to network, short#define ntohs(x) swap16(x) // network to host, short#define htobl(x) swap32(x) // host to big endian, long#define btohl(x) swap32(x) // big endian to host, long#define htobs(x) swap32(x) // host to big endian, short#define btohs(x) swap32(x) // big endian to host, short#define htoll(x) (x) // host to little endian, long#define ltohl(x) (x) // little endian to host, long#define htols(x) (x) // host to little endian, short#define ltohs(x) (x) // little endian to host, short#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?