__KERNEL__ macro
转载: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的更多相关文章
- FreeMarker学习(宏<#macro>的使用)
原文链接:https://my.oschina.net/weiweiblog/blog/506301?p=1 用户定义指令-使用@符合来调用 有两种不同的类型:Macro(宏)和transform( ...
- configure.ac:32: error: possibly undefined macro: AC_DEFINE
在ubuntu 下编译snappy时,在检查依赖关系时,处理autoconf的包时,在相关依赖包都已经安装的情况下,报如下错误,死活不过. configure.ac:32: error: possib ...
- 【freemaker】之自定义指令<#macro>
测试代码 @Test public void test07(){ try { root.put("name", "张三"); freemakerUtil.fpr ...
- C++ macro(宏)使用小结
谈起C++中的宏,我们第一个想到的应该就是“#define”,它的基本语法长得像这样: #define macroname(para1, para2, para3, ... ,paran) macro ...
- Macro and SQL
If you’ve developed anything in the supply chain area, you’ve most probably come across InventDimJoi ...
- 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 ...
- Cmockery macro demo hacking
/********************************************************************* * Cmockery macro demo hacking ...
- 幾種方法實現C語言Macro for debug
1. #include <stdio.h> #include <stdlib.h> #define DEBUG 1 #ifdef DEBUG #define DEBUG_PRI ...
- jinja2 宏的简单使用总结(macro)
Table of Contents 1. 简介 2. 用法 3. 参数和变量 4. 注意事项 4.1. macro的变量只能为如下三种: 4.2. 和block的关系: 5. 参考文档 1 简介 ji ...
随机推荐
- Android Studio 中SDK Manager的设置
android studio 代码块左边的缩进对齐线的颜色修改: Settings -> Editor -> Colors & Fonts -> General -> ...
- [翻译]Behavior-Driven Development (BDD)行为驱动开发(二)
测试驱动开发体现了开发人员对软件产品各部分运作方式的理解,而行为驱动开发则关注于开发人员对软件产品最终表现的行为的预期. 行为驱动开发 TDD更像是一种范式而不是一个过程.它描述了一种先编写测试,然后 ...
- react native listview 一个有用的属性,用作两列布局
contentContainerStyle:设置listview包裹内容的属性 <ListView contentContainerStyle={{flexDirection:'row',fle ...
- 记一次PHP项目部署过程
首先介绍一下项目的基本情况:使用PHP语言开发,数据库用的是MySQL 5.5,HTTP服务器用的是Apache 2.2.早上十点到机房看了看服务器的基本情况:Windows 2000操作系统,没有安 ...
- UI:数据持久化
数据持久化 参考1 参考2 参考3 什么是数据持久化,就是将文件保存在本地的硬盘中,使得应用程序或者机器重启后可以继续访问以前保留的数据.IOS开发中有许多的数据持久化方案. 如下面五种方案 ...
- 《Spring3.0就这么简单》第1章快速入门
问题 [如何将jsp中传递到HttpServletRequest的参数,自动装配到Java对象中] [成功] public void setUsernAme(String username) < ...
- 数据库 SQL :数据库三大泛式简谈
相信,在学习数据库知识时,大家都会碰到这个概念问题:数据三大泛式,同时,在面试过程中,可能大部分面试官也会提及这个问题. 首先,看看维基百科对于三大泛式的定义: 数据库规范化,又称数据库或资料库的正规 ...
- putty 中文乱码解决方法
解决putty.exe 中文乱码的问题 export NLS_LANG="AMERICAN_AMERICA.ZHS16GBK"
- 130712周赛(CF)
这次练习从第一题开始注定水了,1A的题目wa了3次,第三题走进了错误的思想,wa到死....其他三个题目看都没看...........赛后慢慢搞. A. Free Cash 巨水的一题,直接找出每个时 ...
- MON166 User's Guide
MON166 is a debug monitor for C16x and ST10 user programs. It consists of: A configurable monitor pr ...