转载: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. Home-brew 安装&卸载 Git

    安装 brew install git 卸载git: rm -rf /usr/local/git rm /etc/paths.d/git rm /etc/manpaths.d/git sudo rm ...

  2. 类似于QQ游戏百万人同时在线的服务器架构实现

    http://blog.csdn.net/sodme/article/details/213995 —————————————————————————————————————————————————— ...

  3. Terrain & Light & Camera

    [Terrain Engine] 1.When you press F, wherever your mouse is positioned will be moved to the center o ...

  4. area标签circle/rect/poligon坐标

    <img src="images/02.gif" title="flower" usemap="#mm" /> <map ...

  5. 在Ribbon中,中文换行位置不对怎么办

    在Ribbon代码的编写时,关于UI上面设置Button的中文字,经常会出现不想换行的地方换行的情况,比如下图: 我如果希望中国一行,然后只有一行怎么办呢. 网上流传的很多方法就是直接加空格,但是很遗 ...

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

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

  7. JavaScript神一样的变量系统

    话说上一篇介绍了JavaScript故事版的身世之谜.看官你估计也明白JavaScript出生之时,就未曾托于重任.布兰登-艾奇估计也没料到今天的JavaScript变得如此重要.要不然,当年他也不会 ...

  8. 移动端类似IOS的滚动年月控件(需要jQuery和iScroll)

    一. 效果图 二. 功能介绍 支持滚动和点击选择年月.(目前只支持设置年月的最大最小值,不支持整体的最大最小值) 三. 代码 1. 在你的html中添加如下代码: 直接加载<body>里面 ...

  9. CI reids 缓存

    注意:在项目中的application/libraries 中自己定义的类最好不要以cache命名. 连接 Redis 服务器的配置信息必须保存到 application/config/redis.p ...

  10. 【转载】Fragment 全解析(1):那些年踩过的坑

    http://www.jianshu.com/p/d9143a92ad94 Fragment系列文章:1.Fragment全解析系列(一):那些年踩过的坑2.Fragment全解析系列(二):正确的使 ...