__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 ...
随机推荐
- 《学习OpenCV》练习题第四章第二题
#include <highgui.h> #include <cv.h> #pragma comment (lib,"opencv_calib3d231d.lib&q ...
- 在适配iPhone 6 Plus屏幕的时候,模拟器上两边有很细的白边如何解决
取消掉Constrain to margin 然后添加左右约束 版权声明:本文为博主原创文章,未经博主允许不得转载.
- [POJ] #1004# Financial Management : 浮点数运算
一. 题目 Financial Management Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 173910 Acc ...
- 检查 CPU 是否支持二级地址转换 - 摘自网络
Windows 8 Consumer Preview 于2月正式发布,随后 Windows Server 8 Beta 也公布了下载.整体对比,Windows 8 在硬件方面的要求并不高,其最低硬件需 ...
- dom 拖拽回放
<!doctype html> <html> <head> <meta charset="utf-8"> <title> ...
- linux 从命令行自动识别文件并将其打开的命令
若是shell是 zsh,则可: 使用 alias -s 定义后缀别名 (zsh) % alias -s pl=perl % script.pl perl script.pl % alias -s p ...
- 编译安装glibc
转帖地址下载glibcwget http://ftp.gnu.org/gnu/glibc/glibc-2.3.2.tar.gz 下载glibc-linuxthreadswget http://ftp. ...
- HDU 5778 abs (素数,暴力)
题意:给定一个数x,求正整数y≥2y\geq 2y≥2,使得满足以下条件: 1.y-x的绝对值最小 2.y的质因数分解式中每个质因数均恰好出现2次. 析:由于y质因数分解式中每个质因数均出现2次,那么 ...
- Uncaught TypeError: Object #<Object> has no method 'fancybox'
Uncaught TypeError: Object #<Object> has no method 'fancybox' 2011-10-24 16:51:19| 分类: html|举 ...
- 汇编语言程序入门实验一:在dos下对用户输入作出应答
汇编语言程序入门实验一:在dos下对用户输入作出应答 1,背景 成功预言了今天要上计算机操作系统上机实验课,昨天预习后,今天的两个上机实验做得很成功.但是也有一些问题.问题1:学校的系统目前是wind ...