转载: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. SQL2008 SQL Server 代理服务提供的凭据无效

    工作中遇到的问题记录: 安装到服务器配置时出的错误:为 SQL Server 代理服务提供的凭据无效.若要继续操作,请为 SQL Server 代理服务提供有效的帐户和密码. 解决方法:直接在所有的“ ...

  2. HDU 2516 取石子游戏(FIB博弈)

    取石子游戏 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submi ...

  3. HDU 1525 Euclid's Game (博弈)

    Euclid's Game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  4. fastscript调用delphi方法和DELPHI调用FASTSCRIPT方法

    fastscript调用Delphi过程:  1. 先创建事件处理方法:TfsCallMethodEvent 2. 然后再用调用TfsScript.AddMethod方法,第一个参数为Delphi方法 ...

  5. LeetCode100:Same Tree

    Given two binary trees, write a function to check if they are equal or not. Two binary trees are con ...

  6. c++中的array数组和vector数组

    我觉得实验一下会记得比较牢,话不多直接上代码. 下面是array数组,感觉用的不多. //cpp 风格数组 array #include <iostream> #include <a ...

  7. window

  8. MenuStrip菜单递归

    C# TreeView菜单,MenuStrip菜单递归动态生成例子 http://www.cnblogs.com/ajiaojiao0303/articles/1884772.html http:// ...

  9. CloudStack4.2 更新全局参数

    { "updateconfigurationresponse": { "configuration": { "category": &quo ...

  10. PostgreSQL中的AnyEnum例子

    建立函数: CREATE OR REPLACE FUNCTION enumtest(anyenum) RETURNS text AS $$ ::text; $$ LANGUAGE SQL; 建立enu ...