linux内核 数据类型,Linux驱动知识:内核中常用的数据类型

#include typedef u8;

typedef u16;

typedef u32;

typedef u64;

The equivalent signed types exist as well. In user space, you can refer to the types as __u8, _ _u16, and so forth.

#include

PAGE_SIZE //未必是4K

PAGE_SHIFT

Symbols that define the number of bytes per page for the current architecture and the number of bits in the page offset (12 for 4-KB pages and 13 for 8-KB pages).

#include __LITTLE_ENDIAN

__BIG_ENDIAN

Only one of the two symbols is defined, depending on the architecture.

#include u32 __cpu_to_le32 (u32);

u32 __le32_to_cpu (u32);

Functions that convert between known byte orders and that of the processor. There are more than 60 such functions; see the various files ininclude/linux/byteorder/ for a full list and the ways in which they are defined.

#include get_unaligned(ptr);

put_unaligned(val, ptr);

Some architectures need to protect unaligned data access using these macros. The macros expand to normal pointer dereferencing for architectures that permit you to access unaligned data.

有的平台上在非对齐的位置存取相应数据(比如在4的非整数倍地址上访问u32)会有问题,有的平台是通过产生异常并在异常处理中进行读写,极大降低了性能。

#include

void *ERR_PTR(longerror);long PTR_ERR(const void *ptr);long IS_ERR(const void *ptr);

Functions allow error codes to be returned by functions that return a pointer value.

#include list_add(struct list_head *new, struct list_head *head);

list_add_tail(struct list_head *new, struct list_head *head);

list_del(struct list_head *entry);

list_del_init(struct list_head *entry);

list_empty(struct list_head *head);

list_entry(entry, type, member);

list_move(struct list_head *entry, struct list_head *head);

list_move_tail(struct list_head *entry, struct list_head *head);

list_splice(struct list_head *list, struct list_head *head);

Functions that manipulate circular, doubly linked lists.

list_for_each(struct list_head *cursor, struct list_head *list)

list_for_each_prev(struct list_head *cursor, struct list_head *list)

list_for_each_safe(struct list_head *cursor, struct list_head *next, struct list_head *list)

list_for_each_entry(type*cursor, struct list_head *list, member)

list_for_each_entry_safe(type*cursor, type *next struct list_head *list, member)

Convenience macros for iterating through linked lists.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值