- 论坛徽章:
- 0
|
本帖最后由 wangzhen11aaa 于 2011-11-26 09:23 编辑
- 22
- 23 for (i = 0; i < 100; i++) {
- 24 newx = ACCESS_ONCE(x);
- 25 if (newx != oldx) {
- 26 printf("lock_reader() : x = %d \n", newx);
- 27 }
- 28 oldx = newx;
- 29 poll(NULL, 0, 1);
复制代码 ACESS_ONCE(x) 宏定义在 /linux/compiler.h 中
当我包含 <linux/compiler.h>
gcc 报告没有这个文件。
当我加上 -I /usr/src/kernels/linux-2.6.39.1/include/linux 时,出现一大堆错误。
当我不包含 <linux/compiler.h>时,当然就出现了
$gcc -o Plockrw Plockrw.c -pthread
/tmp/cc4ktUwE.o: In function `lock_reader':
Plockrw.c.text+0x53): undefined reference to `ACCESS_ONCE'
/tmp/cc4ktUwE.o: In function `lock_writer':
Plockrw.c.text+0x114): undefined reference to `ACCESS_ONCE'
collect2: ld 返回 1
我在想,是把这个当作一个模块来写还是一个普通的应用程序来写。
请指教。。。 |
|