转载:http://blog.csdn.net/kasalyn/article/details/17097639

The __KERNEL__ macro is defined because there is programs (like libraries) that include kernel code and there is many things that you don't want them to include. So most modules will want the__KERNEL__ macro to be enabled.

When you compile your kernel, __KERNEL__ is defined on the command line. (in tree/kernel/Makefile---> KBUILD_CPPFLAGS := -D__KERNEL__)

User-space programs need access to the kernel headers, but some of
the info in kernel headers is intended only for the kernel. Wrapping
some statements in an#ifdef __KERNEL__/#endif block ensures that user-space programs don't see those statements.

example:

in the user space ,if you want to include the header using ‘#ifdef __KERNEL__ XXXX', you should define the __KERNEL__.

/*为了引用kernel中的数据结构,我常用如下样式include那些服务于内核的头文件*/

#ifdef __KERNEL__
#include <linux/list.h>
#include <linux/mm.h>
#undef __KERNEL__

/*将两种类型的头文件隔离开来*/
#include <stdio.h>
#include <errno.h>

对于__KERNEL__举例:

#ifdef __KERNEL__
# define HZ        CONFIG_HZ    /* Internal kernel timer frequency */
# define USER_HZ    100        /* User interfaces are in "ticks" */
# define CLOCKS_PER_SEC    (USER_HZ)    /* like times() */
#else
# define HZ        100
#endif

在.config中:

CONFIG_HZ=100

故ISA-32中,HZ=100,而jiffies =10ms

__KERNEL__ macro的更多相关文章

  1. FreeMarker学习(宏<#macro>的使用)

    原文链接:https://my.oschina.net/weiweiblog/blog/506301?p=1 用户定义指令-使用@符合来调用  有两种不同的类型:Macro(宏)和transform( ...

  2. configure.ac:32: error: possibly undefined macro: AC_DEFINE

    在ubuntu 下编译snappy时,在检查依赖关系时,处理autoconf的包时,在相关依赖包都已经安装的情况下,报如下错误,死活不过. configure.ac:32: error: possib ...

  3. 【freemaker】之自定义指令<#macro>

    测试代码 @Test public void test07(){ try { root.put("name", "张三"); freemakerUtil.fpr ...

  4. C++ macro(宏)使用小结

    谈起C++中的宏,我们第一个想到的应该就是“#define”,它的基本语法长得像这样: #define macroname(para1, para2, para3, ... ,paran) macro ...

  5. Macro and SQL

    If you’ve developed anything in the supply chain area, you’ve most probably come across InventDimJoi ...

  6. The difference between macro and function I/Ofunction comparision(from c and pointer )

    macro is typeless and execute faster than funtion ,becaus of the overhead of calling and returnning ...

  7. Cmockery macro demo hacking

    /********************************************************************* * Cmockery macro demo hacking ...

  8. 幾種方法實現C語言Macro for debug

    1. #include <stdio.h> #include <stdlib.h> #define DEBUG 1 #ifdef DEBUG #define DEBUG_PRI ...

  9. jinja2 宏的简单使用总结(macro)

    Table of Contents 1. 简介 2. 用法 3. 参数和变量 4. 注意事项 4.1. macro的变量只能为如下三种: 4.2. 和block的关系: 5. 参考文档 1 简介 ji ...

随机推荐

  1. docker集成管理工具-shipyard的开发环境搭建笔记

    前段时间一直在研究openstack,后来老师告诉我需要用docker容器来搭建hadoop集群,所以就将战场转移到docker上来了,话说docker最近这段时间太火了,但是说实话我觉得应用起来还不 ...

  2. 第三百二十六天 how can I 坚持

    今天元宵节啊,晚上去蓝色港湾看了看灯光节,快冻死了,人倒是挺多. 其他没啥了. 还有晚上吃了几个元宵. 好像冻感冒了,有点头晕. 睡觉.

  3. KMP算法——Javascript实现

    腾讯和阿里的笔试刚过去了,里面有很多题都很值得玩味的.之前Blog积累的很多东西,还要平时看的书,都有很大的帮助.这个深有体会啊! 例如,腾讯有一道算法题是吃香蕉(好邪恶的赶脚..),一次吃一根或者两 ...

  4. Cisco 防止SYN Flood 攻击原理

    DoS(Denial of Service拒绝服务)和DDoS(Distributed Denial of Service分布式拒绝服务)攻击是大型网站和网络服务器的安全威胁之一.2000年2月,Ya ...

  5. winform 映射字段的写法:

    public partial class FrmFieldMapping : DevComponents.DotNetBar.Office2007Form { private AMDataFieldC ...

  6. c# 解决IIS写Excel的权限问题

    c# 解决IIS写Excel的权限问题 from: http://www.jb51.net/article/31473.htm 发布:mdxy-dxy 字体:[增加 减小] 类型:转载 使用以上方法必 ...

  7. 8.1搜索专练DFS和BFS

    这是第一次全部做出来的依次练习了,有一些都是做过两遍了的,但是还是错了几回,更多时候我还是应该多注意下细节,就好像章爷笑我 的一样,像什么vis[]标记没清0,什么格式错误,还有什么题目没看清,还是的 ...

  8. 编译ffmpeg(iOS)

    一,x264库的编译 首先到http://www.videolan.org/developers/x264.html下载x264的库,然后解压,修改文件夹名称为x264     二,下载ffmpeg2 ...

  9. JPA 原生态SQL 的复杂查询之createNamedQuery

    JPA 原生态SQL 的复杂查询之createNamedQuery调用存储过程,返回的List字段对应的填充实体============实体类,调用存储过程====================== ...

  10. Lucene/ElasticSearch 学习系列 (2) Information Retrival 初步之名词解释

    计算机领域一半是理论,一半是在理论基础之上的应用.要想深入地掌握某个方面的应用,就需要先学习那方面的理论. “搜索”是应用,其背后的理论是 "Information Retrieval&qu ...