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

📄 byteorder.h

📁 红外接口串口仿真
💻 H
字号:
#ifndef _ASM_BYTEORDER_H
#define _ASM_BYTEORDER_H

#include <linux/types.h>

#define __constant_htons(x) \
	((__u16)( \
		(((__u16)(x) & (__u16)0x00ffU) << 8) | \
		(((__u16)(x) & (__u16)0xff00U) >> 8) ))

__inline __u16 swap16(__u16 x)
{
    __asm
    {
        mov  ax,x
        xchg al,ah
        mov  x,ax
    }
    return x;
}

__inline __u32 swap32(__u32 x)
{
    __asm
    {
        mov  eax,x
        bswap eax
        mov  x,eax
    }
    return x;
}

#define cpu_to_be16(x)  swap16((x))
#define cpu_to_le16(x)  ((__u16)(x))
#define cpu_to_be32(x)  swap32((x))
#define cpu_to_be32s(x) do { *(x) = swap32(*(x)); } while (0)
#define cpu_to_le32s(x)

#define be16_to_cpu(x)  swap16((x))
#define le16_to_cpu(x)  ((__u16)(x))
#define be32_to_cpus(x) do { *(x) = swap32(*(x)); } while (0)
#define le32_to_cpus(x)

#define htons(x)        cpu_to_be16((x))

#endif

⌨️ 快捷键说明

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