关于宏定义中的 struct 成员 ##1

30 views
Skip to first unread message

kernel.cn niko

unread,
Mar 2, 2011, 7:56:09 AM3/2/11
to Linux-...@zh-kernel.org
不知道怎么描述,所以标题乱了点。。。。。

最近看代码看到这样的宏定义:
*#define read_48(struc, entry) (le32_to_cpu((struc)->entry##1) |\*
* ((chunk_t)le16_to_cpu((struc)->entry##2) << 31 << 1))*
*
*
*其中,struc 为struct ,定义如下*
*
*
*
struct multisnap_commit_block {
......
__u32 alloc_rover1; /* the next place where to try allocation */
__u16 alloc_rover2;
*
*
......
}
所以读这个变量,为alloc_rover = read_48(cb, alloc_rover);

以前没见过,网上也没搜到相关的资料,求解..........
*
_______________________________________________
Linux 内核开发中文邮件列表
Linux-...@zh-kernel.org
http://zh-kernel.org/mailman/listinfo/linux-kernel
Linux 内核开发中文社区: http://zh-kernel.org

Américo Wang

unread,
Mar 2, 2011, 8:10:10 AM3/2/11
to kernel.cn niko, Linux-...@zh-kernel.org
On Wed, Mar 02, 2011 at 08:56:09PM +0800, kernel.cn niko wrote:
>不知道怎么描述,所以标题乱了点。。。。。
>
>最近看代码看到这样的宏定义:
>*#define read_48(struc, entry) (le32_to_cpu((struc)->entry##1) |\*
>* ((chunk_t)le16_to_cpu((struc)->entry##2) << 31 << 1))*
>*
>*
>*其中,struc 为struct ,定义如下*
>*
>*
>*
>struct multisnap_commit_block {
>......
>__u32 alloc_rover1; /* the next place where to try allocation */
>__u16 alloc_rover2;
>*
>*
>......
>}
>所以读这个变量,为alloc_rover = read_48(cb, alloc_rover);
>


~% gcc -E -xc -
#define read_48(struc, entry) (le32_to_cpu((struc)->entry##1) |\
((chunk_t)le16_to_cpu((struc)->entry##2) << 31 << 1))
alloc_rover = read_48(cb, alloc_rover);
# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "<stdin>"


alloc_rover = (le32_to_cpu((cb)->alloc_rover1) |((chunk_t)le16_to_cpu((cb)->alloc_rover2) << 31 << 1));

liuchang

unread,
Mar 3, 2011, 7:25:40 AM3/3/11
to linux-...@zh-kernel.org
宏定义中## 的意思是连接符。比如
#define link(a, b, c) a##b##c
而 link(1, 2, 3)
展开就是 123。

kernel.cn niko

unread,
Mar 3, 2011, 8:26:55 PM3/3/11
to liuchang, linux-...@zh-kernel.org
后来看到用法我也理解了,非常感谢。
就是有时候看代码时碰到诸如此类的问题不知道到哪去查,
大家有没有内核开发入门科普一级的资料啊。。。。
thks

2011/3/3 liuchang <liuc...@nrchpc.ac.cn>

china.gd.sz.cd

unread,
Mar 4, 2011, 3:07:28 AM3/4/11
to linux-...@zh-kernel.org
大家好,
我有一个问题想请教大家,
在内核里:
arch/arm/include/asm/cacheflush.h
#define dmac_inv_range cpu_cache.dma_inv_range
#define dmac_clean_range cpu_cache.dma_clean_range
#define dmac_flush_range cpu_cache.dma_flush_range
这三个定义是起什么作用的?真的不明白。
谢谢!

fbwww

unread,
Mar 5, 2011, 2:28:39 AM3/5/11
to china.gd.sz.cd, linux-...@zh-kernel.org
Linux内核会把内存都用作硬盘缓存,以加快硬盘访问,如果用户进程需要,再将内存给用户进程用
我记得在大内存(24G内存, PAE)的服务器上,内核缓存就很大了,早超过1G了,但是在32位系统中,内核之访问1G空间范围的内核内存空间,不知道是怎么处理的?

Luke Zhang (luzhan)

unread,
Mar 27, 2011, 9:56:14 PM3/27/11
to linux-...@zh-kernel.org
最后一封是3/3/2011,难道又坏了?

--luke

Alvin

unread,
Mar 29, 2011, 6:40:48 AM3/29/11
to Luke Zhang (luzhan), linux-...@zh-kernel.org
我发现很多都放进我Spam列表了

2011/3/28 Luke Zhang (luzhan) <luz...@cisco.com>


--

~Alvin

Tiny G

unread,
Mar 29, 2011, 9:39:03 PM3/29/11
to Alvin, linux-...@zh-kernel.org, Luke Zhang (luzhan)
不好说,我也是一段时间能收到信,一段时间收不到信

Zhi-zhou Zhang

unread,
Mar 29, 2011, 11:30:18 PM3/29/11
to Luke Zhang (luzhan), linux-...@zh-kernel.org
为什么都在spam里面呢。

Wang, Fei-Jiao

unread,
Apr 11, 2011, 11:39:06 PM4/11/11
to linux-...@zh-kernel.org

大家好,我是一个新手,想学习linux驱动相关的内容,请问谁能推荐基本这方面经典书籍,谢谢!!!

Wick

unread,
Apr 11, 2011, 11:48:54 PM4/11/11
to Wang, Fei-Jiao, linux-...@zh-kernel.org
LDD,没得说。

http://lwn.net/Kernel/LDD3/


2011/4/12 Wang, Fei-Jiao <Fei-Ji...@amd.com>:

--
Shenzhen, CN
twitter: @izhangxc

Reply all
Reply to author
Forward
0 new messages